Exemplo n.º 1
0
 /// <summary>Добавляем строение герою</summary>
 /// <param name="building">Строение.</param>
 public void AddBuilding(Building building)
 {
     if (building == null)
     return;
       _Buildings.Add(building);
       CurrentMagic += building.MaxResource;
       building.Owner = this;
 }
Exemplo n.º 2
0
        /// <summary>Обновляем состояние магии</summary>
        private void GetMagic(MouseState state)
        {
            //Магия равна нулю выходим
              if (_SelectedMagic == null)
            return;
              //Магия запущена убираем все выделения
              if (_SelectedMagic.Finished)
              {
            if (_SelectedMagic.Targets.Contains(TargetType.town))
              foreach (Building build in _Buildings)
              {
             build.DrawEnemySelector = false;
             build.DrawOurSelector = false;
              }

            if (_SelectedMagic.Targets.Contains(TargetType.hero))
              foreach (Player player in _Players)
              {
            player.DrawOurSelector = false;
            player.DrawEnemySelector = false;
              }
            _Players[0].CurrentMagic -= _SelectedMagic.Cost;

            if (_TargetBuilding != null)
            {
              if (_TargetBuilding.CurrentResource > _SelectedMagic.Effect)
            _TargetBuilding.CurrentResource -= _SelectedMagic.Effect;
              else
              {
            _TargetBuilding.CurrentResource = _TargetBuilding.MaxResource;
            _Players[0].AddBuilding(_TargetBuilding);
              }
            }

            else if (_TargetPlayer != null)
            {
              _TargetPlayer.CurrentMagic -= _SelectedMagic.Effect;
            }
            _TargetBuilding = null;
            _TargetPlayer = null;
            _SelectedMagic = null;
            return;
              }

              if (_SelectedMagic.Executed|_Wait)
            return;

              //Агрессивная магия
              if (_SelectedMagic.Type == MagicType.agressive)
              {
            //Удар по городу
            if (_SelectedMagic.Targets.Contains(TargetType.town))
            {
              foreach (Building castle in _Buildings)
            if (castle.Contains(state.X, state.Y) && castle.Owner != _Players[0])
            {
               castle.DrawEnemySelector = true;
               _TargetBuilding = castle;
              _TargetPlayer = null;
            }
              else
            castle.DrawEnemySelector = false;
            }

            //Удар по герою
            if (_SelectedMagic.Targets.Contains(TargetType.hero))
            {
              foreach (Player player in _Players)
            if (player.Contains(state.X, state.Y) && player != _Players[0] && !player.Dead)
            {
              player.DrawEnemySelector = true;
              _TargetPlayer = player;
              _TargetBuilding = null;
            }
            else
              player.DrawEnemySelector = false;
            }

              }
              //Мирная магия
              else
              {
            if (_SelectedMagic.Targets.Contains(TargetType.town))
            {
              foreach (Building castle in _Buildings)
            if (castle.Contains(state.X, state.Y) && castle.Owner == _Players[0])
            {
               castle.DrawOurSelector = true;
              _TargetBuilding = castle;
            }
               else
               castle.DrawOurSelector = false;
            }

            if (_SelectedMagic.Targets.Contains(TargetType.hero))
            {
              if (_Players[0].Contains(state.X, state.Y))
              {
            _Players[0].DrawOurSelector = true;
            _TargetPlayer = _Players[0];
              }
              else
            _Players[0].DrawOurSelector = false;
            }
              }
        }