private void Start() { loadResources(); patrolFactory.StartPatrol(); for (int i = 0; i < patrols.Count; i++) { patrolActionManager.Patrol(patrols[i]); } moveWall = GameObject.FindGameObjectWithTag("move"); }
void Update() { GameObject tmp1 = null; GameObject tmp2 = null; foreach (GameObject patrol in patroling) { if (Vector3.Distance(patrol.transform.position, player.transform.position) <= 5) { tmp1 = patrol; patrolActionManager.CatchPlayer(patrol); } } if (tmp1 != null) { catching.Add(tmp1); patroling.Remove(tmp1); } foreach (GameObject patrol in catching) { if (Vector3.Distance(patrol.transform.position, player.transform.position) <= 1) { gameover = true; } if (Vector3.Distance(patrol.transform.position, player.transform.position) > 5) { tmp2 = patrol; patrolActionManager.Patrol(patrol); scoreRecorder.addScore(); } } if (tmp2 != null) { patroling.Add(tmp2); catching.Remove(tmp2); } }
//public Camera cameraMain; void Start() { SSDirector director = SSDirector.getInstance(); director.CurrentSceneController = this; scoreRecorder = Singleton <ScoreRecorder> .Instance; patrolFactory = Singleton <PatrolFactory> .Instance; playerRegion = 4; patrolActionManager = gameObject.AddComponent <PatrolActionManager>(); userGUI = gameObject.AddComponent <UserGUI>() as UserGUI; LoadResources(); for (int i = 0; i < patrols.Count; ++i) { patrolActionManager.Patrol(patrols[i]); } }
private List <GameObject> patrols; // 场景中巡逻兵列表 // 场景初始化 void Start() { Director director = Director.GetInstance(); director.CurrentSceneController = this; patrolFactory = Singleton <PatrolFactory> .Instance; playerRegion = 5; patrolActionManager = gameObject.AddComponent <PatrolActionManager>(); userGUI = gameObject.AddComponent <UserGUI>() as UserGUI; director.SetFPS(30); director.leaveSeconds = 60; LoadResources(); // 巡逻兵开始巡逻 for (int i = 0; i < patrols.Count; i++) { patrolActionManager.Patrol(patrols[i]); } }
// 失去目标,巡逻兵放弃追击 public void OnGoalLost(GameObject patrol) { patrolActionManager.Patrol(patrol); scoreRecorder.Record(); }
// 失去目标,巡逻兵放弃追击 public void OnGoalLost(GameObject patrol) { patrolActionManager.Patrol(patrol); }