public virtual void Update(ISpriteEntity spriteEntity, GameTime gameTime, BallInput ballInput)
 {
     ballInput.PlayScored();
     _gameManager = ((IGameManager)spriteEntity.Game.Services.GetService(typeof(IGameManager)));
     int score = (int)_gameManager[PlayerScoreKey];
     score++;
     _gameManager[PlayerScoreKey] = score;
 }
Example #2
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);
        }
Example #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.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);
        }
Example #4
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);
        }
Example #5
0
        /// <summary>
        /// Creates the sprite.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public ISpriteEntity CreateSprite(string type)
        {
            ISpriteEntity spriteEntity = null;
            if (type == "Padel1")
            {
                spriteEntity = CreatePadel();

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

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

            if (type == "Ball")
            {
                spriteEntity = CreateBall();
                BallConfiguration ballConfiguration = Game.Content.Load<BallConfiguration>("Ball.Config");
                spriteEntity.LoadContent(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));
                BallInput input = new BallInput(new StartBallState());
                CollisionManager.Collision += new CollisionEventHandler(input.BallInput_Collision);
                spriteEntity.Input = input;
            }

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

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

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

            if( spriteEntity!=null)
            {
                spriteEntity.Graphics = SpriteGraphics;
            }

            return spriteEntity;
        }
Example #6
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);
        }
Example #7
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);
        }