Exemplo n.º 1
0
    public virtual void orderAttack(BuildingAndUnit e)
    {
        _target = e;

        if (typeof(SpriteEntity).IsAssignableFrom(e.GetType()))
        {
            if (e.Size >= 2)
            {
                Point a = new Point((int)e.Position.X / data.tSize(), (int)e.Position.Y / data.tSize());
                if (e.Position.X < _position.X)
                {
                    a.X += 2;
                }
                else if (e.Position.Y < _position.Y)
                {
                    a.Y += 2;
                }

                orderMove(a);
            }
            else
            {
                orderMove(new Point((int)e.Position.X / data.tSize(), (int)e.Position.Y / data.tSize()));
            }
        }
    }
Exemplo n.º 2
0
 public void Defend(BuildingAndUnit e)
 {
     if (Agrorange(_position, e.Position) < data.tSize() * 5)
     {
         if (_target == null || _target.HitPoints <= 0)
         {
             orderAttack(e);
         }
         else if (typeof(Unit).IsAssignableFrom(e.GetType()) && typeof(StaticBuilding).IsAssignableFrom(_target.GetType()))
         {
             orderAttack(e);
         }
         else if (Agrorange(_position, _target.Position) > Agrorange(_position, e.Position))
         {
             orderAttack(e);
         }
     }
 }