public Fish(List <Food> _foodList, int frames, string type, string fishName, string description) : base(fishName + ".png", frames, 1, frames) { foodList = _foodList; this.type = type; this.fishName = fishName; this.description = description; _frames = frames; SetOrigin(width / 2, height / 2); _position = new Vec2(Utils.Random(50, game.width - 200), Utils.Random(50, game.height - 200)); _radius = width / 2; hungerIcon = new Sprite("square.png"); timer = 100; buyToUnlock = new Sprite("square.png"); this.x = Utils.Random(50, game.width - 50); this.y = Utils.Random(_position.y - 100, _position.y + 100); }
void calcDistToPoint() { if (currentPoint.x != 0 && currentPoint.y != 0) { velocity.SetXY(0, 0); if (isFishHungry <= 3000) { if (isFoodPresent()) { calcNearestFood(); } } Vec2 deltaVector = currentPoint - _position; if (deltaVector.Magnitude() <= 0.5f) { currentPoint.SetXY(0, 0); if (isFoodPresent()) { if (currentFood != null && isFishHungry <= 3000) { RemoveFood(currentFood); currentFood.LateDestroy(); isFishHungry += 4000; } } } else { deltaVector.Normalize(); //deltaVector *= 0.2f; velocity += deltaVector; } } else { currentPoint.SetXY(Utils.Random(50, game.width - 50), Utils.Random(_position.y - 100, _position.y + 100)); if (isFoodPresent()) { if (isFishHungry <= 3000) { calcNearestFood(); } } } }
public Dirt(ref int meter) : base("dirt.png") { x = Utils.Random(50, game.width - 50); y = Utils.Random(50, game.height - 50); _position.SetXY(x, y); int type = Utils.Random(1, 100); if (type <= 50) { width /= 5; height /= 5; cleanImpact = 5; } else { width /= 10; height /= 10; cleanImpact = 3; } meter += cleanImpact; _radius = width / 2; }
public static Vec2 RandomUnitVector() { return(GetUnitVectorDegrees(Utils.Random(0, 359))); }
public static Vec2 RandomUnitVector() { float rand_angle = Utils.Random(0.0f, 2f * (float)Math.PI); return(new Vec2(Mathf.Cos(rand_angle), Mathf.Sin(rand_angle))); }
public static Vec2 RandomUnitVector() { float randomAngle = Deg2Rad(Utils.Random(0, 361)); return(new Vec2(Mathf.Cos(randomAngle), Mathf.Sin(randomAngle))); }
public static Vec2 GetRandomVector() { float a = Utils.Random(0, 360); return(GetUnitVectorDegrees(a)); }