death + poge face

This commit is contained in:
2023-02-02 00:00:48 +05:30
parent 92ac8ad88a
commit a1b46f9342
35 changed files with 1967 additions and 11 deletions

View File

@@ -12,6 +12,7 @@ public class Drawer : MonoBehaviour
bool dragging = false;
public void OnMouseDown(BaseEventData e){
if (drawn) { return; }
PointerEventData ped = (PointerEventData) e as PointerEventData;
dragging= true;
@@ -19,7 +20,7 @@ public class Drawer : MonoBehaviour
lineRenderer.SetPositions(new Vector3[0]);
points = new List<Vector3>();
drawn = true;
// lineRenderer.transform.position = new Vector3(0, 0, 10);
//lineRenderer.GetComponent<Rigidbody2D>().simulated = false;
@@ -57,7 +58,7 @@ public class Drawer : MonoBehaviour
}
bool drawn = false;
void FinishDrawing()
{
List<Vector2> points3 = new List<Vector2>();

View File

@@ -17,9 +17,14 @@ public class Enemy : MonoBehaviour
Color debugColor = Color.white;
void FixedUpdate()
{
if (GameManager.Player == null) { return; }
RaycastHit2D hit = Physics2D.Linecast(transform.position, GameManager.Player.position, linecastLayer);
if (hit.collider == null) {
canSeePlayer = true;
@@ -38,6 +43,15 @@ public class Enemy : MonoBehaviour
Debug.DrawLine(transform.position, hit.point, debugColor);
}
if (canSeePlayer)
{
if (Vector2.Distance(GameManager.Player.position, transform.position) < distanceThreshold*5)
{
GameManager.GameOver();
return;
}
}
Vector3 direction = (GameManager.Player.position - new Vector3(0,0.5f,0) - transform.position).normalized;
if (dodgeTimer < dodgeTime)

View File

@@ -1,6 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviour
{
@@ -8,18 +9,21 @@ public class GameManager : MonoBehaviour
public static Transform Player { get { if (instance == null) { return null; } return instance.player; } }
public static GameManager instance { get;private set; }
public GameObject gameOverPanel;
void Awake()
{
instance = this;
}
void Start()
public static void GameOver()
{
instance.gameOverPanel.SetActive(true);
}
// Update is called once per frame
void Update()
public void Restart()
{
SceneManager.LoadScene(0);
}
}