Exemplo n.º 1
0
 public JumpingState(Teno teno, Game1 game)
 {
     this.game      = game;
     this.teno      = teno;
     teno.isJumping = true;
     game.level.collision.standingBlock.Clear();
 }
Exemplo n.º 2
0
        public RightIdleTeno(Teno teno)
        {
            ISpriteFactory factory = new SpriteFactory();

            Sprite    = factory.build(SpriteFactory.sprites.rightIdleTeno);
            this.teno = teno;
        }
Exemplo n.º 3
0
 public RightFallingTeno(Teno teno, Game1 game)
 {
     this.game = game;
     factory   = new SpriteFactory();
     Sprite    = factory.build(SpriteFactory.sprites.rightJumpFallTeno);
     this.teno = teno;
 }
Exemplo n.º 4
0
 public FallingState(Teno teno, Game1 game)
 {
     this.game      = game;
     this.teno      = teno;
     teno.isFalling = true;
     teno.isJumping = false;
 }
Exemplo n.º 5
0
 public LeftJumpingTeno(Teno teno, Game1 game)
 {
     this.game = game;
     factory   = new SpriteFactory();
     Sprite    = factory.build(SpriteFactory.sprites.leftJumpUpTeno);
     this.teno = teno;
 }
Exemplo n.º 6
0
        public void TenoHouseCollide(Teno teno, House house, List <House> standingHouse)
        {
            Rectangle tenoRect     = teno.state.GetBoundingBox(teno.position);
            Rectangle houseRect    = house.state.GetBoundingBox(house.position);
            Rectangle intersection = Rectangle.Intersect(tenoRect, houseRect);

            if (intersection.Height > intersection.Width)
            {
                if (tenoRect.Right > houseRect.Left && tenoRect.Right < houseRect.Right)
                {
                    teno.position.X -= intersection.Width;
                }
                else
                {
                    teno.position.X += intersection.Width;
                }
            }
            else if (intersection.Height < intersection.Width)
            {
                if (tenoRect.Bottom > houseRect.Top && tenoRect.Bottom < houseRect.Bottom)
                {
                    if (!teno.isJumping)
                    {
                        teno.velocity.Y = 0;
                    }
                    if (intersection.Height > 1)
                    {
                        teno.position.Y -= intersection.Height;
                    }
                    standingHouse.Add(house);
                }
            }
        }
Exemplo n.º 7
0
        public LeftMovingTeno(Teno teno)
        {
            ISpriteFactory factory = new SpriteFactory();

            Sprite    = factory.build(SpriteFactory.sprites.leftMovingTeno);
            this.teno = teno;
        }
Exemplo n.º 8
0
        public LeftIdleTeno(Teno teno, Game1 game)
        {
            this.game = game;
            ISpriteFactory factory = new SpriteFactory();

            Sprite    = factory.build(SpriteFactory.sprites.leftIdleTeno);
            this.teno = teno;
        }
Exemplo n.º 9
0
        public DeadTeno(Teno teno)
        {
            ISpriteFactory factory = new SpriteFactory();

            Sprite    = factory.build(SpriteFactory.sprites.deadTeno);
            this.teno = teno;
            Game1.GetInstance().gameState = new DeadGameState(teno);
        }
Exemplo n.º 10
0
 public DeadGameState(Teno mario)
 {
     game      = Game1.GetInstance();
     this.teno = mario;
     //SoundManager.StopMusic();
     //SoundManager.death.Play();
     teno.isDead = true;
 }
Exemplo n.º 11
0
 public TrasitionGameState(Teno teno, ITenoState prevState, ITenoState newState, Game1 game)
 {
     this.game      = game;
     this.teno      = teno;
     this.prevState = prevState;
     this.newState  = newState;
     currentState   = prevState;
 }
Exemplo n.º 12
0
 public CollisionDetector(Teno teno, Game1 game)
 {
     this.game      = game;
     blockResponser = new BlockCollisionResponder(game);
     houseResponser = new HouseCollisionResponder(game);
     enemyResponser = new EnemyCollisionResponder(game);
     itemResponser  = new ItemCollisionResponder(game);
 }
