Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EnemyEmiterBehavior" /> class.
        /// </summary>
        /// <param name="emiter">The emiter.</param>
        public EnemyEmiterBehavior(EnemyEmiter emiter)
        {
            this.emiter     = emiter;
            this.cadence    = TimeSpan.FromSeconds(2);
            this.minCadence = TimeSpan.FromSeconds(0.5f);
            this.time       = this.cadence;

            this.center   = new Vector2(WaveServices.ViewportManager.VirtualWidth / 2, WaveServices.ViewportManager.VirtualHeight / 2);
            this.upVector = this.center + Vector2.UnitY * 500;
        }
Exemplo n.º 2
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;
        }