void Update() { if (battleEngine == null || !battleEngine.isRunning) { return; } if (_mapView == null) { InitMap(); } // 只有部分玩法有暂停 if (battleEngine.Context.isPaused) { return; } // 1. sync actors SyncActors(); // 2. tick _dt = Time.deltaTime; // 3. update actors if (_mapView != null) { _mapView.DoUpdate(_dt); } foreach (FoodView food in _foodViewList) { if (!food.Model.IsReleased) { food.DoUpdate(_dt); } else { removeFoodView.Add(food); } } foreach (SnakerActor snaker in _snakerActorList) { if (!snaker.Model.IsReleased) { snaker.DoUpdate(_dt); } else { removeSnakerActor.Add(snaker); } } // 4 remove dead entity foreach (FoodView food in removeFoodView) { _foodViewList.Remove(food); DestroyFood(food); } removeFoodView.Clear(); foreach (SnakerActor snaker in removeSnakerActor) { _snakerActorList.Remove(snaker); DestroySnaker(snaker); } removeSnakerActor.Clear(); }