Exemplo n.º 13
0
 public DeadGameState(Teno mario, Game1 game)
 {
     this.game = game;
     this.teno = mario;
     SoundManager.StopMusic();
     //SoundManager.death.Play();
     teno.isDead = true;
 }
Exemplo n.º 14
0
        public RightMovingTeno(Teno teno, Game1 game)
        {
            this.game = game;
            ISpriteFactory factory = new SpriteFactory();

            Sprite    = factory.build(SpriteFactory.sprites.rightRunTeno);
            this.teno = teno;
        }
Exemplo n.º 15
0
        public Teno Build(string fileName)
        {
            float        xCoord = 0, yCoord = 0;
            StreamReader sr;

            sr = File.OpenText(fileName);
            string line;

            while ((line = sr.ReadLine()) != null)
            {
                yCoord += spacingIncrement;
                xCoord  = 0;
                string[] words = line.Split(',');
                for (int i = 0; i < words.Length; i++)
                {
                    int events = 1;
                    if (words[i] == "T")
                    {
                        teno = new Teno(new Vector2(xCoord, yCoord), game);
                    }
                    if (itemDictionary.ContainsKey(words[i]))
                    {
                        ICollectable item = collectableFactory.build(itemDictionary[words[i]], new Vector2(xCoord, yCoord));
                        level.levelItems.Add(item);
                    }
                    if (backgroundDictonary.ContainsKey(words[i]))
                    {
                        if (words[i] == "ex")
                        {
                            level.exitPosition = new Vector2(xCoord, yCoord);
                        }
                        else
                        {
                            KeyValuePair <IAnimatedSprite, Vector2> item = new KeyValuePair <IAnimatedSprite, Vector2>
                                                                               (factory.build(backgroundDictonary[words[i]]), new Vector2(xCoord, yCoord));
                            level.levelBackgroundObjects.Add(item);
                        }
                    }
                    if (blockDictionary.ContainsKey(words[i]))
                    {
                        Block block = blockFactory.build(blockDictionary[words[i]], new Vector2(xCoord, yCoord));
                        level.levelBlock.Add(block);
                    }
                    if (enemyDictionary.ContainsKey(words[i]))
                    {
                        Enemy enemy = enemyFactory.build(enemyDictionary[words[i]], new Vector2(xCoord, yCoord));
                        level.levelEnemies.Add(enemy);
                    }

                    if (words[i] == "Ch")
                    {
                        level.checkpoint = new Vector2(xCoord, yCoord);
                    }
                    xCoord += spacingIncrement * events;
                }
            }
            return(teno);
        }
Exemplo n.º 16
0
 public void TenoItemCollide(Teno teno, ICollectable item)
 {
     if (item.GetType().Equals(new Coin(item.position).GetType()))
     {
         //SoundManager.coinCollect.Play();
         //game.gameHUD.Coins++;
         //game.gameHUD.Score += ValueHolder.coinCollectPoints;
     }
 }
Exemplo n.º 17
0
 public Level(string fileName)
 {
     game    = new Game1();
     builder = new LevelBuilder(this);
     teno    = builder.Build(fileName);
     game.gameCamera.LookAt(teno.position);
     collision         = new CollisionDetector(teno, game);
     exitPole          = new GateSprite(Game1.gameContent.Load <Texture2D>("gateFramedFinal"), 2, 23);
     game.gameHUD.Time = ValueHolder.startingTime;
 }
Exemplo n.º 18
0
        public void TenoEnemyCollide(Teno teno, Enemy enemy)
        {
            Rectangle tenoRect     = teno.state.GetBoundingBox(teno.position);
            Rectangle eneRect      = enemy.state.GetBoundingBox(enemy.position);
            Rectangle intersection = Rectangle.Intersect(tenoRect, eneRect);

            if (intersection != null)
            {
                teno.MakeDeadTeno();
            }
        }
