public void moveTowardOtherSlime(GreenSlime other, bool moveAway, GameTime time) { int xToGo = Math.Abs(other.getStandingX() - getStandingX()); int yToGo = Math.Abs(other.getStandingY() - getStandingY()); if (xToGo > 4 || yToGo > 4) { int dx = (other.getStandingX() > getStandingX()) ? 1 : (-1); int dy = (other.getStandingY() > getStandingY()) ? 1 : (-1); if (moveAway) { dx = -dx; dy = -dy; } double chanceForX = (double)xToGo / (double)(xToGo + yToGo); if (Game1.random.NextDouble() < chanceForX) { tryToMoveInDirection((dx > 0) ? 1 : 3, isFarmer: false, base.DamageToFarmer, glider: false); } else { tryToMoveInDirection((dy > 0) ? 2 : 0, isFarmer: false, base.DamageToFarmer, glider: false); } } Sprite.AnimateDown(time); if (invincibleCountdown > 0) { invincibleCountdown -= time.ElapsedGameTime.Milliseconds; if (invincibleCountdown <= 0) { stopGlowing(); } } }
public void moveTowardOtherSlime(GreenSlime other, bool moveAway, GameTime time) { int num = Math.Abs(other.getStandingX() - base.getStandingX()); int num2 = Math.Abs(other.getStandingY() - base.getStandingY()); if (num > 4 || num2 > 4) { int num3 = (other.getStandingX() > base.getStandingX()) ? 1 : -1; int num4 = (other.getStandingY() > base.getStandingY()) ? 1 : -1; if (moveAway) { num3 = -num3; num4 = -num4; } double num5 = (double)num / (double)(num + num2); if (Game1.random.NextDouble() < num5) { base.tryToMoveInDirection((num3 > 0) ? 1 : 3, false, this.damageToFarmer, false); } else { base.tryToMoveInDirection((num4 > 0) ? 2 : 0, false, this.damageToFarmer, false); } } this.sprite.AnimateDown(time, 0, ""); if (this.invincibleCountdown > 0) { this.invincibleCountdown -= time.ElapsedGameTime.Milliseconds; if (this.invincibleCountdown <= 0) { base.stopGlowing(); } } }