Esempio n. 1
0
        /// <summary>
        /// Creates the sprite.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public IEntity CreateSprite(string type)
        {
            IEntity entity = null;

            if (type == "Padel1")
            {
                entity = CreatePadel();

                PadelConfiguration padelConfiguration = Game.Content.Load <PadelConfiguration>("Padel.Config");
                //entity.SpriteTexture = _textureManager.GetTexture("PlanetBeam");
                entity.LoadContent(padelConfiguration.AssetName);
                entity.Scale    = padelConfiguration.Scale;
                entity.Position = new Vector2(padelConfiguration.Position, (Game.GraphicsDevice.Viewport.Height / 2) - (entity.Size.Height / 2));
                entity.Input    = new Player1KeyboardInput();
                entity.Name     = "Player1";
            }

            if (type == "Padel2")
            {
                entity = CreatePadel();
                PadelConfiguration padelConfiguration = Game.Content.Load <PadelConfiguration>("Padel.Config");
                entity.LoadContent(padelConfiguration.AssetName);
                entity.Scale    = padelConfiguration.Scale;
                entity.Position = new Vector2(Game.GraphicsDevice.Viewport.Width - entity.Size.Width - padelConfiguration.Position, (Game.GraphicsDevice.Viewport.Height / 2) - (entity.Size.Height / 2));
                entity.Input    = new Player2KeyboardInput();
                entity.Name     = "Player2";
            }

            if (type == "Ball")
            {
                entity = CreateBall();
                BallConfiguration ballConfiguration = Game.Content.Load <BallConfiguration>("Ball.Config");
                entity.LoadContent(ballConfiguration.AssetName);
                entity.Scale    = ballConfiguration.Scale;
                entity.Color    = Color.Black;
                entity.Position = new Vector2((Game.GraphicsDevice.Viewport.Width / 2) - (entity.Size.Width / 2), (Game.GraphicsDevice.Viewport.Height / 2) - (entity.Size.Height / 2));
                BallInput input = new BallInput(new StartBallState());
                CollisionManager.Collision += new CollisionEventHandler(input.BallInput_Collision);
                entity.Input = input;
            }

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

            if (type == "Circle")
            {
                entity = new CircleDebugEntity(new NullInput(), new NullGraphics(), Game);
                entity.LoadContent("Pixel");
                entity.Name = "Circle";
            }

            return(entity);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates the sprite.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public void Add(string type)
        {
            IEntity entity = null;

            if (type == "Padel1")
            {
                entity = EntityFactory.CreateSprite("Padel");

                PadelConfiguration padelConfiguration = Game.Content.Load <PadelConfiguration>("Padel.Config");
                entity.LoadContent(padelConfiguration.AssetName);
                entity.Scale    = padelConfiguration.Scale;
                entity.Position = new Vector2(padelConfiguration.Position, (Game.GraphicsDevice.Viewport.Height / 2) - (entity.Size.Height / 2));
                entity.Input    = new Player1KeyboardInput();
                entity.Name     = "Player1";
                player1         = entity;
                camera.Focus    = player1 as IFocusable;
            }

            if (type == "Padel2")
            {
                entity = EntityFactory.CreateSprite("Padel");
                PadelConfiguration padelConfiguration = Game.Content.Load <PadelConfiguration>("Padel.Config");
                entity.LoadContent(padelConfiguration.AssetName);
                entity.Scale    = padelConfiguration.Scale;
                entity.Position = new Vector2(Game.GraphicsDevice.Viewport.Width - entity.Size.Width - padelConfiguration.Position, (Game.GraphicsDevice.Viewport.Height / 2) - (entity.Size.Height / 2));
                entity.Input    = new Player2KeyboardInput();
                entity.Name     = "Player2";
                player2         = entity;
            }

            if (type == "Ball")
            {
                entity = EntityFactory.CreateSprite("Ball");
                BallConfiguration ballConfiguration = Game.Content.Load <BallConfiguration>("Ball.Config");
                entity.LoadContent(ballConfiguration.AssetName);
                entity.Scale    = ballConfiguration.Scale;
                entity.Color    = Color.Black;
                entity.Position = new Vector2((Game.GraphicsDevice.Viewport.Width / 2) - (entity.Size.Width / 2), (Game.GraphicsDevice.Viewport.Height / 2) - (entity.Size.Height / 2));
                BallInput input = new BallInput(new StartBallState());
                CollisionManager.Collision += new CollisionEventHandler(input.BallInput_Collision);
                entity.Input = input;
                ball         = entity;
            }
            if (type == "Background")
            {
                entity = EntityFactory.CreateSprite("Background");
                entity.LoadContent("Grass");
                entity.Size = new Rectangle(0, 0, Game.GraphicsDevice.Viewport.Width, Game.GraphicsDevice.Viewport.Height);
                background  = entity;
            }

            _entities.Add(entity);
        }
Esempio n. 3
0
        /// <summary>
        /// Creates the sprite.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public void Add(string type)
        {
            IEntity entity = null;

            if (type == "Padel1")
            {
                entity = EntityFactory.Instance.CreateSprite("Padel");

                PadelConfiguration padelConfiguration = _contentManager.Load <PadelConfiguration>("Padel.Config");
                entity.LoadContent(_contentManager, padelConfiguration.AssetName);
                entity.Scale    = padelConfiguration.Scale;
                entity.Position = new Vector2(padelConfiguration.Position, (Game.GraphicsDevice.Viewport.Height / 2) - (entity.Size.Height / 2));
                entity.Input    = new Player1KeyboardInput();
                entity.Name     = "Player1";
                player1         = entity;
            }

            if (type == "Padel2")
            {
                entity = EntityFactory.Instance.CreateSprite("Padel");
                PadelConfiguration padelConfiguration = _contentManager.Load <PadelConfiguration>("Padel.Config");
                entity.LoadContent(_contentManager, padelConfiguration.AssetName);
                entity.Scale    = padelConfiguration.Scale;
                entity.Position = new Vector2(Game.GraphicsDevice.Viewport.Width - entity.Size.Width - padelConfiguration.Position, (Game.GraphicsDevice.Viewport.Height / 2) - (entity.Size.Height / 2));
                entity.Input    = new Player2KeyboardInput();
                entity.Name     = "Player2";
                player2         = entity;
            }

            if (type == "Ball")
            {
                entity = EntityFactory.Instance.CreateSprite("Ball");
                BallConfiguration ballConfiguration = _contentManager.Load <BallConfiguration>("Ball.Config");
                entity.LoadContent(_contentManager, ballConfiguration.AssetName);
                entity.Scale    = ballConfiguration.Scale;
                entity.Position = new Vector2((Game.GraphicsDevice.Viewport.Width / 2) - (entity.Size.Width / 2), (Game.GraphicsDevice.Viewport.Height / 2) - (entity.Size.Height / 2));
                BallInput input = new BallInput();
                _collisionManager.Collision += new CollisionEventHandler(input.BallInput_Collision);
                entity.Input = input;
                ball         = entity;
            }
            if (type == "WallUpper")
            {
            }

            if (type == "WallLower")
            {
            }


            _entities.Add(entity);
        }