Example #1
0
 /// <summary>
 /// 开始游戏
 /// </summary>
 /// 和客户端上的开始游戏不同,初始化玩家列表的时候
 /// 从Room而非客户端用于同步的CurrentRoom获得数据
 public new void StartGame(List <PGeneral> DefaultGenerals = null)
 {
     if (Room.IsFull())
     {
         #region 初始化玩家列表
         PlayerList = new List <PPlayer>();
         for (int i = 0; i < PlayerNumber; ++i)
         {
             PPlayer Player = new PPlayer()
             {
                 Index     = i,
                 Name      = Room.PlayerList[i].PlayerType.Equals(PPlayerType.Player) ? Room.PlayerList[i].Nickname : "P" + (i + 1).ToString(),
                 IsAlive   = true,
                 Money     = PPlayer.Config.DefaultMoney,
                 TeamIndex = GameMode.Seats[i].Party - 1
             };
             if (DefaultGenerals != null && i < DefaultGenerals.Count)
             {
                 Player.General = DefaultGenerals[i];
             }
             Player.Tags = new PTagManager(Player);
             PlayerList.Add(Player);
             PBlock Position = Map.BlockList.Find((PBlock Block) => Block.StartPointIndex == i % Map.StartPointNumber);
             if (Position != null)
             {
                 PlayerList[i].Position = Position;
             }
             else
             {
                 PlayerList[i].Position = Map.BlockList[0];
             }
         }
         #endregion
         NowPlayer            = null;
         NowPeriod            = null;
         StartGameFlag        = true;
         EndGameFlag          = false;
         ReadyToStartGameFlag = false;
         CardManager.InitializeCardHeap();
         PLogger.Log("开始进行规则装载");
         PObject.ListSubTypeInstances <PSystemTriggerInstaller>().ForEach((PSystemTriggerInstaller Installer) => {
             Installer.Install(Monitor);
         });
         PNetworkManager.NetworkServer.Game.PlayerList.ForEach((PPlayer Player) => {
             PNetworkManager.NetworkServer.TellClient(Player, new PStartGameOrder(Map.Name, Player.Index.ToString()));
         });
         if (PSystem.AllAi)
         {
             Room.PlayerList.ForEach((PRoom.PlayerInRoom Player) => {
                 Player.PlayerType = PPlayerType.AI;
             });
         }
         NowPlayer = PlayerList[0];
         Monitor.CallTime(PTime.InstallModeTime);
         if (DefaultGenerals == null)
         {
             Monitor.CallTime(PTime.ChooseGeneralTime);
         }
         Monitor.CallTime(PTime.StartGameTime);
         NowPeriod = PPeriod.StartTurn;
         PNetworkManager.NetworkServer.TellClients(new PStartTurnOrder(NowPlayerIndex.ToString()));
         Logic.StartLogic(PPeriod.StartTurn.Execute());
     }
 }
Example #2
0
 public void MoveCard(PCard Card, PCardArea Source, PCardArea Destination)
 {
     PLogger.Log("[" + Card.Name + "]将要从[" + Source.Name + "]移动到[" + Destination.Name + "]");
     if (Source.CardList.Contains(Card))
     {
         PMoveCardTag MoveCardTag = Game.Monitor.CallTime(PTime.Card.LeaveAreaTime, new PMoveCardTag(Card, Source, Destination));
         MoveCardTag.Source.CardList.Remove(Card);
         if (MoveCardTag.Source.Owner != null)
         {
             if (MoveCardTag.Source.IsHandCardArea())
             {
                 PNetworkManager.NetworkServer.TellClient(MoveCardTag.Source.Owner, new PRefreshHandCardsOrder(MoveCardTag.Source.ToStringArray()));
                 PNetworkManager.NetworkServer.TellClients(new PRefreshHandCardNumberOrder(MoveCardTag.Source.Owner.Index.ToString(), MoveCardTag.Source.CardNumber.ToString()));
             }
             else if (MoveCardTag.Source.IsEquipmentArea())
             {
                 PNetworkManager.NetworkServer.TellClient(MoveCardTag.Source.Owner, new PRefreshEquipmentsOrder(MoveCardTag.Source.ToStringArray()));
                 PNetworkManager.NetworkServer.TellClients(new PRefreshEquipStringOrder(MoveCardTag.Source.Owner));
             }
             else if (MoveCardTag.Source.IsAmbushArea())
             {
                 PNetworkManager.NetworkServer.TellClient(MoveCardTag.Source.Owner, new PRefreshAmbushOrder(MoveCardTag.Source.ToStringArray()));
                 PNetworkManager.NetworkServer.TellClients(new PRefreshAmbushStringOrder(MoveCardTag.Source.Owner));
             }
         }
         if (MoveCardTag.Destination.IsEquipmentArea())
         {
             PCard CurrentCard = MoveCardTag.Destination.Owner.GetEquipment(Card.Type);
             if (CurrentCard != null)
             {
                 MoveCard(CurrentCard, MoveCardTag.Destination, ThrownCardHeap);
             }
         }
         if (!MoveCardTag.Destination.Equals(SettlingArea))
         {
             Card.Model = PObject.ListSubTypeInstances <PCardModel>().Find((PCardModel Model) => Model.Name.Equals(Card.Name));
         }
         Game.Monitor.CallTime(PTime.Card.EnterAreaTime, MoveCardTag);
         MoveCardTag.Destination.CardList.Add(Card);
         if (MoveCardTag.Destination.Owner != null)
         {
             if (MoveCardTag.Destination.IsHandCardArea())
             {
                 MoveCardTag.Destination.Arrange();
                 PNetworkManager.NetworkServer.TellClient(MoveCardTag.Destination.Owner, new PRefreshHandCardsOrder(MoveCardTag.Destination.ToStringArray()));
                 PNetworkManager.NetworkServer.TellClients(new PRefreshHandCardNumberOrder(MoveCardTag.Destination.Owner.Index.ToString(), MoveCardTag.Destination.CardNumber.ToString()));
             }
             else if (MoveCardTag.Destination.IsEquipmentArea())
             {
                 MoveCardTag.Destination.Arrange();
                 PNetworkManager.NetworkServer.TellClient(MoveCardTag.Destination.Owner, new PRefreshEquipmentsOrder(MoveCardTag.Destination.ToStringArray()));
                 PNetworkManager.NetworkServer.TellClients(new PRefreshEquipStringOrder(MoveCardTag.Destination.Owner));
             }
             else if (MoveCardTag.Destination.IsAmbushArea())
             {
                 PNetworkManager.NetworkServer.TellClient(MoveCardTag.Destination.Owner, new PRefreshAmbushOrder(MoveCardTag.Destination.ToStringArray()));
                 PNetworkManager.NetworkServer.TellClients(new PRefreshAmbushStringOrder(MoveCardTag.Destination.Owner));
             }
         }
     }
 }