예제 #1
0
 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);
 }
예제 #2
0
        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();
                    }
                }
            }
        }
예제 #3
0
        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;
        }
예제 #4
0
파일: Vec2.cs 프로젝트: mbos14/2d-Physics
 public static Vec2 RandomUnitVector()
 {
     return(GetUnitVectorDegrees(Utils.Random(0, 359)));
 }
예제 #5
0
        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)));
        }
예제 #6
0
        public static Vec2 RandomUnitVector()
        {
            float randomAngle = Deg2Rad(Utils.Random(0, 361));

            return(new Vec2(Mathf.Cos(randomAngle), Mathf.Sin(randomAngle)));
        }
예제 #7
0
        public static Vec2 GetRandomVector()
        {
            float a = Utils.Random(0, 360);

            return(GetUnitVectorDegrees(a));
        }