This commit is contained in:
2023-02-02 00:31:31 +05:30
parent a1b46f9342
commit d2d1d49d48
3 changed files with 138 additions and 7 deletions

View File

@@ -21,7 +21,9 @@ public class Drawer : MonoBehaviour
points = new List<Vector3>();
drawn = true;
// lineRenderer.transform.position = new Vector3(0, 0, 10);
GameManager.StartGame();
// lineRenderer.transform.position = new Vector3(0, 0, 10);
//lineRenderer.GetComponent<Rigidbody2D>().simulated = false;
}
@@ -73,6 +75,7 @@ public class Drawer : MonoBehaviour
//edgeCollider2D.SetPoints(points3);
edgeCollider2D.SetPath(0, points3);
edgeCollider2D.GetComponent<Rigidbody2D>().simulated = true;
}
void OnValidate()

View File

@@ -2,24 +2,65 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class GameManager : MonoBehaviour
{
public Transform player;
public static Transform Player { get { if (instance == null) { return null; } return instance.player; } }
public static GameManager instance { get;private set; }
public static GameManager instance { get; private set; }
public Text timerTxt;
public float game_start_timer = 5;
public float game_end_timer = 15;
public GameObject gameOverPanel;
public GameObject[] bees;
void Awake()
{
instance = this;
}
float t;
bool gameStarted = false;
bool beesReleased = false;
public static void StartGame()
{
instance.gameStarted= true;
}
private void Update()
{
if(!gameStarted) { return; }
t += Time.deltaTime;
if(t < game_start_timer)
{
timerTxt.text = (game_start_timer - t).ToString("n0");
}else if(t < game_end_timer)
{
if (!beesReleased) {
beesReleased = true;
ReleaseTheBees();
}
timerTxt.text = (game_end_timer - t).ToString("n0");
}
}
void ReleaseTheBees()
{
foreach(GameObject enemy in bees)
{
enemy.SetActive(true);
}
}
public static void GameOver()
{
instance.gameOverPanel.SetActive(true);
}
public void Restart()