Exemplo n.º 19
0
 public Level(Game1 game, string fileName)
 {
     this.game    = game;
     levelCurrent = fileName;
     builder      = new LevelBuilder(this, game);
     teno         = builder.Build(fileName);
     game.gameCamera.LookAt(teno.position);
     collision         = new CollisionDetector(teno, game);
     exitPole          = new GateSprite(Game1.gameContent.Load <Texture2D>("Item/exit"), 1, 1);
     game.gameHUD.Time = ValueHolder.startingTime;
 }
Exemplo n.º 20
0
        public GroundState(Teno teno, Game1 game)
        {
            this.game = game;
            teno.state.Land();
            teno.velocity.Y = 0;
            this.teno       = teno;
            game.gameHUD.pointMultiplier = 1;

            teno.isJumping = false;
            teno.isFalling = false;
        }
Exemplo n.º 21
0
 public KeyboardController(Teno teno, Game1 game)
 {
     this.teno       = teno;
     commandLibrabry = new Dictionary <Keys, ICommands>();
     commandLibrabry.Add(Keys.W, currentCommand         = new UpCommand(teno));
     commandLibrabry.Add(Keys.LeftShift, currentCommand = new RunCommand(teno));
     commandLibrabry.Add(Keys.A, currentCommand         = new LeftCommand(teno));
     commandLibrabry.Add(Keys.D, currentCommand         = new RightCommand(teno));
     commandLibrabry.Add(Keys.S, currentCommand         = new DownCommand(teno));
     commandLibrabry.Add(Keys.Escape, currentCommand    = new QuitCommand(game));
     //commandLibrabry.Add(Keys.Enter, currentCommand = new PauseCommand(game));
 }
Exemplo n.º 22
0
 public VVVVVVKeyController(Teno mario)
 {
     flip           = new FlipCommand(mario);
     this.mario     = mario;
     commandLibrary = new Dictionary <Keys, ICommands>();
     commandLibrary.Add(Keys.W, currentCommand = new FlipCommand(mario));
     commandLibrary.Add(Keys.S, currentCommand = new FlipCommand(mario));
     commandLibrary.Add(Keys.A, currentCommand = new LeftCommand(mario));
     commandLibrary.Add(Keys.D, currentCommand = new RightCommand(mario));
     commandLibrary.Add(Keys.Q, currentCommand = new QuitCommand());
     commandLibrary.Add(Keys.R, currentCommand = new ResetSceneCommand());
 }
Exemplo n.º 23
0
        public void TenoBlockCollide(Teno teno, Block block, List <Block> detroyedBlocks, List <Block> standingBlock)
        {
            Rectangle tenoRect     = teno.state.GetBoundingBox(teno.position);
            Rectangle blockRect    = block.GetBoundingBox();
            Rectangle intersection = Rectangle.Intersect(tenoRect, blockRect);

            if (intersection.Height > intersection.Width)
            {
                if (tenoRect.Right > blockRect.Left && tenoRect.Right < blockRect.Right)
                {
                    teno.position.X -= intersection.Width;
                }
                else
                {
                    teno.position.X += intersection.Width;
                }
            }
            else if (intersection.Height < intersection.Width)
            {
                if (tenoRect.Bottom > blockRect.Top && tenoRect.Bottom < blockRect.Bottom)
                {
                    if (!teno.isJumping)
                    {
                        teno.velocity.Y = 0;
                    }
                    if (intersection.Height > 1)
                    {
                        teno.position.Y -= intersection.Height;
                    }
                    standingBlock.Add(block);
                }
                else
                {
                    teno.position.Y += intersection.Height;
                    if (!game.isVVVVVV)
                    {
                        block.Reaction();
                        teno.physState = new FallingState(teno);
                        teno.tenoHight = 0;

                        /*if (block.state.GetType().Equals(new BrickBlockState().GetType()) && mario.isBig)
                         * {
                         *  block.Explode();
                         * }*/
                    }
                    else
                    {
                        standingBlock.Add(block);
                    }
                }
            }
        }
