/// <summary>
        /// 获取上家
        /// </summary>
        /// <returns></returns>
        public AbstractPlayer GetLastPlayer()
        {
            AbstractPlayer p = player;

            while (p.GetNextPlayer() != player)
            {
                p = p.GetNextPlayer();
            }
            return(p);
        }
        /// <summary>
        /// 计算两个玩家之间的距离
        /// 两者各按逆时针计算,取最小值
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        public int GetDistance(AbstractPlayer p)
        {
            AbstractPlayer pNext = player.GetNextPlayer();
            int            i     = 1;
            int            j     = 1;

            while (pNext != p)
            {
                i++;
                pNext = pNext.GetNextPlayer();
            }
            pNext = p.GetNextPlayer();
            while (pNext != player)
            {
                j++;
                pNext = pNext.GetNextPlayer();
            }
            return(i <= j ? i : j);
        }
 //下家开始
 private void Pass()
 {
     //if(Frame_Main.isGameOver){
     //    return;
     //}
     Console.WriteLine(player.GetInfo().GetName() + "pass");
     Thread.Sleep(800);
     //ViewManagement.getInstance().refreshAll();
     player.GetNextPlayer().Process();
 }
        /// <summary>
        /// 获取场上全部玩家
        /// </summary>
        /// <returns></returns>
        public List <AbstractPlayer> GetAllPlayers()
        {
            List <AbstractPlayer> list = new List <AbstractPlayer>();
            AbstractPlayer        p    = player.GetNextPlayer();

            while (p != player)
            {
                list.Add(p);
                p = p.GetNextPlayer();
            }
            return(list);
        }
Esempio n. 5
0
 /// <summary>
 /// 人物死亡
 /// </summary>
 /// <param name="murderer"></param>
 public void Dead(AbstractPlayer murderer)
 {
     //// 全局列表中删除
     //ModuleManagement.getInstance().getPlayerList().remove(player);
     // 设置死亡状态
     player.GetState().SetDead(true);
     player.GetState().SetCurHP(0);
     // 删除手牌
     foreach (AbstractCard c in player.GetState().GetCardList())
     {
         c.Gc();
     }
     player.GetState().GetCardList().Clear();
     // 上下家重置
     player.GetFunction().GetLastPlayer().SetNextPlayer(
         player.GetNextPlayer());
     //检测该人物死亡是否终止游戏
     if (player.GetState().GetId() == EIdentity.ZHUGONG)
     {
         if (GetFanZei() > 0)
         {
             //Frame_Main.me.gameOver(GameOver.FANZEI_WIN);
         }
         else
         {
             //Frame_Main.me.gameOver(GameOver.NEIJIAN_WIN);
         }
         return;
     }
     if (player.GetState().GetId() == EIdentity.FANZEI || player.GetState().GetId() == EIdentity.NEIJIAN)
     {
         int alive = GetFanZeiOrNeiJian();
         Console.WriteLine("反贼或内奸还剩:" + alive + "个");
         if (alive == 0)
         {
             //Frame_Main.me.gameOver(GameOver.ZHUGONG_WIN);
             return;
         }
     }
     // 死亡触发事件
     player.GetTrigger().AfterDead();
     //死亡后的奖惩
     if (murderer != null)
     {
         // 如果死亡者是反贼 凶手获得3张牌
         if (player.GetState().GetId() == EIdentity.FANZEI)
         {
             for (int i = 0; i < 3; i++)
             {
                 murderer.GetAction().AddOneCardFromList();
             }
         }
         //主公误杀忠臣则掉光所有牌
         if (player.GetState().GetId() == EIdentity.ZHONGCHEN &&
             murderer.GetState().GetId() == EIdentity.ZHUGONG)
         {
             murderer.GetState().GetCardList().Clear();
             murderer.GetState().GetEquipment().RemoveALL();
             //AISpeakService.sayFuckBoss(player);
         }
         player.RefreshView();
         murderer.RefreshView();
     }
     //如果在回合中死亡,直接跳出回合,下家开始
     if (player.GetStageNum() != EStageState.STAGE_END)
     {
         Console.WriteLine("dead" + Thread.CurrentThread.Name);
         player.GetNextPlayer().Process();
     }
 }