Example #1
0
        // Called as part of gameObject.AddComponent<...>(). Can therefore not have initialization here that is added after addComponent, use Start() instead
        void Awake()
        {
            AFEventManager.INSTANCE.AddListener(this);

            // Setting up scoring resources
            currentRoundScores = PlayersState.INSTANCE.gameScores.StartNewRound();
            PlayersState.INSTANCE.gameScoresAccumulator = (acc, current) => UndeadScore.Accumulator((UndeadScore)acc, (UndeadScore)current);

            undeadSettings             = (UndeadGameSettings)GameSettingsState.INSTANCE.GameModeSettings;
            NumberOfGameRounds         = undeadSettings.NumberOfGameRounds;
            NumberOfStartingUndead     = undeadSettings.StartingUndead;
            UndeadRespawnTimeInSeconds = undeadSettings.UndeadRespawnTimeInSeconds;
            AliveKillPoints            = undeadSettings.AliveKillPoints;
            UndeadKillPoints           = undeadSettings.UndeadKillPoints;
        }
Example #2
0
        void HandleGameStart(List <PlayerSettings> allPlayers)
        {
            foreach (var ps in allPlayers)
            {
                var playerScore = new UndeadScore(ps.playerNumber, ps.color);
                currentRoundScores.AddScoreForPlayer(playerScore);
            }

            var undeadPlayerNumbers = SelectPlayersToStartAsUndead(PlayersState.INSTANCE.gameScores, NumberOfStartingUndead);

            foreach (var playerScore in currentRoundScores.Scores)
            {
                if (ArrayUtils.Contains(playerScore.PlayerNumber(), undeadPlayerNumbers))
                {
                    ((UndeadScore)playerScore).Undead          = true;
                    ((UndeadScore)playerScore).StartedAsUndead = true;
                    MakeUndead(allPlayers.Find(ps => ps.playerNumber == playerScore.PlayerNumber()));
                }
                else
                {
                    MakeLiving(allPlayers.Find(ps => ps.playerNumber == playerScore.PlayerNumber()));
                }
            }
        }
Example #3
0
 public static UndeadScore Accumulator(UndeadScore acc, UndeadScore current)
 {
     return(new UndeadScore(acc.playerColor, acc.playerNumber, acc.score + current.score, acc.Deaths + current.Deaths, false, acc.StartedAsUndead || current.StartedAsUndead));
 }