Exemplo n.º 24
0
        public DeadTeno(Teno teno, Game1 game)
        {
            this.game = game;
            ISpriteFactory factory = new SpriteFactory();

            if (teno.state.GetType().Equals(new RightCrouchingTeno(teno, game).GetType()) || teno.state.GetType().Equals(new RightFallingTeno(teno, game).GetType()) ||
                teno.state.GetType().Equals(new RightIdleTeno(teno, game).GetType()) || teno.state.GetType().Equals(new RightJumpingTeno(teno, game).GetType()) ||
                teno.state.GetType().Equals(new RightMovingTeno(teno, game).GetType()))
            {
                Sprite = factory.build(SpriteFactory.sprites.rightDeadTeno);
            }
            else
            {
                Sprite = factory.build(SpriteFactory.sprites.leftDeadTeno);
            }
            this.teno      = teno;
            game.gameState = new DeadGameState(teno, game);
        }
Exemplo n.º 25
0
        public void Detect(Teno teno, List <Enemy> levelEnemies, List <Block> levelBlocks, List <House> levelHouses,
                           List <ICollectable> levelItems)
        {
            Rectangle tenoRect = teno.state.GetBoundingBox(teno.position);

            foreach (Enemy enemy in levelEnemies)
            {
                Rectangle eneRect = enemy.state.GetBoundingBox(enemy.position);
                if (!enemy.isDead)
                {
                    if (tenoRect.Intersects(eneRect))
                    {
                        enemyResponser.TenoEnemyCollide(teno, enemy);
                    }
                }

                foreach (Block block in levelBlocks)
                {
                    Rectangle blockRect = block.GetBoundingBox();
                    if (eneRect.Intersects(blockRect))
                    {
                        blockResponser.EnemyBlockCollide(enemy, block);
                    }
                }
                foreach (Enemy otherEnemy in levelEnemies)
                {
                    Rectangle otherEnemyRect = otherEnemy.state.GetBoundingBox(otherEnemy.position);
                    if (otherEnemy != enemy && otherEnemyRect.Intersects(eneRect))
                    {
                        enemyResponser.EnemyEnemyCollide(enemy, otherEnemy);
                    }
                }
                foreach (House house in levelHouses)
                {
                    Rectangle houseRect = house.state.GetBoundingBox(house.position);
                    if (houseRect.Intersects(eneRect))
                    {
                        houseResponser.HouseEnemyCollide(enemy, house);
                    }
                }
            }
            foreach (House house in levelHouses)
            {
                Rectangle houseRect = house.GetBoundingBox(house.position);
                if (houseRect.Intersects(tenoRect))
                {
                    houseResponser.TenoHouseCollide(teno, house, standingHouse);
                }
            }
            foreach (ICollectable item in levelItems)
            {
                Rectangle itemRect = item.GetBoundingBox();
                if (itemRect.Intersects(tenoRect) && !item.isSpawning)
                {
                    ontainedItems.Add(item);
                    itemResponser.TenoItemCollide(teno, item);
                }
            }

            foreach (Block block in levelBlocks)
            {
                if (game.gameCamera.InCameraView(block.GetBoundingBox()))
                {
                    Rectangle blockRect = block.GetBoundingBox();
                    if (tenoRect.Intersects(blockRect))
                    {
                        blockResponser.TenoBlockCollide(teno, block, detroyedBlock, standingBlock);
                    }
                    else
                    {
                        standingBlock.Remove(block);
                    }
                }
            }
            foreach (ICollectable obtainedItem in ontainedItems)
            {
                levelItems.Remove(obtainedItem);
            }
            foreach (Block destroyedBlock in detroyedBlock)
            {
                levelBlocks.Remove(destroyedBlock);
            }
        }
Exemplo n.º 26
0
 public RightCommand(Teno teno)
 {
     this.teno = teno;
 }
Exemplo n.º 27
0
 public UpCommand(Teno teno)
 {
     this.teno = teno;
 }
Exemplo n.º 28
0
 public LeftCommand(Teno teno)
 {
     this.teno = teno;
 }
Exemplo n.º 29
0
 public RightJumpingTeno(Teno teno)
 {
     factory   = new SpriteFactory();
     Sprite    = factory.build(SpriteFactory.sprites.rightJumpingTeno);
     this.teno = teno;
 }
Exemplo n.º 30
0
 public DeadFlipGameState(Teno teno, Game1 game)
 {
     this.game = game;
     this.teno = teno;
 }