public override void Touch(Movier other) { if (other != null && other is Food && !other.ground) { DoDamage(other); } }
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); }
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 override (double dx, double dy) GetNextMove(IEnumerable <Movier> others) { //var enemy = Nearest(others, obj => obj is BadFish && Dist(obj) < EYE_RANGE); //if (enemy == null) // return Shift(enemy, -speed); var target = Nearest(others, obj => obj is Food && !obj.ground && Dist(obj) < EYE_RANGE); if (target == null) { target = new Movier() { x = this.x + targetx, y = this.y + targety } } ; return(Shift(target, speed)); }
public virtual void Touch(Movier other) { }