Ejemplo n.º 1
0
 public void SetTeam(Team team)
 {
     this.Team = team;
     //this.HeroControl.SetHeroName(this.Team.Hero.Name);
     //this.UnitsControl.SetPosition(this.Team.Hero.Leadership);
     //this.UnitsControl.SetUnits(this.Team.Units);
     //this.TeamHPLabel.Text = "部队HP: " + this.Team.TeamHeal;
 }
Ejemplo n.º 2
0
 public TeamControl(Team team)
 {
     InitializeComponent();
     SetTeam(team);
 }
Ejemplo n.º 3
0
 public Unit(int id)
 {
     //test
     this.UnitID = id;
     _unitName = "民兵";
     this.HealPoint = 3;
     this.MaxHP = this.HealPoint;
     this.CurrentHP = this.MaxHP;
     this.AttackPower = 1;
     this.CurrentAttack = AttackPower;
     this.ActiveSkill = null;
     this.PassiveSkill = null;
     ResetActionState();
     this.Team = null;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 随机选择敌人队伍中存活单位
        /// </summary>
        /// <param name="enemy">敌人队伍</param>
        /// <returns>随机选中的未死亡的单位</returns>
        private Unit RandomTargetAliveEnemy(Team enemy)
        {
            Unit targetUnit = null;
            double maxValue = 0;
            double randValue = 0;

            //根据敌人类型(怪物/玩家)进行遍历
            if (enemy.GetType() == Type.GetType("BountyHanger.Library.MonsterTeam"))
            {
                MonsterTeam monster = (MonsterTeam)enemy;
                #region 遍历怪物未死亡单位
                //遍历未死亡的Boss
                for (int i = 0; i < monster.Bosses.Length; i++)
                {
                    if (monster.Bosses[i].ActionState != UnitActionState.Dead)
                    {
                        randValue = RandomBuilder.GetDouble();
                        if (randValue > maxValue)
                        {
                            maxValue = randValue;
                            targetUnit = monster.Bosses[i];
                        }
                    }
                }
                //遍历未死亡的精英
                for (int i = 0; i < monster.Elites.Length; i++)
                {
                    if (monster.Elites[i].ActionState != UnitActionState.Dead)
                    {
                        randValue = RandomBuilder.GetDouble();
                        if (randValue > maxValue)
                        {
                            maxValue = randValue;
                            targetUnit = monster.Elites[i];
                        }
                    }
                }
                //遍历未死亡的喽啰
                for (int i = 0; i < monster.Minions.Length; i++)
                {
                    if (monster.Minions[i].ActionState != UnitActionState.Dead)
                    {
                        randValue = RandomBuilder.GetDouble();
                        if (randValue > maxValue)
                        {
                            maxValue = randValue;
                            targetUnit = monster.Minions[i];
                        }
                    }
                }
                #endregion
            }
            else
            {
                PlayerTeam player = (PlayerTeam)enemy;
                #region 遍历玩家未死亡单位
                targetUnit = player.Hero;
                maxValue = RandomBuilder.GetDouble();
                //遍历未死亡的部队
                for (int i = 0; i < player.Corps.Length; i++)
                {
                    if (player.Corps[i].ActionState != UnitActionState.Dead)
                    {
                        randValue = RandomBuilder.GetDouble();
                        if (randValue > maxValue)
                        {
                            maxValue = randValue;
                            targetUnit = player.Corps[i];
                        }
                    }
                }
                #endregion
            }

            return targetUnit;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 随机攻击
 /// </summary>
 /// <param name="enemy">敌人队伍</param>
 /// <returns>攻击日志</returns>
 private string RandomAttack(Team enemy)
 {
     StringBuilder actionLog = new StringBuilder();
     //随机选择目标单位
     Unit target = RandomTargetAliveEnemy(enemy);
     actionLog.AppendLine(this.Name + "对" + target.Name + "发动攻击。");
     //目标受到伤害
     string result = target.BeDamage(this.CurrentAttack);
     actionLog.AppendLine(result);
     return actionLog.ToString();
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 加入队伍
 /// </summary>
 /// <param name="team">要加入的队伍</param>
 public void JoinTeam(Team team)
 {
     this.Team = team;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 玩家单位行动
 /// </summary>
 /// <param name="turn">当前回合数</param>
 /// <param name="enemy">敌人(怪物队伍)</param>
 /// <returns>行动日志</returns>
 public virtual string Action(int turn, Team enemy)
 {
     //如已死亡则返回空字符串,否则修改为已行动
     if (this.ActionState == UnitActionState.Dead)
     {
         return "";
     }
     else
     {
         this.ActionState = UnitActionState.Done;
     }
     //判断是否符合主动技能发动条件
     //todo:技能释放判断
     if (false)
     {
         //释放主动技能
         //return "单位释放技能";
     }
     else
     {
         //随机攻击敌人
         return RandomAttack(enemy);
     }
     //return "单位行动";
 }