Beispiel #1
0
        protected override void CreateScene()
        {
            FixedCamera2D camera2d = new FixedCamera2D("camera");
            camera2d.BackgroundColor = Color.CornflowerBlue;
            EntityManager.Add(camera2d);

            // Background
            Entity background = new Entity()
                                    .AddComponent(new Transform2D()
                                    {
                                        X = WaveServices.ViewportManager.LeftEdge,
                                        Y = WaveServices.ViewportManager.TopEdge,
                                        DrawOrder = 1f,
                                        XScale = (WaveServices.ViewportManager.ScreenWidth / 1024) / WaveServices.ViewportManager.RatioX,
                                        YScale = (WaveServices.ViewportManager.ScreenHeight / 768) / WaveServices.ViewportManager.RatioY,
                                    })
                                    .AddComponent(new Sprite(Directories.Textures + "background.wpk"))
                                    .AddComponent(new SpriteRenderer(DefaultLayers.Opaque));
            EntityManager.Add(background);

            // Player
            this.player = new Player("player", new Vector2(WaveServices.ViewportManager.VirtualWidth / 2,
                                                   WaveServices.ViewportManager.VirtualHeight / 2));
            EntityManager.Add(this.player);

            // Bullets pool
            this.bulletEmiter = new BulletEmiter("bulletEmiter");
            EntityManager.Add(this.bulletEmiter);

            // Enemy pool
            this.enemyEmiter = new EnemyEmiter("EnemyEmiter");
            EntityManager.Add(this.enemyEmiter);

            // Left Joystick
            RectangleF leftArea = new RectangleF(0,
                                                  0,
                                                  WaveServices.ViewportManager.VirtualWidth / 2f,
                                                  WaveServices.ViewportManager.VirtualHeight);
            this.leftJoystick = new Joystick("leftJoystick", leftArea);
            EntityManager.Add(this.leftJoystick);

            // Right Joystick
            RectangleF rightArea = new RectangleF(WaveServices.ViewportManager.VirtualWidth / 2,
                                                  0,
                                                  WaveServices.ViewportManager.VirtualWidth / 2f,
                                                  WaveServices.ViewportManager.VirtualHeight);
            this.rightJoystick = new Joystick("rightJoystick", rightArea);
            EntityManager.Add(this.rightJoystick);

            // Create Menu
            this.CreateMenuUI();

            // Create GameOver
            this.CreateGameOver();

            // CreateHUBUI
            this.hubPanel = new HubPanel();
            EntityManager.Add(this.hubPanel);

            // Scene behavior
            this.AddSceneBehavior(new DebugSceneBehavior(), SceneBehavior.Order.PostUpdate);
            this.AddSceneBehavior(new GamePlaySceneBehavior(), SceneBehavior.Order.PostUpdate);

            // Music
            this.musicInfo = new MusicInfo(Directories.Sounds + "ninjaMusic.mp3");
            WaveServices.MusicPlayer.Play(this.musicInfo);
            WaveServices.MusicPlayer.Volume = 0.8f;
            WaveServices.MusicPlayer.IsRepeat = true;

            this.CurrentState = States.Menu;
        }
Beispiel #2
0
        /// <summary>
        /// Resolves the dependencies needed for this instance to work.
        /// </summary>
        protected override void ResolveDependencies()
        {
            base.ResolveDependencies();

            this.hubPanel = EntityManager.Find<HubPanel>("HubPanel");
        }
Beispiel #3
0
 /// <summary>
 /// Handles the EntityInitialized event of the entity control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
 private void entity_EntityInitialized(object sender, EventArgs e)
 {
     this.gamePlayScene = this.entity.Scene as GamePlayScene;
     this.hubPanel = this.entity.Scene.EntityManager.Find<HubPanel>("HubPanel");
     this.Life = 100;            
 }
Beispiel #4
0
 /// <summary>
 /// Handles the EntityInitialized event of the entity control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
 private void entity_EntityInitialized(object sender, EventArgs e)
 {
     this.gamePlayScene = this.entity.Scene as GamePlayScene;
     this.hubPanel      = this.entity.Scene.EntityManager.Find <HubPanel>("HubPanel");
     this.Life          = 100;
 }