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); }
protected void AddUnitToMap() { AbstractUnit newUnit = CreateChild(); GlobalMap.Field[newUnit.X, newUnit.Y].Entity.Add(newUnit); GlobalMap.CreatedUnits.Add(newUnit); newUnit.CurrentBirthCooldown = 10; }
protected bool CanBeTogether(AbstractUnit newOne) { if ((newOne.FoundPartner == null && newOne.Gender != Gender && newOne.GetType() == this.GetType())) { return(WillBeAlive(newOne.X, newOne.Y)); } return(false); }
protected bool CheckPotentialPartner(AbstractUnit potentialPartner) { if (CanBeTogether(potentialPartner)) { SetPotentialPartner(potentialPartner); return(true); } return(false); }
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; }
protected void SetTarget(AbstractUnit newTarget) { if (newTarget == null) { Target = null; } if (Target == null) { Target = newTarget; } if (WhereShouldGo(newTarget)) { Target = newTarget; } }