Ejemplo n.º 1
0
        private void StartGame()
        {
            sndButtonClick.Play();

            if (OnlineGameClient != null && OnlineGameClient.IsConnected)
            {
                OnlineGameClient.StartGame();
            }
            else
            {
                Dictionary <string, List <Squad> > DicSpawnSquadByPlayer = new Dictionary <string, List <Squad> >();
                for (int P = 0; P < Room.ListRoomPlayer.Count; ++P)
                {
                    DicSpawnSquadByPlayer.Add(Room.ListRoomPlayer[P].Name, Room.ListRoomPlayer[P].Inventory.ActiveLoadout.ListSquad);
                }

                BattleMap NewMap;

                if (Room.MapPath == "Random")
                {
                    NewMap = BattleMap.DicBattmeMapType[Room.MapType].GetNewMap(Room.RoomType);
                }
                else
                {
                    NewMap = BattleMap.DicBattmeMapType[Room.MapType].GetNewMap(Room.RoomType);
                }

                NewMap.BattleMapPath         = Room.MapPath;
                NewMap.DicSpawnSquadByPlayer = DicSpawnSquadByPlayer;
                NewMap.ListGameScreen        = ListGameScreen;

                for (int P = 0; P < 10; P++)
                {
                    if (P < PlayerManager.ListLocalPlayer.Count)
                    {
                        BattleMapPlayer ActivePlayer = PlayerManager.ListLocalPlayer[P];
                        NewMap.AddLocalPlayer(ActivePlayer);
                    }
                    else//Fill with empty players to ensure the enemy player is always player 10+
                    {
                        NewMap.AddLocalPlayer(null);
                    }
                }

                NewMap.Load();
                NewMap.Init();
                NewMap.TogglePreview(true);
                ListGameScreen.Insert(0, NewMap);
            }
        }
        protected override void Execute(IOnlineConnection Sender)
        {
            Dictionary <string, List <Squad> > DicSpawnSquadByPlayer = new Dictionary <string, List <Squad> >();

            for (int P = 0; P < Owner.ListRoomPlayer.Count; ++P)
            {
                DicSpawnSquadByPlayer.Add(Owner.ListRoomPlayer[P].Name, Owner.ListRoomPlayer[P].Inventory.ActiveLoadout.ListSquad);
            }

            BattleMap NewMap;

            if (CreatedGroup.Room.MapPath == "Random")
            {
                NewMap = BattleMap.DicBattmeMapType[Owner.MapType].GetNewMap(Owner.RoomType);
            }
            else
            {
                NewMap = BattleMap.DicBattmeMapType[Owner.MapType].GetNewMap(Owner.RoomType);
            }

            NewMap.ListGameScreen        = new List <GameScreen>();
            NewMap.BattleMapPath         = Owner.MapPath;
            NewMap.DicSpawnSquadByPlayer = DicSpawnSquadByPlayer;
            NewMap.InitOnlineServer(OnlineServer, CreatedGroup);
            CreatedGroup.SetGame(NewMap);

            for (int P = 0; P < CreatedGroup.Room.ListOnlinePlayer.Count; P++)
            {
                IOnlineConnection ActiveOnlinePlayer = CreatedGroup.Room.ListOnlinePlayer[P];
                BattleMapPlayer   ActivePlayer       = Owner.ListRoomPlayer[P];
                ActivePlayer.OnlineClient = ActiveOnlinePlayer;

                NewMap.AddLocalPlayer(ActivePlayer);

                //Add Game Specific scripts
                Dictionary <string, OnlineScript> DicNewScript = OnlineHelper.GetBattleMapScriptsServer(CreatedGroup, ActivePlayer);
                ActiveOnlinePlayer.AddOrReplaceScripts(DicNewScript);
            }

            for (int P = 0; P < CreatedGroup.Room.ListOnlinePlayer.Count; P++)
            {
                IOnlineConnection ActiveOnlinePlayer = CreatedGroup.Room.ListOnlinePlayer[P];
                ActiveOnlinePlayer.Send(new CreateGameScriptServer());
            }
        }