public void ResetGame() { this.IsRunning = false; GameReset?.Invoke(); UnityEngine.SceneManagement.SceneManager.LoadScene( UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex ); this.IsRunning = true; }
public void PrepareNewGame() { GameReset?.Invoke(); foreach (IGameCellView computerGameCell in computerGameCells) { computerGameCell.ClearEvents(); computerGameCell.cellClicked += (coordinates) => CellAttacked?.Invoke(coordinates); } }
public void Initalize() { if (playerTemp != null) { Destroy(playerTemp); } IsNotFreezed = CanMove = true; GameReset?.Invoke(this); booted = false; }
/// <summary> /// プレイヤーが死んだときに呼ばれます。 /// </summary> public void Initalize() { if (playerTemp != null) { Destroy(playerTemp); } Player.Life = Player.MaxLife; Player.WaterPoint = PlayerData.MaxWaterPoint; Player.FoodPoint = PlayerData.MaxFoodPoint; IsNotFreezed = CanMove = true; GameReset?.Invoke(this); IsPostInitialized = false; }
public static void InvokeGameReset() { GameReset?.Invoke(); }
void Update() { if (!_startReady) { return; } float dt = Time.deltaTime; if (_finished) { if (Input.anyKey && Time.time - _gameTimerElapsed > LevelResumeTime) { if (_result != Result.Running && _result != Result.LostEarnings && _result != Result.LostExhaustion) { if (LevelIdx < LevelList.Count) { LevelIdx++; if (LevelIdx == LevelList.Count) { _gameTimerElapsed = Time.time; GameBeaten?.Invoke(LevelResumeTime); } else { CheckStartFatigue(); GameReset?.Invoke(); InitLevel(LevelList[LevelIdx]); } } else { LevelIdx = 0; StartFatigue = 0; InitLevel(LevelList[LevelIdx]); } } else { StartFatigue = 0; GameReset?.Invoke(); InitLevel(LevelList[LevelIdx]); } } return; } _gameTimerElapsed += dt; bool exhausted = _result == Result.LostExhaustion; int nextRev = 0; if (_gameTimerElapsed >= CurrentLevel.LevelTimeSeconds || exhausted) { if (_revenue < CurrentLevel.MinRevenue) { _result = Result.LostEarnings; nextRev = CurrentLevel.MinRevenue; } else if (_revenue < CurrentLevel.GoodRevenue) { _result = Result.WonBase; nextRev = CurrentLevel.GoodRevenue; } else if (_revenue < CurrentLevel.GreatRevenue) { _result = Result.WonGood; nextRev = CurrentLevel.GreatRevenue; } else { _result = Result.WonGreat; } if (exhausted) { _result = Result.LostExhaustion; // Override to avoid several ifs above. } _finished = true; GameFinished?.Invoke(_result, _revenue, nextRev, LevelResumeTime); _gameTimerElapsed = Time.time; } else { // requests check: if (_requestIdx < CurrentLevel.NumClients) { _requestElapsed += dt; if (_requestElapsed >= _requestTimes[_requestIdx]) { RequestData reqData = GenerateRequest(); int slotIdx = ActiveClientRequestSlots.FindIndex(x => !_requestAllocations.ContainsKey(x)); if (slotIdx < 0) { _stalledRequests.Enqueue(reqData); } else { _requestAllocations[ActiveClientRequestSlots[slotIdx]] = reqData; ActiveClientRequestSlots[slotIdx].InitClient(reqData); } _requestIdx++; } } if (_dragging) { float fatigueDelta = dt * DragDepletionRate; _fatigue += fatigueDelta; bool exhaustionCheck = _fatigue >= MaxFatigue; if (exhaustionCheck) { _fatigue = MaxFatigue; _result = Result.LostExhaustion; } OnFatigueChanged?.Invoke(FatiguePercent); if (exhaustionCheck) { return; } } else if (_elapsedSinceLastDragFinished >= 0) { _elapsedSinceLastDragFinished += dt; if (_elapsedSinceLastDragFinished > IdleToRestoreTime) { _elapsedSinceLastDragFinished = IdleToRestoreTime; _fatigue -= dt * FatigueRestoreRate; if (_fatigue < 0) { _fatigue = 0; _elapsedSinceLastDragFinished = -1.0f; } OnFatigueChanged?.Invoke(FatiguePercent); } } foreach (var resBuilding in ActiveResourceBuildings) { resBuilding.UpdateGame(dt); } foreach (var recBuilding in ActiveRecipeBuildings) { recBuilding.UpdateGame(dt); } foreach (var slot in ActiveClientRequestSlots) { slot.UpdateLogic(dt); } } }
public static void ResetGame() { GameReset?.Invoke(); }