コード例 #1
0
        /// <summary>
        /// 检测是否在使用范围内
        /// </summary>
        /// <param name="user"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public bool IsInRange(AbstractPlayer user, AbstractPlayer target)
        {
            int p2p = user.GetFunction().GetDistance(target);
            int att = user.GetFunction().GetAttackDistance();
            int def = target.GetFunction().GetDefenceDistance();

            return((att - def) >= p2p);
        }
コード例 #2
0
        /// <summary>
        /// 玩家扣血 -- 调用扣血触发事件
        /// </summary>
        /// <param name="num">扣血数量</param>
        /// <param name="murderer">凶手</param>
        public void LoseHP(int num, AbstractPlayer murderer)
        {
            int hp = player.GetState().GetCurHP();

            hp -= num;
            player.GetState().SetCurHP(hp);
            //ViewManagement.getInstance().printMsg(
            //        player.getInfo().getName() + "受到" + num + "点伤害");
            player.RefreshView();
            // TODO 如果血量不足,则开始求桃
hp:
            while (player.GetState().GetCurHP() <= 0)
            {
                // 先求自己
                if (player.GetRequest().RequestYao())
                {
                    player.GetAction().TaoSave(player);
                    if (player.GetState().GetCurHP() > 0)
                    {
                        return;
                    }
                    else
                    {
                        continue;
                    }
                }
                // 再求其他人
                List <AbstractPlayer> list = player.GetFunction().GetAllPlayers();
                for (int i = 0; i < list.Count(); i++)
                {
                    // 因为有卡死bug,暂时不问凶手求桃
                    // 经研究为swing中的多线程问题 2013-4-5已解决
                    // if(list.get(i)==murderer)continue;
                    if (list.ElementAt(i).GetRequest().RequestYao())
                    {
                        player.GetAction().TaoSave(player);
                        if (player.GetState().GetCurHP() > 0)
                        {
                            break;
                        }
                    }
                }
                player.GetAction().Dead(murderer);
                return;
            }

            // 调用触发事件
            this.player.GetTrigger().AfterLoseHP(murderer);
            player.RefreshView();
            if (murderer != null)
            {
                murderer.RefreshView();
            }
        }
コード例 #3
0
        /// <summary>
        /// 根据准备出的牌
        /// 获得可以对其使用的目标列表 </summary>
        /// <param name="player"> </param>
        /// <param name="c">
        /// @return </param>
        public static IList <AbstractPlayer> getEnableTargets(AbstractPlayer player, AbstractCard c)
        {
            IList <AbstractPlayer> list   = player.GetFunction().GetAllPlayers();
            IList <AbstractPlayer> result = new List <AbstractPlayer>();

            for (int i = 0; i < list.Count; i++)
            {
                if (c.TargetCheck4SinglePlayer(player, list[i]))
                {
                    result.Add(list[i]);
                }
            }
            return(result);
        }