public override void Touch(Movier other) { if (other != null && other is Food) { DoDamage(other); } }
public override void Touch(Movier other) { if (other != null && other is Ant && other.hp >= 5) { DoDamage(other); } }
public override (double dx, double dy) GetNextMove(IEnumerable <Movier> others) { var target = new Movier() { x = this.x + targetx, y = this.y + targety }; return(Shift(target, speed)); }
public double Dist(Movier other) { if (other == null) { return(double.MaxValue); } var cx = other.x - this.x; var cy = other.y - this.y; return(Math.Sqrt(cx * cx + cy * cy)); }
public void DoDamage(Movier other) { if (other == null) { return; } var dmg = Math.Min(other.hp, this.damage); this.hp += dmg; other.hp -= dmg; }
void AquariumObjectWhantToSpawn(Movier obj) { if (obj == null) { return; } var child = obj.CreateChild(); if (child == null) { return; } objects.AddRange(child); }
public override (double dx, double dy) GetNextMove(IEnumerable <Movier> others) { var target = Nearest(others, obj => obj is Food && Dist(obj) < EYE_RANGE && Dist(obj) > 0); if (target == null) { target = new Movier() { x = this.x + targetx, y = this.y + targety } } ; return(Shift(target, -speed)); }
protected (double dx, double dy) Shift(Movier other, double shift) { if (other == null) { return(0, 0); } var dist = Dist(other); if (dist < 0.00001) { return(0, 0); } var cx = other.x - this.x; var cy = other.y - this.y; shift = Math.Min(shift, dist); return(shift * cx / dist, shift *cy / dist); }
public virtual void Touch(Movier other) { }