Esempio n. 1
0
        public static void PlayerJoined(int _playerId, string _playerName)
        {
            Vector2         _newPlayerPosition;
            ETeam           _teamId;
            CharacterObject obj;

            //Add player to a team
            if (TeamManager.centauriTeam.GetNrOfPlayers() <= TeamManager.marineTeam.GetNrOfPlayers())
            {
                _newPlayerPosition = Map.mapPosition + new Vector2(map.getAlienSpawnPoint().X, map.getAlienSpawnPoint().Y);
                TeamManager.centauriTeam.AddPlayer(_playerId);
                _teamId = TeamManager.centauriTeam.GetTeamId();
                obj     = new RoachObject(_playerId, _newPlayerPosition);
            }
            else
            {
                _newPlayerPosition = Map.mapPosition + new Vector2(map.getMarineSpawnPoint().X, map.getMarineSpawnPoint().Y);
                TeamManager.marineTeam.AddPlayer(_playerId);
                _teamId = TeamManager.marineTeam.GetTeamId();
                obj     = new MarineObject(_playerId, _newPlayerPosition);
            }

            Player newPlayer = new Player(_playerId, _playerName, _teamId);

            newPlayer.gameObj = obj;
            players.Add(_playerId, newPlayer);

            characters.Add(obj.id, obj);

            //Send init data to joined player (map, all players etc)
            ServerSend.Initialize(_playerId, map.GetMapId(), new List <Player>(players.Values));

            //Send player joined event to all players
            PushEvent(new PlayerJoinedEvent(_playerId, _playerName, _teamId));
        }
Esempio n. 2
0
        public static void init()
        {
            map            = new TestMap();
            players        = new Dictionary <int, Player>();
            buildings      = new Dictionary <int, BuildingObject>();
            characters     = new Dictionary <int, CharacterObject>();
            events         = new Queue <Event>();
            playerCommands = new Queue <PlayerCommandData>();
            gameStates     = new Dictionary <int, GameState>();
            turnNumber     = 0;

            BuildingObject commandCenter = new CommandCenterObject(Map.mapPosition + map.getMarineSpawnPoint());
            BuildingObject hive          = new HiveObject(Map.mapPosition + map.getAlienSpawnPoint());

            buildings.Add(commandCenter.id, commandCenter);
            buildings.Add(hive.id, hive);
        }