Exemple #1
0
        /// <summary>
        /// Remove the player from the Active Players list for the Mission.
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        public bool RemoveActivePlayer(Client client)
        {
            if (!ActivePlayers.Contains(client))
            {
                return(false);
            }

            ActivePlayers.Remove(client);
            client.ResetData(EntityData.ActiveMission);
            NAPI.ClientEvent.TriggerClientEvent(client, "MissionInfo", "Mission_Active_Players", "");
            NAPI.ClientEvent.TriggerClientEvent(client, "MissionInfo", "Mission_Active_Objectives", "");

            string activePlayers = JsonConvert.SerializeObject(GetActivePlayers());

            for (int i = 0; i < ActivePlayers.Count; i++)
            {
                NAPI.ClientEvent.TriggerClientEvent(NAPI.Player.GetPlayerFromHandle(ActivePlayers[i]), "MissionInfo", "Mission_Active_Players", activePlayers);
            }

            if (ActivePlayers.Count <= 0)
            {
                CleanupMission();
            }

            return(true);
        }
Exemple #2
0
 void IStarcraftBot.onPlayerLeft(SWIG.BWAPI.Player player)
 {
     if (ActivePlayers.ContainsKey(player.getName()))
     {
         ActivePlayers.Remove(player.getName());
     }
 }
Exemple #3
0
        private void EliminatePlayer(Player playerToEliminate)
        {
            playerToEliminate.Active = false;
            ActivePlayers.Remove(playerToEliminate);

            if (playerToEliminate.Role == Role.Mafia)
            {
                Mafias.Remove((Mafia)playerToEliminate);
                return;
            }
            if (playerToEliminate.Role == Role.Doctor)
            {
                Doctors.Remove((Doctor)playerToEliminate);
            }
        }
Exemple #4
0
        //public void RespawnPlayer(EPlayerID playerID)
        //{
        //    if ((IS_KEY_NOT_CONTAINED(ActivePlayers, playerID))
        //        && (IS_KEY_CONTAINED(PlayersDeathPositions, playerID))
        //        && (IS_KEY_CONTAINED(PlayersDeathRotations, playerID))
        //        && (IS_KEY_CONTAINED(PlayersSpawnPositions, playerID)))
        //    {
        //        Vector3 startPostion = PlayersDeathPositions[playerID];
        //        Quaternion startRotation = PlayersDeathRotations[playerID];
        //        Vector3 endPosition = PlayersSpawnPositions[playerID].Position;
        //        Quaternion endRotation = PlayersSpawnPositions[playerID].Rotation;

        //        PlayerRespawnGhost playerRespawnGhost = Instantiate(playerRespawnGhostPrefab, startPostion, startRotation);
        //        playerRespawnGhost.PlayerID = playerID;
        //        playerRespawnGhost.RespawnAnimationDone += On_RespawnAnimationDone;
        //        playerRespawnGhost.StartRespawnAnimation(startPostion, startRotation, endPosition, endRotation);
        //    }
        //}


        //private void On_RespawnAnimationDone(PlayerRespawnGhost playerRespawnGhost)
        //{
        //    playerRespawnGhost.RespawnAnimationDone -= On_RespawnAnimationDone;

        //    LogConsole(playerRespawnGhost.PlayerID + " completed respawn animation");
        //    SpawnPlayer(playerRespawnGhost.PlayerID);
        //    playerRespawnGhost.DestroyGhost();
        //}

        public void DestroyPlayer(EPlayerID playerID)
        {
            if (IS_KEY_CONTAINED(ActivePlayers, playerID))
            {
                AbstractPlayer player = ActivePlayers[playerID];
                if ((IS_KEY_CONTAINED(PlayersDeathPositions, playerID)) &&
                    (IS_KEY_CONTAINED(PlayersDeathRotations, playerID)))
                {
                    PlayersDeathPositions[playerID] = player.Position;
                    PlayersDeathRotations[playerID] = player.Rotation;
                }

                ActivePlayers.Remove(playerID);
                BEventsCollection.PLAYERS_PlayerDied.Invoke(new BEHandle <EPlayerID, IPlayer>(playerID, player));
                player.DestroyPawn();
            }
        }
Exemple #5
0
    public bool CheckVictoryConditions()
    {
        if (ActivePlayers[0].Role == Role.Defeated)
        {
            if (Config.Giveaway)
            {
                Victory();
            }
            else
            {
                Defeat();
            }
            return(true);
        }

        //check if all m.ActivePlayers exept human
        bool          allDefeated = true;
        bool          oneDefeated = false;
        List <Player> defeated    = new List <Player>();

        for (int i = 1; i < ActivePlayers.Count; i++)
        {
            if (ActivePlayers[i].Role != Role.Defeated)
            {
                allDefeated = false;
            }
            else
            {
                defeated.Add(ActivePlayers[i]);
                oneDefeated = true;
            }
        }
        //remove defeated players from active players.
        foreach (var item in defeated)
        {
            ActivePlayers.Remove(item);
        }
        if (oneDefeated)
        {
            turnSequencer.RecalculateTurningOrder(ActivePlayers);
        }

        if (allDefeated)
        {
            Victory();
            return(true);
        }
        //check until one player eliminated condition
        //If it is true, then game is held until one player is defeated. Other m.ActivePlayers are winners.
        if (oneDefeated)
        {
            //giveaway game winner is the one who got rid of cards first.
            if (Config.Giveaway)
            {
                Defeat();
                return(true);
            }

            if (Config.UntilOneEliminated)
            {
                Victory();
                return(true);
            }
        }

        return(false);
    }