コード例 #1
0
ファイル: EnemyBehavior.cs プロジェクト: dezol/QuickStarters
        /// <summary>
        /// Resolves the dependencies needed for this instance to work.
        /// </summary>
        protected override void ResolveDependencies()
        {
            base.ResolveDependencies();

            this.player = EntityManager.Find<Player>("player");
            this.playerTransform = this.player.Entity.FindComponent<Transform2D>();
        }
コード例 #2
0
ファイル: GamePlayScene.cs プロジェクト: dezol/QuickStarters
        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;
        }