示例#1
0
        protected bool WhereShouldGo(AbstractUnit newTarget)
        {
            int wayToNewTarget = Math.Abs(X - newTarget.X) + Math.Abs(Y - newTarget.Y);
            int wayToTarget    = Math.Abs(X - Target.X) + Math.Abs(Y - Target.Y);

            return(wayToNewTarget < wayToTarget);
        }
示例#2
0
        protected void AddUnitToMap()
        {
            AbstractUnit newUnit = CreateChild();

            GlobalMap.Field[newUnit.X, newUnit.Y].Entity.Add(newUnit);
            GlobalMap.CreatedUnits.Add(newUnit);
            newUnit.CurrentBirthCooldown = 10;
        }
示例#3
0
 protected bool CanBeTogether(AbstractUnit newOne)
 {
     if ((newOne.FoundPartner == null && newOne.Gender != Gender &&
          newOne.GetType() == this.GetType()))
     {
         return(WillBeAlive(newOne.X, newOne.Y));
     }
     return(false);
 }
示例#4
0
        protected bool CheckPotentialPartner(AbstractUnit potentialPartner)
        {
            if (CanBeTogether(potentialPartner))
            {
                SetPotentialPartner(potentialPartner);
                return(true);
            }

            return(false);
        }
示例#5
0
        private void SetPotentialPartner(AbstractUnit potentialPartner)
        {
            int x = potentialPartner.X;
            int y = potentialPartner.Y;

            DateX        = (X + x) / 2;
            DateY        = (Y + y) / 2;
            FoundPartner = potentialPartner;

            potentialPartner.DateX        = DateX;
            potentialPartner.DateY        = DateY;
            potentialPartner.FoundPartner = this;
        }
示例#6
0
 protected void SetTarget(AbstractUnit newTarget)
 {
     if (newTarget == null)
     {
         Target = null;
     }
     if (Target == null)
     {
         Target = newTarget;
     }
     if (WhereShouldGo(newTarget))
     {
         Target = newTarget;
     }
 }