public static void OnWinInvoke(object sender = null) { if (OnWin != null) { OnWin.Invoke(null, EventArgs.Empty); } }
public bool TryIsGameOver() { if (!HasMoveAvailable()) { // No more moves, game over! OnOutOfMoves?.Invoke(this, EventArgs.Empty); return(true); } switch (levelSO.goalType) { default: case LevelSO.GoalType.Score: if (score >= levelSO.targetScore) { // Reached Target Score! OnWin?.Invoke(this, EventArgs.Empty); return(true); } break; case LevelSO.GoalType.Glass: if (GetGlassAmount() <= 0) { // All glass destroyed! OnWin?.Invoke(this, EventArgs.Empty); return(true); } break; } // Not game over return(false); }
private IEnumerator CheckOpenedCard() { if (cards[cards.Count - 1].CardID == cards[cards.Count - 2].CardID) { score.AddScore(cards.Count == 2 ? health.HealthCount : 3 * health.HealthCount); if (cards.Count == 3) { _successPicks += 3; if (_successPicks == gridRows * gridCols) { OnWin?.Invoke(); } RemoveCardsFromField(); ClearVariables(); } } else { yield return(new WaitForSeconds(0.5f)); FlipCardsToBack(); health.TakeLife(); ClearVariables(); } }
/// <summary> /// OnPlayerPlayChess回调 /// </summary> /// <param name="obj"></param> private void ChessBoard_OnPlayerPlayChess(Vector2Int index, ChessState chessState) { //TODO判定是否是否胜利 if (JudeWinOrContinue(index, chessState) == true) { Debug.Log(chessState + "Win"); if (OnWin != null) { OnWin.Invoke();//执行结束的事件 剔除棋盘格子的射线事件 } UIManager.Instance.chessState = chessState; UIManager.Instance.gameStatus = GameStatus.Over; return; } playerIndex++;//增加回合 #region 轮询逻辑 if (OnTurn != null) { OnTurn.Invoke(playerIndex);//暂停事件 } #endregion //TODO增加栈 来储存10步内的悔棋。 }
private void OnItemDestroyed(Static.Item staticItem) { var itemIndex = Targets.FindIndex(i => i.StaticItem.Id == staticItem.Id); if (itemIndex < 0) { return; } var item = Targets[itemIndex]; if (item.Amount <= 0) { return; } item.Amount--; Targets[itemIndex] = item; OnTargetsChange?.Invoke(Targets); var allItemsDestroyed = Targets.All(i => i.Amount <= 0); if (!allItemsDestroyed) { return; } Clear(); OnWin?.Invoke(); }
/// <summary> /// Завершаем шаг и проверяем выиграла ли одна из команд /// Команда выигрывает если все ее фигуры, которые могут двигаться /// достигли лагеря противоположенной команды /// </summary> public bool CompleteStep(PieceStrategy strategy) { bool hasAllPlayerPiecesReachedEnemyCamp = true; bool hasAllEnemyPiecesReachedPlayerCamp = true; bool playerIsBlocked = true; bool enemyIsBlocked = true; foreach (Piece piece in pieces) { // Проверям может ли двигаться фигура List <Cell> availableCells = strategy.GetAvailableCells(piece.cellRef); if (piece.IsPlayer) { bool isInEnemyCamp = IsInEnemyCamp(piece.cellRef); if (!isInEnemyCamp) { hasAllPlayerPiecesReachedEnemyCamp = false; } if (!isInEnemyCamp && availableCells.Count > 0) { playerIsBlocked = false; } } else { bool isInPlayerCamp = IsInPlayerCamp(piece.cellRef); if (!isInPlayerCamp) { hasAllEnemyPiecesReachedPlayerCamp = false; } if (availableCells.Count > 0) { enemyIsBlocked = false; } } } bool hasPlayerWon = hasAllPlayerPiecesReachedEnemyCamp || playerIsBlocked; bool hasEnemyWon = hasAllEnemyPiecesReachedPlayerCamp || enemyIsBlocked; // Все фишки игрока достигли вражеского лагеря либо заблокированы противником if (hasPlayerWon) { OnWin?.Invoke(true); } // Все фишки противника достигли лагеря игрока либо заблокированы игроком if (hasEnemyWon) { OnWin?.Invoke(false); } IsPlayerTurn = !IsPlayerTurn; return(hasPlayerWon || hasEnemyWon); }
public void Win() { Debug.Log("HELLLLLLO?"); gameOver = true; OnWin?.Invoke(this, System.EventArgs.Empty); MusicManager.Instance.PlayEnding(); }
public static void Win() { if (!PlayerProfile.sounds) { return; } OnWin.Invoke(); }
public void CheckIfWon() { if (currentBerriesCount == gameSettingsData.maxBerries) { OnWin?.Invoke(); berrySpawner.StopSpawning(); } }
public void DecreaseEnemyCount() { m_EnemyCount--; if (m_EnemyCount == 0 && !m_HasWon) { m_HasWon = true; OnWin?.Invoke(); } }
public void addVotes(int thousandVotes) { votes += thousandVotes; OnVoteGained.Invoke(); if (votes == votesToWin) { OnWin.Invoke(); } }
public static void PickupCollected(Pickup p) { Collected += 1; OnCollected?.Invoke(); if (Collected >= TotalPickups) { OnWin?.Invoke(); } }
private void HandleOnPipePlaced(Pipe pipe) { bool isWin = IsWin(); Debug.Log("Winner: " + isWin); if (IsWin()) { OnWin?.Invoke(); } }
private void CheckForWinCondition() { if (_currentCatSatiety < maxCatSatiety) { return; } StopSpawnFood(); isWon = true; OnWin?.Invoke(); FindObjectOfType <PauseController>().enabled = false; ClearFoodTable(); }
//Gestion des cubes //Pour le score savoir quelle cube sont dans le player public bool AddCubeToScore(Cube cube) { if (isStun) { return(true); } cubesInPlayer.Add(cube); OnWin?.Invoke(); return(false); }
private void EndGame(bool win) { gameUIController.TurnOfRocketButton(); PlayerPrefs.SetString(GlobalModule.GameData.PPKEY_HAS_SAVE, "false"); if (win) { OnWin?.Invoke(); } else { OnLose?.Invoke(); } }
public void Win() { foreach (var hero in Heroes) { var itemsStack = ItemsMap[hero.X, hero.Y]; if (itemsStack.Count == 0 || !(itemsStack.Peek() is DestinationItem)) { return; } } OnWin?.Invoke(); }
private void Damagable_OnDie(IDamageable instance) { m_Enemies.Remove(instance); Count++; instance.OnDie -= Damagable_OnDie; if (m_Enemies.Count == 0) { PlayTime = TimeProvider.Current.Now - m_StartTime; OnWin?.Invoke(); } }
private void CheckGameState() { if (_charactersState[EnemyTag] == 0 && _charactersState[AllyTag] == _alliesToSave) { OnWin?.Invoke(this, EventArgs.Empty); LevelLoader.Instance.LoadNextLevel(); } if (_charactersState[AllyTag] != _alliesToSave) { OnLose?.Invoke(this, EventArgs.Empty); LevelLoader.Instance.ReloadLevel(); } }
public void RemoveEnemy(int i) { CancelQueue(enemyList[i]); enemyList[i].OnAimChanged -= enemyHealthBar[i].ActionGauge.DrawGauge; enemyList[i].OnAttackSelected -= enemyHealthBar[i].DrawTarget; enemyList[i].Enemy.CharacterStatController.OnHPChanged -= enemyHealthBar[i].HealthGauge.DrawGauge; enemyList[i].Enemy.CharacterStatController.OnScratchChanged -= enemyHealthBar[i].ScratchGauge.DrawGauge; enemyHealthBar[i].Destroy(); if (enemyList.Count == 1) // On le fait à 1 pour pouvoir zoomer sur le dernier kill { OnWin.Invoke(); } enemyList.RemoveAt(i); enemyHealthBar.RemoveAt(i); }
void CheckForWinCondition() { if (currentNumberOfEnemiesSpawned == totalNumberOfEnemies) { arrayOfAliveEnemies = GameObject.FindGameObjectsWithTag("Enemy"); if (arrayOfAliveEnemies.Length == 0) { OnWin?.Invoke(); Debug.Log("YOU WIN"); } else { Debug.Log("Still left to fight!"); } } }
// private PuzzleBobbleSoundManager() { } public static void playSound(SoundsEvent e) { switch (e) { case SoundsEvent.BALL_EXPLOSION: { OnBallExplosion.Play(); break; } case SoundsEvent.BALL_DOCKED: { OnBallDocked.Play(); break; } case SoundsEvent.BALL_SHOOT: { OnBallShoot.Play(); break; } case SoundsEvent.ARROW_MOVED: { // OnArrowMoved.Play(); break; } case SoundsEvent.WIN: { OnWin.Play(); break; } case SoundsEvent.ROOF_TICK: { clockTicking.Play(); break; } case SoundsEvent.ROOF_DOWN: { doorSlam.Play(0.75f, 0.0f, 0.0f); break; } default: break; } }
public void Move(object sender, MoveArgs e) { if (e.playerId != Turn) { return; // not players turn Return } int col = e.col; int playerId = e.playerId; int row; //check a place is available in Coloum if (!Move_Available(col)) { return; // Move Not Avaliable Return } //annoyouns Move to network if it was made by local player if (e.playerId == Properties.Settings.Default.userId) { OnMoveMade?.Invoke(this, new MoveArgs(col, Properties.Settings.Default.userId)); } row = GetRow(col, playerId); lock (board) // Lock Board while in use { board.boardState[col, row] = e.playerId; //update Boardstate With move OnUpdate(this, board); } Turn *= -1; // use // use reference types that point to player / players peices ------------------------------------------------------ // dont repeat your selfs // Ai Takes over moves if (win(e.playerId, col, row)) { gameActive = false; OnWin?.Invoke(this, e.playerId.ToString()); // Publish Win Event } if (Ai && gameActive && Turn == Properties.Settings.Default.userId) { AiPlayer(); } }
public void GameOver() { isGameOver = true; bool won = score.CurrentStars >= 1; //TODO: If we see that saving and oading slows the device, //we can import the loaded data that was loaded previously and thus avoid loading inside TrySaveLevelData SaveAndLoadManager.TrySaveLevelData(LevelsManager.CurrentLevelNumber, (UInt32)Score.score, won); //currentLevel.PlayingCount++; if (won /*currentLevel.MinStarsToWin*/) //TODO: hardcoded winning condition(Can be moved to Level) { // currentLevel.LevelSucceeded(); //SaveAndLoadManager.TrySaveLevelData(LevelsManager.CurrentLevelNumber, (UInt32)Score.score); OnWin?.Invoke(score.CurrentStars);//TODO: Record the number of stars or/and score if it's larger than it was previously } else { OnLose.Invoke(); } OnGameOver?.Invoke(Score.score); }
private void Update() { if (!hasFinished && Time.frameCount > 4) // Magic number whatever it works { var location = new Vector2 { x = homeLocation.position.x, y = homeLocation.position.z, }; var distance = Vector2.Distance(location, HerdMember.Target); if (distance < homeRadius) { hasFinished = true; Debug.Log("Won the game."); OnWin?.Invoke(); } else if (herd.JoinedCount() == 0) { hasFinished = true; Debug.Log("Lost the game."); OnLose?.Invoke(); } } }
private void CheckConditions( ) { if (!_playerLost) { if (IsWinCondition( )) { ClearPlanets( ); WeaponManager.Instance.Clear( ); OnWin?.Invoke( ); } else if (IsLooseCondition( )) { _playerLost = true; ClearPlanets( ); WeaponManager.Instance.Clear( ); OnLoose?.Invoke( ); } } }
private void OnUpdateGameResult(object sender, ClientListener <PlayGameMessage> .TArg e) { //Проверка статуса игры: string status = e.Arg.GameStatus; switch (status) { case PlayGameMessage.PlayingGameStatus: OnUpdate?.Invoke(e.Arg); break; case PlayGameMessage.WinGameStatus: tcpClient.Dispose(); playGameListener.Stop(); OnWin?.Invoke(); break; case PlayGameMessage.LoseGameStatus: tcpClient.Dispose(); playGameListener.Stop(); OnLose?.Invoke(); break; } }
public void Win(Field field1, Field field2) { OnWin?.Invoke(this, new List <Field> { field1, field2 }); }
public void Win() { OnWin?.Invoke(); Debug.Log("Level completed in " + currentLevelTime.ToString()); }
public void PlayerWinYeet() { OnWin?.Invoke(); }