예제 #1
0
        private void Reflect(object obj, uint type)
        {
            Aquarium.Fish fish = type == 0 ? fish = (Aquarium.Carp)obj : fish = (Aquarium.Pike)obj;

            if (bX - 10 <= 0)
            {
                if (fish.DirectionAngle <= 180)
                {
                    fish.DirectionAngle = 180 - fish.DirectionAngle;
                }
                else
                {
                    fish.DirectionAngle = 540 - fish.DirectionAngle;
                }
            }
            else if (bX + 10 >= 984)
            {
                if ((fish.DirectionAngle >= 0) && (fish.DirectionAngle < 90))
                {
                    fish.DirectionAngle = 180 - fish.DirectionAngle;
                }
                else if ((fish.DirectionAngle < 360) && (fish.DirectionAngle > 270))
                {
                    fish.DirectionAngle = 540 - fish.DirectionAngle;
                }
            }
            if ((bY - 10 <= 0) || (bY + 10 >= 561))
            {
                fish.DirectionAngle = 360 - fish.DirectionAngle;
            }
        }
예제 #2
0
        private void Move(object obj, uint type)
        {
            Aquarium.Fish fish = type == 0 ? fish = (Aquarium.Carp)obj : fish = (Aquarium.Pike)obj;

            bX = fish.Location.X;
            bY = fish.Location.Y;

            Reflect(fish, type);

            p.X = bX + fish.Speed * (float)Math.Cos(fish.DirectionAngle * Math.PI / 180);
            p.Y = bY - fish.Speed * (float)Math.Sin(fish.DirectionAngle * Math.PI / 180);

            fish.Location = p;
        }
예제 #3
0
        private void Draw(Graphics g, object obj, uint type)
        {
            Aquarium.Fish fish = type == 0 ? fish = (Aquarium.Carp)obj : fish = (Aquarium.Pike)obj;

            g.FillEllipse(fish.FishColor, fish.Location.X - 10, fish.Location.Y - 10, 20, 20);

            if ((fish.DirectionAngle >= 90) && (fish.DirectionAngle <= 270))
            {
                g.FillRectangle(fish.FishColor, fish.Location.X, fish.Location.Y - 5, 20, 10);
            }
            else
            {
                g.FillRectangle(fish.FishColor, fish.Location.X - 20, fish.Location.Y - 5, 20, 10);
            }
        }