Пример #1
0
        /// <summary>
        /// Creates the sprite.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public IController CreateSpriteController(string type)
        {
            IController controller = null;

            if (type == "Padel1")
            {
                ISpriteEntity spriteEntity = CreateSprite(type);
                spriteEntity.Position = SpriteHelper.GetAbsolutePosition(spriteEntity.Position, GameManager.GraphicsDeviceManager);
                IPadel model = new Padel(spriteEntity);
                IPadelController padelController = new PadelController(model, GameManager);
                PlayerInputController playerController = new PlayerInputController(padelController, GameManager, PlayerIndex.One);
                playerController.MoveUpKey = Keys.Q;
                playerController.MoveDownKey = Keys.A;
                return playerController;
            }

            if (type == "Padel2")
            {
                ISpriteEntity spriteEntity = CreateSprite(type);
                spriteEntity.Position = SpriteHelper.GetAbsolutePosition(spriteEntity.Position, GameManager.GraphicsDeviceManager);
                IPadel model = new Padel(spriteEntity);
                IPadelController padelController = new PadelController(model, GameManager);
                PlayerInputController playerController = new PlayerInputController(padelController, GameManager, PlayerIndex.Two);
                playerController.MoveUpKey = Keys.PageUp;
                playerController.MoveDownKey = Keys.PageDown;
                return playerController;
            }


            if (type == "AIPadel")
            {
                ISpriteEntity spriteEntity = CreateSprite("Padel2"); ;
                spriteEntity.Position = SpriteHelper.GetAbsolutePosition(spriteEntity.Position, GameManager.GraphicsDeviceManager);
                IPadel model = new Padel(spriteEntity);
                IPadelController padelController = new PadelController(model, GameManager);
                
                AIInputController aiInputController = new AIInputController(padelController, GameManager, PlayerIndex.Two);
                
                return aiInputController;
            }

            if (type == "Ball")
            {
                ISpriteEntity spriteEntity = new SpriteEntity();
                _spriteLoader.LoadSprite("Ball", ref spriteEntity);
                //spriteEntity.Texture = GameManager.ContentManager.Load<Texture2D>(ballConfiguration.AssetName);
                //spriteEntity.Scale = ballConfiguration.Scale;
                //spriteEntity.Color = Color.Cyan;
                //spriteEntity.Position = new Vector2((Game.GraphicsDevice.Viewport.Width / 2) - (spriteEntity.Size.Width / 2), (Game.GraphicsDevice.Viewport.Height / 2) - (spriteEntity.Size.Height / 2));
                spriteEntity.Position = SpriteHelper.GetAbsolutePosition(spriteEntity.Position, GameManager.GraphicsDeviceManager);
                IBall model = new Ball(spriteEntity);
                controller = new BallController(model, GameManager);
                //model.Name = "Ball";
                return controller;

            }

            //if( type == "MainBackground")
            //{
            //    controller = CreateDefaultSprite("Pong Title Screen");
            //    //controller = CreateBackground();
            //    //controller.LoadContent("Pong Title Screen");
            //    //controller.Name = "TitleScreen";
            //}

            //if (type == "Background")
            //{
            //    controller = CreateBackground();
            //    controller.LoadContent("Grass");
            //    controller.Size = new Rectangle(0, 0, Game.GraphicsDevice.Viewport.Width, Game.GraphicsDevice.Viewport.Height);
            //}

            //if( type=="Circle")
            //{
            //    controller = new SinusCurveSpriteEntity(new NullController(), new NullGraphicsManager(), Game);
            //    controller.LoadContent("Pixel");
            //    controller.Name = "Circle";
            //}

            //if( type=="Player1Scores")
            //{
            //    controller = new PlayerScoredView(new NullController(), new NullGraphicsManager(), Game);
            //    controller.LoadContent("Player1Scores");
            //    controller.Name = "Player1Scores";
            //    controller.Position = new Vector2(300, 250);
            //}
            //if( type== "Player2Scores")
            //{
            //    controller = new PlayerScoredView(new NullController(), new NullGraphicsManager(), Game);
            //    controller.LoadContent("Player2Scores");
            //    controller.Name = "Player2Scores";
            //    controller.Position = new Vector2(300, 250);
            //}

            ThrowTypeInitializationExeption(type);
            return null;
        }
Пример #2
0
        public PadelView(IPadel padel, PadelController padelController)
        {
            Padel = padel;
            Controller = padelController;

        }