Exemple #1
0
        /// <summary>
        /// 收到战斗类消息
        /// </summary>
        /// <param name="command">执行的命令</param>
        private void OnReciveBattleCommand(BattleCommand command)
        {
            if (command == null || command.Index < 0 || command.Index >= 3)
            {
                return;
            }

            BattleObjects sender = command.Sender as BattleObjects;

            if (sender == null || sender.IsDead)
            {
                return;
            }

            for (int i = 0; i < 6; ++i)
            {
                _temp[i] = null;
            }

            int index     = 0;
            int effectNum = command.ValueEffectNum;

            BattleObjects[] group = null;

            switch (command.EffectGroup)
            {
            case EffectGroup.Self:
                group = sender.Group == GroupTag.Monster ? MonsterObjectses : HeroObjectses;
                break;

            case EffectGroup.Enemy:
                group = sender.Group == GroupTag.Monster ? HeroObjectses : MonsterObjectses;
                break;
            }

            if (group == null)
            {
                return;
            }

            //优先处理选定对象
            if (IsLegalBattleTarget(command, group[command.Index]))
            {
                _temp[index++] = group[command.Index];
                effectNum--;
                Console.WriteLine(sender.Name + " 向 " + group[command.Index].Name + " 使用了 " +
                                  command.Name);
            }

            //处理附加对象
            for (int i = 0; i < 3 && effectNum > 0; ++i)
            {
                if (i != command.Index && IsLegalBattleTarget(command, group[i]))
                {
                    _temp[index++] = group[i];
                    effectNum--;
                    Console.WriteLine(sender.Name + " 向 " + group[command.Index].Name + " 使用了 " +
                                      command.Name);
                }
            }

            for (int i = 0; i < index; ++i)
            {
                _temp[i].OnReciveCommand(command);
            }
        }
Exemple #2
0
 public bool IsLegalBattleTarget(BattleCommand command, BattleObjects battleObjects)
 {
     return(command != null && battleObjects != null &&
            ((!battleObjects.IsDead && command.BuffType != BuffType.Revive) ||
             (battleObjects.IsDead && command.BuffType == BuffType.Revive)));
 }