Timer
This commit is contained in:
parent
a1b46f9342
commit
d2d1d49d48
|
|
@ -821,7 +821,7 @@ GameObject:
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 0
|
||||||
--- !u!114 &947231828
|
--- !u!114 &947231828
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -981,7 +981,14 @@ MonoBehaviour:
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
player: {fileID: 1688767157}
|
player: {fileID: 1688767157}
|
||||||
|
timerTxt: {fileID: 1335199560}
|
||||||
|
game_start_timer: 5
|
||||||
|
game_end_timer: 15
|
||||||
gameOverPanel: {fileID: 1815937850}
|
gameOverPanel: {fileID: 1815937850}
|
||||||
|
bees:
|
||||||
|
- {fileID: 947231827}
|
||||||
|
- {fileID: 1919562618}
|
||||||
|
- {fileID: 1094132247}
|
||||||
--- !u!1 &1094132247
|
--- !u!1 &1094132247
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -1000,7 +1007,7 @@ GameObject:
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 0
|
||||||
--- !u!58 &1094132248
|
--- !u!58 &1094132248
|
||||||
CircleCollider2D:
|
CircleCollider2D:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -1210,6 +1217,85 @@ BoxCollider2D:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 1, y: 1}
|
m_Size: {x: 1, y: 1}
|
||||||
m_EdgeRadius: 0
|
m_EdgeRadius: 0
|
||||||
|
--- !u!1 &1335199558
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1335199559}
|
||||||
|
- component: {fileID: 1335199561}
|
||||||
|
- component: {fileID: 1335199560}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: timer
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!224 &1335199559
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1335199558}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 1981446461}
|
||||||
|
m_RootOrder: 2
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
m_AnchorMin: {x: 0, y: 1}
|
||||||
|
m_AnchorMax: {x: 0, y: 1}
|
||||||
|
m_AnchoredPosition: {x: 19.98999, y: -17.06}
|
||||||
|
m_SizeDelta: {x: 250, y: 100}
|
||||||
|
m_Pivot: {x: 0, y: 1}
|
||||||
|
--- !u!114 &1335199560
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1335199558}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_RaycastTarget: 1
|
||||||
|
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_Maskable: 1
|
||||||
|
m_OnCullStateChanged:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_FontData:
|
||||||
|
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
m_FontSize: 54
|
||||||
|
m_FontStyle: 0
|
||||||
|
m_BestFit: 0
|
||||||
|
m_MinSize: 10
|
||||||
|
m_MaxSize: 73
|
||||||
|
m_Alignment: 0
|
||||||
|
m_AlignByGeometry: 0
|
||||||
|
m_RichText: 1
|
||||||
|
m_HorizontalOverflow: 0
|
||||||
|
m_VerticalOverflow: 0
|
||||||
|
m_LineSpacing: 1
|
||||||
|
m_Text:
|
||||||
|
--- !u!222 &1335199561
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1335199558}
|
||||||
|
m_CullTransparentMesh: 1
|
||||||
--- !u!1 &1680175197
|
--- !u!1 &1680175197
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -1505,7 +1591,7 @@ GameObject:
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 0
|
||||||
--- !u!114 &1919562619
|
--- !u!114 &1919562619
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -1699,6 +1785,7 @@ RectTransform:
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 892467176}
|
- {fileID: 892467176}
|
||||||
- {fileID: 1815937851}
|
- {fileID: 1815937851}
|
||||||
|
- {fileID: 1335199559}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 4
|
m_RootOrder: 4
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ public class Drawer : MonoBehaviour
|
||||||
points = new List<Vector3>();
|
points = new List<Vector3>();
|
||||||
|
|
||||||
drawn = true;
|
drawn = true;
|
||||||
|
GameManager.StartGame();
|
||||||
|
|
||||||
// lineRenderer.transform.position = new Vector3(0, 0, 10);
|
// lineRenderer.transform.position = new Vector3(0, 0, 10);
|
||||||
//lineRenderer.GetComponent<Rigidbody2D>().simulated = false;
|
//lineRenderer.GetComponent<Rigidbody2D>().simulated = false;
|
||||||
|
|
||||||
|
|
@ -73,6 +75,7 @@ public class Drawer : MonoBehaviour
|
||||||
//edgeCollider2D.SetPoints(points3);
|
//edgeCollider2D.SetPoints(points3);
|
||||||
edgeCollider2D.SetPath(0, points3);
|
edgeCollider2D.SetPath(0, points3);
|
||||||
edgeCollider2D.GetComponent<Rigidbody2D>().simulated = true;
|
edgeCollider2D.GetComponent<Rigidbody2D>().simulated = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnValidate()
|
void OnValidate()
|
||||||
|
|
|
||||||
|
|
@ -2,24 +2,65 @@ using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public class GameManager : MonoBehaviour
|
public class GameManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
public Transform player;
|
public Transform player;
|
||||||
public static Transform Player { get { if (instance == null) { return null; } return instance.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 gameOverPanel;
|
||||||
|
public GameObject[] bees;
|
||||||
void Awake()
|
void Awake()
|
||||||
{
|
{
|
||||||
instance = this;
|
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()
|
public static void GameOver()
|
||||||
{
|
{
|
||||||
instance.gameOverPanel.SetActive(true);
|
instance.gameOverPanel.SetActive(true);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Restart()
|
public void Restart()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user