예제 #1
0
        // PRAGMA MARK - Internal
        protected override void Activate()
        {
            PlayerSpawner.SpawnAllPlayers();

            List <GameModeIntroView.Icon> icons = new List <GameModeIntroView.Icon>();

            foreach (Player player in RegisteredPlayers.AllPlayers)
            {
                icons.Add(GameModeIntroView.Icon.Player);
                icons.Add(GameModeIntroView.Icon.Swords);
            }
            icons.RemoveLast();

            BattlePlayerHealth.LaserDamage         = 0;
            BattlePlayerHealth.KnockbackMultiplier = 0.1f;

            GameModeIntroView.Show(DisplayTitle, icons);

            foreach (Player player in RegisteredPlayers.AllPlayers.Where(p => p.IsAI))
            {
                BattlePlayer battlePlayer = PlayerSpawner.GetBattlePlayerFor(player);
                battlePlayer.Rigidbody.constraints |= RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ;
            }

            PlayerSpawner.OnSpawnedPlayerRemoved += HandleSpawnedPlayerRemoved;
        }
예제 #2
0
        private void HandleBattlePlayerShotLaser(Laser laser, BattlePlayer battlePlayer)
        {
            if (battlePlayer != PlayerSpawner.GetBattlePlayerFor(Player_))
            {
                return;
            }

            recordedShots_++;
        }
예제 #3
0
        private void HandleBattlePlayerReflectLaser(Laser laser, BattlePlayer battlePlayerThatReflected)
        {
            if (battlePlayerThatReflected != PlayerSpawner.GetBattlePlayerFor(Player_))
            {
                return;
            }

            recordedReflects_++;
        }
예제 #4
0
        private void HandleBattlePlayerDashHit(BattlePlayer battlePlayerHit, BattlePlayer battlePlayerSource)
        {
            if (battlePlayerSource != PlayerSpawner.GetBattlePlayerFor(Player_))
            {
                return;
            }

            recordedHits_++;
        }
예제 #5
0
        // PRAGMA MARK - Public Interface
        public void Init(Player player)
        {
            battlePlayer_      = PlayerSpawner.GetBattlePlayerFor(player);
            nicknameText_.Text = player.Nickname;
            playerColor_       = player.Skin.UIColor;

            UpdateAnchoredPosition();
            Animate();
        }
예제 #6
0
        private void RecordHitIfLaserMeetsRequirements(Laser laser)
        {
            // if reflected then doesn't count
            if (laser.BattlePlayerSources.Count > 1)
            {
                return;
            }

            if (laser.BattlePlayer != PlayerSpawner.GetBattlePlayerFor(Player_))
            {
                return;
            }

            recordedHits_++;
        }
예제 #7
0
        private void HandleBattlePlayerFellOffGround(BattlePlayer battlePlayer)
        {
            if (battlePlayer != PlayerSpawner.GetBattlePlayerFor(Player_))
            {
                return;
            }

            if (battlePlayer.Health.KnockbackDamageSource != null)
            {
                // need to check for my own laser hitting me + pushing me off the edge
                if (battlePlayer.Health.KnockbackDamageSource is Laser)
                {
                    Laser knockbackLaser = battlePlayer.Health.KnockbackDamageSource as Laser;

                    // if laser source is not self - then someone else pushed me off the edge
                    if (knockbackLaser.BattlePlayer != battlePlayer)
                    {
                        return;
                    }
                }
                else if (battlePlayer.Health.KnockbackDamageSource is BattlePlayer)
                {
                    BattlePlayer knockbackPlayer = battlePlayer.Health.KnockbackDamageSource as BattlePlayer;

                    if (knockbackPlayer == battlePlayer)
                    {
                        Debug.LogWarning("How did battlePlayer knockback themselves?? Investigate please.");
                    }

                    // knockbacked by another player - does not count as suicide
                    return;
                }

                recordedSuicidesByLaser_++;
            }
            else
            {
                // classic suicide - just walked / dashed off the edge
                recordedSuicidesByFalling_++;
            }
        }
예제 #8
0
        private void HandleBattlePlayerDiedWithSource(BattlePlayer battlePlayer, object damageSource)
        {
            if (battlePlayer != PlayerSpawner.GetBattlePlayerFor(Player_))
            {
                return;
            }

            Laser laser = damageSource as Laser;

            if (laser == null)
            {
                return;
            }

            // if source is not self - then it is not a suicide
            if (laser.BattlePlayer != battlePlayer)
            {
                return;
            }

            recordedSuicidesByLaser_++;
        }
예제 #9
0
        protected override void Activate()
        {
            PlayerSpawner.SpawnAllPlayers();

            // Sort the players from lowest score to highest score
            List <Player> players = RegisteredPlayers.AllPlayers.ToList();

            players.Sort((playerA, playerB) => {
                return(PlayerScores.GetScoreFor(playerA).CompareTo(PlayerScores.GetScoreFor(playerB)));
            });

            teams_ = new HashSet <Player> [kNumberOfTeams];
            if (players.Count == 4 && kNumberOfTeams == 2)
            {
                teams_[0] = new HashSet <Player>()
                {
                    players[0], players[3]
                };
                teams_[1] = new HashSet <Player>()
                {
                    players[1], players[2]
                };
            }
            else
            {
                Debug.LogWarning("Assumptions failed when creating teams - random teams!");

                players.Shuffle();

                int teamIndex = 0;
                foreach (Player player in players)
                {
                    if (teams_[teamIndex] == null)
                    {
                        teams_[teamIndex] = new HashSet <Player>();
                    }

                    teams_[teamIndex].Add(player);

                    teamIndex = MathUtil.Wrap(teamIndex + 1, 0, kNumberOfTeams);
                }
            }

            // set override color for players
            for (int i = 0; i < teams_.Length; i++)
            {
                HashSet <Player> team = teams_[i];

                foreach (Player player in team)
                {
                    BattlePlayer battlePlayer = PlayerSpawner.GetBattlePlayerFor(player);
                    ObjectPoolManager.Create(accessoryPrefabs_[i], parent: battlePlayer.AccessoriesContainer);
                }
            }

            foreach (HashSet <Player> team in teams_)
            {
                BattlePlayerTeams.DeclareTeam(team.Select(p => PlayerSpawner.GetBattlePlayerFor(p)));
            }

            List <int> playerOrdering           = new List <int>();
            List <GameModeIntroView.Icon> icons = new List <GameModeIntroView.Icon>();

            for (int i = 0; i < teams_.Length - 1; i++)
            {
                playerOrdering.AddRange(teams_[i].Select(p => RegisteredPlayers.AllPlayers.IndexOf(p)));
                icons.AddRange(teams_[i].Select(p => GameModeIntroView.Icon.Player));
                icons.Add(GameModeIntroView.Icon.Swords);
            }
            playerOrdering.AddRange(teams_[teams_.Length - 1].Select(p => RegisteredPlayers.AllPlayers.IndexOf(p)));
            icons.AddRange(teams_[teams_.Length - 1].Select(p => GameModeIntroView.Icon.Player));

            GameModeIntroView.Show(DisplayTitle, icons, playerOrdering);

            PlayerSpawner.OnSpawnedPlayerRemoved += HandleSpawnedPlayerRemoved;
        }