Exemplo n.º 1
0
        public void CreateFishes()
        {
            float fishPos = 200 + (float)this.random.NextDouble() * 150;

            while (!IsDisposed && fishPos < 9400 && (SceneManager.Form == null || !SceneManager.Form.IsDisposed))
            {
                if (random.NextDouble() <= 0.33)
                {
                    Fish3.Instantiate(SceneManager.Player, new Vector2(0, fishPos));
                }
                else
                {
                    Fish.Instantiate(SceneManager.Player, new Vector2(0, fishPos));                             // Fishes 1 and 2
                }
                fishPos += (float)this.random.NextDouble() * 175;
                Thread.Sleep((int)Math.Round(random.NextDouble() * 450));
            }
        }
Exemplo n.º 2
0
        public void InitScene()
        {
            IsDisposed = false;
            GameEnded  = false;
            gameHUD    = new GameHUD(gl);
            gameHUD.Init();
            SceneManager.HUD = gameHUD;

            // Create scene's background
            CreateBackground();

            // Create player
            PlayerObject player = new PlayerObject(new Vector2(34, 71), "Player", new Vector2(SceneManager.ScreenSize.X / 2f, 5));

            player.Animator.AddTexture("HOOK", new Bitmap("./Textures/HOOK.png"));
            player.Animator.CurrentTexture = "HOOK";
            SceneManager.AddObject(player);
            SceneManager.Player = player;

            // Create fishes
            Fish.RegisterTextures();
            Fish3.RegisterTextures();
            new Thread(new ThreadStart(CreateFishes)).Start();

            // Create bombs
            Bombs.RegisterTextures();
            new Thread(new ThreadStart(CreateBombs)).Start();

            // Create bubbles
            float bubblePos = 500;

            while (bubblePos < 17000)
            {
                CreateBubbles(new Vector2((float)this.random.NextDouble() * SceneManager.ScreenSize.X, bubblePos, SceneManager.ScreenSize.X, 0));
                bubblePos += 50 + (float)this.random.NextDouble() * 475;
            }

            // Create player's aim
            GameObject aim = new GameObject(new Vector2(40, 40), "Aim");

            aim.Animator.AddTexture("AIM", AIM_TEXTURE_ID);
            aim.Animator.CurrentTexture = "AIM";
            aim.Transform.SetPositionFn(() => {
                aim.Transform.Position = SceneManager.MousePositionInScene() - aim.Transform.Size / 2f;
            });
            SceneManager.Aim = aim;

            // Play games' song
            long position;

            try {
                position = OutputDevice.GetPosition();
            } catch {
                position = 0;
            }

            if (position == 0)
            {
                keepPlaying = true;
                OutputDevice.PlaybackStopped += SongStopped;
                OutputDevice.Init(audioFile);
                OutputDevice.Play();
            }
        }