public void EndGame(bool victory) { if (gameEnded) { return; // Dont end twice } gameEnded = true; OnEndOfGame?.Invoke(); if (victory) { OnVictory?.Invoke(); } else { OnGameOver?.Invoke(); } TimeManager.Instance.ChangeTimescale(0f); if (endOfGame != null) { StopCoroutine(endOfGame); endOfGame = null; } endOfGame = StartCoroutine(ResetGame()); }
private IEnumerator VictoryCoroutine() { yield return(new WaitForSeconds(endGameDelay)); OnVictory?.Invoke(); Time.timeScale = 0; }
private void Update() { if (finalRound && orcCounter == 0) { OnVictory?.Invoke(); } }
void CheckVictory() { if (puzzle.isVictory()) { OnVictory?.Invoke(); } }
void Victory() { // if (CurrentLevel.MovesRecord==0 || movesCount < CurrentLevel.MovesRecord) //CurrentLevel.MovesRecord = movesCount; bool isNewRecord = false; RecordLevelSave.AddRecord(CurrentLevel, movesCount, out isNewRecord); victory = true; OnVictory?.Invoke(movesCount, RecordLevelSave.GetRecordByLevelID(CurrentLevel), isNewRecord); movesCount = 0; saveController.DeleteSave(CurrentLevel.ID); }
void Awake() { Time.timeScale = 1; BotManager.Instance.OnTeamDisable += (int teamID) => { Time.timeScale = 0; Debug.Log("Team " + teamID + " all disabled. Returning to editor."); int victorTeamID = teamID == 0 ? 1 : 0; OnVictory?.Invoke(victorTeamID); StartCoroutine(ReturnToEditor()); }; }
/// <summary> /// Runs a battle between the player and npc /// </summary> /// <returns></returns> public void Battle(Player player) { if (Health <= 0) { OnLoss?.Invoke(this, EventArgs.Empty); } player.Damage(Level); if (player.Health <= 0) { OnVictory?.Invoke(this, EventArgs.Empty); } }
private void OnEnemyKilled(object sender, System.EventArgs e) { _messageBroker.RaiseMessage($"{_enemy.Name} is dead"); _messageBroker.RaiseMessage($"You get {_enemy.RewardExp} exp"); _messageBroker.RaiseMessage($"You get {_enemy.Credits} credits"); _player.ReciveCredits(_enemy.Credits); foreach (Item lootItem in _enemy.Inventory.Items) { _player.AddItemToInventory(lootItem); _messageBroker.RaiseMessage($"You get {lootItem.Name} from corpse"); } _player.AddExp(_enemy.RewardExp); OnVictory?.Invoke(this, new CombatVictoryEventArgs()); }
public void Play(Card card) { if (waitingForInput || !turnInProgress) { ArrangeCards(); return; } BaseCardBehaviour(card); switch (card.cardValue) { case Card.CardValue.Sedm: { manager.sevenState += 2; turnInProgress = false; OnEndTurn(this, this); break; } case Card.CardValue.Svrsek: { workingCard = card; if (controlledByLocal) { GetColorInput(card); } break; } case Card.CardValue.Eso: { manager.aceState = true; turnInProgress = false; OnEndTurn(this, this); break; } default: { turnInProgress = false; OnEndTurn(this, this); break; } } if (hand.Count == 0) { OnVictory?.Invoke(this, this); } ArrangeCards(); }
void GameTimeEnded() { OnTimerEnd += () => { if (HasWon()) { OnVictory?.Invoke(); //Debug.Log("YOu have won"); GetComponent <CanvasSwitcher>()?.OpenScreen(CanvasType.WinScreen); } else { OnDefeat?.Invoke(); GetComponent <CanvasSwitcher>()?.OpenScreen(CanvasType.LoseScreen); } StopGame(); }; }
public void MakeMove(Cell cell) { if (State == GameState.Stopped || !_gameEngine.IsMoveValid(cell)) { return; } CurrentPlayerPutPiece(cell); if (_gameEngine.IsVictory(Field)) { State = GameState.Stopped; OnVictory?.Invoke(this, EventArgs.Empty); } else { NextPlayer(); } }
public void Start(Action onStartCompleted) { Debug.Log("Starting the game"); InitServices(); m_GameEntities = GetComponentsInChildren <IBoxesGameEntity>(m_GamePlayScene); var entitiesInitQueue = ListPool <IBoxesGameEntity> .Get(); entitiesInitQueue.AddRange(m_GameEntities); InitGameEntities(entitiesInitQueue, () => { ListPool <IBoxesGameEntity> .Release(entitiesInitQueue); onStartCompleted.Invoke(); }); Assert.IsNotNull(m_MainCharacter); var deathZones = GetComponentsInChildren <DeathZone>(m_GamePlayScene); foreach (var deathZone in deathZones) { deathZone.OnCollision += character => { character.Die(); if (character == m_MainCharacter) { OnDefeat?.Invoke(); } }; } var winZones = GetComponentsInChildren <WinZone>(m_GamePlayScene); foreach (var winZone in winZones) { winZone.OnCollision += character => { if (character == m_MainCharacter) { OnVictory?.Invoke(); } }; } }
public void CheckVictory() { if (VictoryDeclared) { return; } foreach (var score in NeededScore) { CollectedCarsScore.TryGetValue(score.Key, out int currentlyCollected); if (currentlyCollected < score.Value) { return; } } OnVictory?.Invoke(); SoundManager.Instance.PlaySoundVictory(); VictoryDeclared = true; }
IEnumerator CoVictory() { OnVictory?.Invoke(); yield return(new WaitForSeconds(victoryDuration)); yield return(StartCoroutine(ScreenFader.Me.CoFade(ScreenFader.Transitions.victory))); if (nextSceneIndex < 0) { SceneManager.LoadScene("Scene Level Select"); } else if (nextSceneIndex < 9) { SceneManager.LoadScene(nextSceneIndex); } else { SceneManager.LoadScene("Scene End Game"); } }
public void GameWin() { OnVictory?.Invoke(); }
public void ActivateVictory(string victory_message = "") { OnVictory?.Invoke(victory_message); }
private void OnTriggerEnter2D(Collider2D other) { Debug.Log("Flag !"); OnVictory?.Invoke(); }
void Win() { Time.timeScale = 0.0f; OnVictory?.Invoke(); }