Exemple #1
0
        public override void Update(Minijam32 game, MouseState mouse, MouseState oldMouse, KeyboardState keys, KeyboardState oldKeys)
        {
            if ((keys.IsKeyDown(Keys.W) && oldKeys.IsKeyUp(Keys.W)) || (keys.IsKeyDown(Keys.Up) && oldKeys.IsKeyUp(Keys.Up)))
            {
                pressedButton--;
                SoundPlayer.PlaySound(SoundPlayer.Type.MenuSwitch);
            }
            else if ((keys.IsKeyDown(Keys.S) && oldKeys.IsKeyUp(Keys.S)) || (keys.IsKeyDown(Keys.Down) && oldKeys.IsKeyUp(Keys.Down)))
            {
                pressedButton++;
                SoundPlayer.PlaySound(SoundPlayer.Type.MenuSwitch);
            }

            if (pressedButton < 0)
            {
                pressedButton = 0;
            }
            if (pressedButton > 1)
            {
                pressedButton = 1;
            }

            if (keys.IsKeyDown(Keys.Space) && oldKeys.IsKeyUp(Keys.Space) && pressedButton == 0)
            {
                game.screenPool.TriggerGameStart();
                SoundPlayer.PlaySound(SoundPlayer.Type.MenuConfirm);
            }
            if (keys.IsKeyDown(Keys.Space) && oldKeys.IsKeyUp(Keys.Space) && pressedButton == 1)
            {
                game.Exit();
            }
        }
Exemple #2
0
        private void ControlRandomMovement(Minijam32 game)
        {
            bool hasGeneratedPos = false;
            int  i = 0;

            //Later there will be a check "if 4 sides are blocked then no check"

            while (!hasGeneratedPos && i < 10)
            {
                i++;

                Point move   = this.GenerateNewDirectionalMove();
                Point newPos = this.currentPos + move;

                if (newPos.X <= 0 || newPos.Y <= 0 || newPos.X >= game.levelData.tileGrid.GetLength(0) || newPos.Y >= game.levelData.tileGrid.GetLength(1))
                {
                    continue;
                }

                if (IsThisNewPosOkay(game, newPos))
                {
                    hasGeneratedPos  = true;
                    this.currentPos += move;
                    this.lastMove    = move;
                }
            }
        }
Exemple #3
0
        public void CallGuiControlUpdates(Minijam32 game)
        {
            this._key   = Keyboard.GetState();
            this._mouse = Mouse.GetState();

            //code
            if (screenState == ScreenState.Start)
            {
                menuGui.Update(game, _mouse, _oldMouse, _key, _oldKey);
            }
            else if (screenState == ScreenState.Playing)
            {
                PlayerController.UpdateMovement(game, _key, _oldKey);
            }
            else if (screenState == ScreenState.DeadGameOver)
            {
                newLevelDrawer.UpdateDeathScene(game, _key, _oldKey);
            }
            else if (screenState == ScreenState.SwitchingLevel)
            {
                this.currentNewLevelDelayLeft -= Minijam32.DeltaUpdate;
                if (currentNewLevelDelayLeft <= 0f)
                {
                    screenState = ScreenState.Playing;
                    game.musicPlayer.Unmute();
                }
            }
            else if (screenState == ScreenState.FinishedGame)
            {
                this.finishedGameDrawer.Update(game, _key, _oldKey);
            }

            this._oldKey   = this._key;
            this._oldMouse = this._mouse;
        }
Exemple #4
0
        private bool TryMoveInStraightLine(Minijam32 game)
        {
            //Obtain the direction and, since we're tile-based, make only one step at a time
            Point move = PlayerDataManager.tilePosition - this.currentPos;

            move = new Point(Math.Sign(move.X), Math.Sign(move.Y));

            //Remember new position for later calculations
            Point newPos = this.currentPos + move;

            //Try to see if the tiles on straight line don't contain any bad ones like solid or bombs
            int tilesInLine = (int)(PlayerDataManager.tilePosition - this.currentPos).ToVector2().Length();

            for (int i = 1; i < tilesInLine; i++)
            {
                bool normalTile = IsThisNewPosOkay(game, (move.ToVector2() * i * Math.Sign(move.X + move.Y)).ToPoint() + this.currentPos);
                if (!normalTile)
                {
                    return(false);
                }
            }

            //Try to see if there aren't any tiles like bombs and solid tiles, and move
            if (IsThisNewPosOkay(game, newPos))
            {
                this.currentPos += move;
                this.lastMove    = move;

                return(true);
            }

            //We've failed every check up to that
            return(false);
        }
Exemple #5
0
 public LevelData(Minijam32 game)
 {
     maxLevelId     = Convert.ToInt32(File.ReadAllLines("Code/Level/Layouts/last_level_id.txt")[0]);
     currentLevelId = 1;
     this.ReInitializeLevelData(level: currentLevelId);
     hasCompletedLastLevel = false;
 }
Exemple #6
0
        static public void LoadAssets(Minijam32 game)
        {
            playerHpGui  = game.Content.Load <Texture2D>("res/gui/hp_bar");
            numbersSheet = game.Content.Load <Texture2D>("res/gui/numbers");

            normalColor = new Color(238, 216, 261);
            dangerColor = new Color(165, 140, 39);
            deathColor  = new Color(239, 58, 12);
        }
Exemple #7
0
        public MenuGui(Minijam32 game)
        {
            menuButtons    = game.Content.Load <Texture2D>("res/gui/menu");
            menuBackground = game.Content.Load <Texture2D>("res/gui/menu_background");
            menuPressed    = game.Content.Load <Texture2D>("res/gui/menu_selected");

            UnscaledPlayCoords = new Vector2(129, 101);
            UnscaledExitCoords = new Vector2(129, 147);
        }
 public void Update(Minijam32 game, KeyboardState keys, KeyboardState oldKeys)
 {
     if (keys.IsKeyDown(Keys.Space) && oldKeys.IsKeyUp(Keys.Space))
     {
         game.levelData.ResetToDefault();
         game.screenPool.GoMenu();
         PlayerDataManager.ResetToDefaultState();
     }
 }
Exemple #9
0
        static public void InitAssets(Minijam32 game)
        {
            bombSheet  = game.Content.Load <Texture2D>("res/tile/exp");
            heartSheet = game.Content.Load <Texture2D>("res/tile/heart");

            finiteFieldAnimations = new List <Animation> {
            };
            heartAnimations       = new Dictionary <Point, Animation> {
            };
        }
Exemple #10
0
        public void Update(Minijam32 game)
        {
            currentWaitTime -= Minijam32.DeltaUpdate;

            if (currentWaitTime <= 0)
            {
                currentWaitTime = defaultWaitTime;
                this.Move(game);
            }
        }
Exemple #11
0
 public void DrawAbove(Minijam32 game, SpriteBatch batch)
 {
     for (int x = tileGrid.GetLength(0) - 1; x >= 0; x--)
     {
         for (int y = tileGrid.GetLength(1) - 1; y >= 0; y--)
         {
             TileDrawer.DrawTileRoofingAt(batch, tileGrid[x, y].type, new Point(x, y));
         }
     }
 }
Exemple #12
0
        /// <summary>
        /// Main draw cycle. Calls other drawers.
        /// </summary>
        public void CallDraws(Minijam32 game, SpriteBatch batch, GraphicsDevice graphicsDevice)
        {
            graphicsDevice.Clear(backgroundDirtColor);
            batch.Begin(samplerState: SamplerState.PointClamp);

            if (screenState == ScreenState.Start)
            {
                this.menuGui.Draw(game, batch);
            }
            else if (screenState == ScreenState.Playing)
            {
                if (PlayerDataManager.isDead)
                {
                    this.SetStateToDeath();
                }

                if (game.levelData.hasCompletedLastLevel)
                {
                    screenState = ScreenState.FinishedGame;
                    game.musicPlayer.Mute();
                    SoundPlayer.PlaySound(SoundPlayer.Type.NextLevelLick);
                }

                game.levelData.DrawBelow(game, batch);
                PlayerDrawer.DrawCurrentState(batch, PlayerDataManager.tilePosition);
                game.levelData.DrawAbove(game, batch);
                Animator.DrawFieldAnimations(batch);

                InfoDrawer.Draw(batch);
            }
            else if (screenState == ScreenState.SwitchingLevel)
            {
                this.newLevelDrawer.DrawNextLevelIntro(batch);
            }
            else if (screenState == ScreenState.DeadGameOver)
            {
                game.levelData.DrawBelow(game, batch);
                PlayerDrawer.DrawCurrentState(batch, PlayerDataManager.tilePosition);
                game.levelData.DrawAbove(game, batch);
                Animator.DrawFieldAnimations(batch);

                this.newLevelDrawer.DrawDeathScene(batch);
            }
            else if (screenState == ScreenState.FinishedGame)
            {
                game.levelData.DrawBelow(game, batch);
                PlayerDrawer.DrawCurrentState(batch, PlayerDataManager.tilePosition);
                game.levelData.DrawAbove(game, batch);
                Animator.DrawFieldAnimations(batch);

                this.finishedGameDrawer.DrawGameCompletedScene(game, batch);
            }

            batch.End();
        }
Exemple #13
0
        public ScreenPool(Minijam32 game)
        {
            this.screenState         = ScreenState.Start;
            this.backgroundDirtColor = new Color(104, 76, 60);

            currentNewLevelDelayLeft = 0f;

            newLevelDrawer     = new NewLevelDrawer(game);
            finishedGameDrawer = new GameFinishedDrawer(game);
            menuGui            = new MenuGui(game);
        }
Exemple #14
0
        public override void Draw(Minijam32 game, SpriteBatch spriteBatch)
        {
            DrawBackground(spriteBatch);

            this.DrawTexture(spriteBatch, this.menuButtons, Vector2.Zero, Minijam32.Scale);

            if (pressedButton == 0)
            {
                this.DrawTexture(spriteBatch, menuPressed, UnscaledPlayCoords * Minijam32.Scale, Minijam32.Scale);
            }
            if (pressedButton == 1)
            {
                this.DrawTexture(spriteBatch, menuPressed, UnscaledExitCoords * Minijam32.Scale, Minijam32.Scale);
            }
        }
        public void DrawGameCompletedScene(Minijam32 game, SpriteBatch batch)
        {
            screen.Draw(batch, new Color(21, 15, 10, fadeOut), Vector2.Zero, new Vector2(Minijam32.ScaledWidth, Minijam32.ScaledHeight));

            if (fadeOut < 255)
            {
                fadeOut++;
            }
            else
            {
                game.screenPool.menuGui.DrawBackground(batch);
                batch.Draw(sorryNothing, Vector2.Zero, null, Color.White, 0.0f, Vector2.Zero, Minijam32.Scale, SpriteEffects.None, 0.0f);
                InfoDrawer.DrawCoinsGui(batch, centered: true);
            }
        }
Exemple #16
0
        public void DrawBelow(Minijam32 game, SpriteBatch batch)
        {
            //Tiles
            for (int x = tileGrid.GetLength(0) - 1; x >= 0; x--)
            {
                for (int y = tileGrid.GetLength(1) - 1; y >= 0; y--)
                {
                    TileDrawer.DrawTileAt(batch, tileGrid[x, y].type, new Point(x, y));
                }
            }

            //Bombs
            foreach (var location in this.plantedBombs.Keys)
            {
                int bombFuseCh = (int)(this.plantedBombs[location]);

                if (bombFuseCh > 1000)
                {
                    if ((bombFuseCh / 100) % 5 == 0)
                    {
                        TileDrawer.DrawTileAt(batch, TileData.Type.BombOne, location);
                    }
                    else
                    {
                        TileDrawer.DrawTileAt(batch, TileData.Type.BombTwo, location);
                    }
                }
                else
                {
                    if ((bombFuseCh / 100) % 2 == 0)
                    {
                        TileDrawer.DrawTileAt(batch, TileData.Type.BombOne, location);
                    }
                    else
                    {
                        TileDrawer.DrawTileAt(batch, TileData.Type.BombTwo, location);
                    }
                }
            }

            //Enemies
            foreach (var enemy in this.enemies)
            {
                EnemyDrawer.DrawThisTypeAt(batch, enemy);
            }
        }
Exemple #17
0
        private void Move(Minijam32 game)
        {
            //The idea is that a straight line difference is always integer, but the non-straight line will always have some weirdass numbers
            bool playerInStraightLine = (this.currentPos - PlayerDataManager.tilePosition).ToVector2().Length() % 1 == 0;

            bool success = false;

            if (playerInStraightLine)
            {
                success = TryMoveInStraightLine(game);
            }

            //For every other case including finding a straight line but meeting a wall, use random movements
            if (!success)
            {
                ControlRandomMovement(game);
            }
        }
        static public void InitAssets(Minijam32 game)
        {
            currentState    = State.FacingDownStill;
            heroDrawOffset  = new Vector2(0, -2);
            spritesheet     = game.Content.Load <Texture2D>("res/mob/hero");
            stateSourceRect = new Dictionary <State, Rectangle>
            {
                { State.FacingDownStill, new Rectangle(0, 14, 16, 18) },
                { State.FacingLeftStill, new Rectangle(0, 46, 16, 18) },
                { State.FacingUpStill, new Rectangle(0, 78, 16, 18) },
                { State.FacingRightStill, new Rectangle(0, 110, 16, 18) },
            };

            movingLeft  = new Animation(game, "res/mob/hero_left", 16, Minijam32.Scale, oneFrameTime);
            movingRight = new Animation(game, "res/mob/hero_right", 16, Minijam32.Scale, oneFrameTime);
            movingUp    = new Animation(game, "res/mob/hero_up", 16, Minijam32.Scale, oneFrameTime);
            movingDown  = new Animation(game, "res/mob/hero_down", 16, Minijam32.Scale, oneFrameTime);

            currentAnimationMs = 0f;
        }
Exemple #19
0
        public void Update(Minijam32 game)
        {
            if (!isMuted && PlayerDataManager.isDead)
            {
                isMuted = true;
                MediaPlayer.Stop();

                SoundPlayer.PlaySound(SoundPlayer.Type.GameOverLick);
            }

            if (game.screenPool.screenState == ScreenPool.ScreenState.Playing)
            {
                SongType shouldBePlaying = (SongType)(((game.levelData.currentLevelId - 1) % 3));

                if (shouldBePlaying != this.currentSong)
                {
                    this.currentSong = shouldBePlaying;
                    MediaPlayer.Play(this.songs[this.currentSong]);
                }
            }
        }
 public GameFinishedDrawer(Minijam32 game)
 {
     screen       = new Pixel(game.GraphicsDevice);
     sorryNothing = game.Content.Load <Texture2D>("res/gui/sorry_nothing");
     fadeOut      = 0;
 }
Exemple #21
0
 public NewLevelDrawer(Minijam32 game)
 {
     screen     = new Pixel(game.GraphicsDevice);
     youDied    = game.Content.Load <Texture2D>("res/gui/u_ded");
     deathAlpha = 0;
 }
 public void Update(Minijam32 game)
 {
 }
Exemple #23
0
 abstract public void Update(Minijam32 game, MouseState mouse, MouseState oldMouse, KeyboardState keys, KeyboardState oldKeys);
Exemple #24
0
        static public void UpdateMovement(Minijam32 game, KeyboardState keys, KeyboardState oldKeys)
        {
            keyState    = keys;
            oldKeyState = oldKeys;

            //On death, no controls
            if (PlayerDataManager.isDead)
            {
                return;
            }

            if (OneKeyPress(keyUp) || OneKeyPress(keyUp_a))
            {
                PlayerDataManager.TryMove(game.levelData, new Point(0, -1));
            }
            else if (OneKeyPress(keyDown) || OneKeyPress(keyDown_a))
            {
                PlayerDataManager.TryMove(game.levelData, new Point(0, +1));
            }
            else if (OneKeyPress(keyLeft) || OneKeyPress(keyLeft_a))
            {
                PlayerDataManager.TryMove(game.levelData, new Point(-1, 0));
            }
            else if (OneKeyPress(keyRight) || OneKeyPress(keyRight_a))
            {
                PlayerDataManager.TryMove(game.levelData, new Point(1, 0));
            }

#if DEBUG
            if (OneKeyPress(Keys.D1))
            {
                game.levelData.DebugSetLevel(1);
            }
            if (OneKeyPress(Keys.D2))
            {
                game.levelData.DebugSetLevel(2);
            }
            if (OneKeyPress(Keys.D3))
            {
                game.levelData.DebugSetLevel(3);
            }
            if (OneKeyPress(Keys.D4))
            {
                game.levelData.DebugSetLevel(4);
            }
            if (OneKeyPress(Keys.D5))
            {
                game.levelData.DebugSetLevel(5);
            }
            if (OneKeyPress(Keys.D6))
            {
                game.levelData.DebugSetLevel(6);
            }
            if (OneKeyPress(Keys.D7))
            {
                game.levelData.DebugSetLevel(7);
            }
            if (OneKeyPress(Keys.D8))
            {
                game.levelData.DebugSetLevel(8);
            }
            if (OneKeyPress(Keys.D9))
            {
                game.levelData.DebugSetLevel(9);
            }
            if (OneKeyPress(Keys.D0))
            {
                game.levelData.DebugSetLevel(10);
            }
#endif

            if (OneKeyPress(keyBomb))
            {
                game.levelData.TryPlantBombAt(PlayerDataManager.tilePosition);
            }
        }
Exemple #25
0
        static public void InitAssets(Minijam32 game)
        {
            tileSheet = game.Content.Load <Texture2D>("res/tile/general");

            typeSourceRect = new Dictionary <TileData.Type, Vector2>
            {
                { TileData.Type.FloorDirtLight, new Vector2(TileData.TileSize.X * 0, TileData.TileSize.Y * 0) },
                { TileData.Type.FloorDirtMediumPlain, new Vector2(TileData.TileSize.X * 1, TileData.TileSize.Y * 0) },
                { TileData.Type.FloorDirtDark, new Vector2(TileData.TileSize.X * 2, TileData.TileSize.Y * 0) },

                { TileData.Type.BombOne, new Vector2(TileData.TileSize.X * 0, TileData.TileSize.Y * 1) },
                { TileData.Type.BombTwo, new Vector2(TileData.TileSize.X * 1, TileData.TileSize.Y * 1) },

                { TileData.Type.WallBricksContourFinished, new Vector2(TileData.TileSize.X * 0, TileData.TileSize.Y * 3) },
                { TileData.Type.WallBricksLeftFinished, new Vector2(TileData.TileSize.X * 1, TileData.TileSize.Y * 3) },
                { TileData.Type.WallBricksMiddleFinished, new Vector2(TileData.TileSize.X * 2, TileData.TileSize.Y * 3) },
                { TileData.Type.WallBricksRightFinished, new Vector2(TileData.TileSize.X * 3, TileData.TileSize.Y * 3) },
                { TileData.Type.WallBricksTopNarrow, new Vector2(TileData.TileSize.X * 4, TileData.TileSize.Y * 3) },
                { TileData.Type.WallBricksTopLeft, new Vector2(TileData.TileSize.X * 5, TileData.TileSize.Y * 3) },
                { TileData.Type.WallBricksTopCenter, new Vector2(TileData.TileSize.X * 6, TileData.TileSize.Y * 3) },
                { TileData.Type.WallBricksTopRight, new Vector2(TileData.TileSize.X * 7, TileData.TileSize.Y * 3) },
                { TileData.Type.WallBricksTopLowCornerNarrow, new Vector2(TileData.TileSize.X * 8, TileData.TileSize.Y * 3) },
                { TileData.Type.WallBricksTopLowCornerLeft, new Vector2(TileData.TileSize.X * 9, TileData.TileSize.Y * 3) },
                { TileData.Type.WallBricksTopLowCornerRight, new Vector2(TileData.TileSize.X * 10, TileData.TileSize.Y * 3) },
                { TileData.Type.WallBricksTopHighCornerNarrow, new Vector2(TileData.TileSize.X * 11, TileData.TileSize.Y * 3) },
                { TileData.Type.WallBricksTopHighCornerLeft, new Vector2(TileData.TileSize.X * 12, TileData.TileSize.Y * 3) },
                { TileData.Type.WallBricksTopHighCornerRight, new Vector2(TileData.TileSize.X * 13, TileData.TileSize.Y * 3) },

                { TileData.Type.FloorWaterStillSimple, new Vector2(TileData.TileSize.X * 0, TileData.TileSize.Y * 4) },
                { TileData.Type.FloorWaterEdgeWallNarrow, new Vector2(TileData.TileSize.X * 1, TileData.TileSize.Y * 4) },
                { TileData.Type.FloorWaterEdgeWallLeft, new Vector2(TileData.TileSize.X * 2, TileData.TileSize.Y * 4) },
                { TileData.Type.FloorWaterEdgeWallCenter, new Vector2(TileData.TileSize.X * 3, TileData.TileSize.Y * 4) },
                { TileData.Type.FloorWaterEdgeWallRight, new Vector2(TileData.TileSize.X * 4, TileData.TileSize.Y * 4) },
                { TileData.Type.FloorWaterEdgeNarrow, new Vector2(TileData.TileSize.X * 5, TileData.TileSize.Y * 4) },
                { TileData.Type.FloorWaterEdgeLeft, new Vector2(TileData.TileSize.X * 6, TileData.TileSize.Y * 4) },
                { TileData.Type.FloorWaterEdgeRight, new Vector2(TileData.TileSize.X * 7, TileData.TileSize.Y * 4) },
                { TileData.Type.FloorWaterEdgeCornerNarrow, new Vector2(TileData.TileSize.X * 8, TileData.TileSize.Y * 4) },
                { TileData.Type.FloorWaterEdgeCornerLeft, new Vector2(TileData.TileSize.X * 9, TileData.TileSize.Y * 4) },
                { TileData.Type.FloorWaterEdgeCornerRight, new Vector2(TileData.TileSize.X * 10, TileData.TileSize.Y * 4) },

                { TileData.Type.RockBasic, new Vector2(TileData.TileSize.X * 0, TileData.TileSize.Y * 5) },
                { TileData.Type.RockFunky, new Vector2(TileData.TileSize.X * 1, TileData.TileSize.Y * 5) },
                { TileData.Type.RockBlues, new Vector2(TileData.TileSize.X * 2, TileData.TileSize.Y * 5) },
                { TileData.Type.RockProg, new Vector2(TileData.TileSize.X * 3, TileData.TileSize.Y * 5) },
                { TileData.Type.RockHard, new Vector2(TileData.TileSize.X * 4, TileData.TileSize.Y * 5) },
                { TileData.Type.RockBread, new Vector2(TileData.TileSize.X * 5, TileData.TileSize.Y * 5) },
                { TileData.Type.RockGrave, new Vector2(TileData.TileSize.X * 6, TileData.TileSize.Y * 5) },
                { TileData.Type.RockTurtle, new Vector2(TileData.TileSize.X * 7, TileData.TileSize.Y * 5) },

                { TileData.Type.RockBasicGold, new Vector2(TileData.TileSize.X * 0, TileData.TileSize.Y * 6) },
                { TileData.Type.RockFunkyGold, new Vector2(TileData.TileSize.X * 1, TileData.TileSize.Y * 6) },
                { TileData.Type.RockBluesGold, new Vector2(TileData.TileSize.X * 2, TileData.TileSize.Y * 6) },
                { TileData.Type.RockProgGold, new Vector2(TileData.TileSize.X * 3, TileData.TileSize.Y * 6) },
                { TileData.Type.RockHardGold, new Vector2(TileData.TileSize.X * 4, TileData.TileSize.Y * 6) },

                { TileData.Type.GoldBasic, new Vector2(TileData.TileSize.X * 0, TileData.TileSize.Y * 7) },
                { TileData.Type.GoldFunky, new Vector2(TileData.TileSize.X * 1, TileData.TileSize.Y * 7) },
                { TileData.Type.GoldBlues, new Vector2(TileData.TileSize.X * 2, TileData.TileSize.Y * 7) },
                { TileData.Type.GoldProg, new Vector2(TileData.TileSize.X * 3, TileData.TileSize.Y * 7) },
                { TileData.Type.GoldHard, new Vector2(TileData.TileSize.X * 4, TileData.TileSize.Y * 7) },

                { TileData.Type.ButtonRed, new Vector2(TileData.TileSize.X * 0, TileData.TileSize.Y * 8) },
                { TileData.Type.ButtonYellow, new Vector2(TileData.TileSize.X * 1, TileData.TileSize.Y * 8) },
                { TileData.Type.ButtonBlue, new Vector2(TileData.TileSize.X * 2, TileData.TileSize.Y * 8) },

                { TileData.Type.ButtonRedPressed, new Vector2(TileData.TileSize.X * 0, TileData.TileSize.Y * 9) },
                { TileData.Type.ButtonYellowPressed, new Vector2(TileData.TileSize.X * 1, TileData.TileSize.Y * 9) },
                { TileData.Type.ButtonBluePressed, new Vector2(TileData.TileSize.X * 2, TileData.TileSize.Y * 9) },

                { TileData.Type.ColorWallRed, new Vector2(TileData.TileSize.X * 0, TileData.TileSize.Y * 11) },
                { TileData.Type.ColorWallYellow, new Vector2(TileData.TileSize.X * 1, TileData.TileSize.Y * 11) },
                { TileData.Type.ColorWallBlue, new Vector2(TileData.TileSize.X * 2, TileData.TileSize.Y * 11) },

                { TileData.Type.Ice, new Vector2(TileData.TileSize.X * 0, TileData.TileSize.Y * 12) },
                { TileData.Type.NewLevelHole, new Vector2(TileData.TileSize.X * 0, TileData.TileSize.Y * 13) },

                { TileData.Type.PassableWallRoofComplete, new Vector2(TileData.TileSize.X * 0, TileData.TileSize.Y * 2) },
                { TileData.Type.PassableWallRoofLeft, new Vector2(TileData.TileSize.X * 1, TileData.TileSize.Y * 2) },
                { TileData.Type.PassableWallRoofMiddle, new Vector2(TileData.TileSize.X * 2, TileData.TileSize.Y * 2) },
                { TileData.Type.PassableWallRoofRight, new Vector2(TileData.TileSize.X * 3, TileData.TileSize.Y * 2) },

                { TileData.Type.ColorWallTopRed, new Vector2(TileData.TileSize.X * 0, TileData.TileSize.Y * 10) },
                { TileData.Type.ColorWallTopYellow, new Vector2(TileData.TileSize.X * 1, TileData.TileSize.Y * 10) },
                { TileData.Type.ColorWallTopBlue, new Vector2(TileData.TileSize.X * 2, TileData.TileSize.Y * 10) },

                { TileData.Type.ColorWallRemainderRed, new Vector2(TileData.TileSize.X * 0, TileData.TileSize.Y * 14) },
                { TileData.Type.ColorWallRemainderYellow, new Vector2(TileData.TileSize.X * 1, TileData.TileSize.Y * 14) },
                { TileData.Type.ColorWallRemainderBlue, new Vector2(TileData.TileSize.X * 2, TileData.TileSize.Y * 14) },

                { TileData.Type.NewWallTopToBeRemoved, new Vector2(TileData.TileSize.X * 15, TileData.TileSize.Y * 3) },

                //Those are unreachable in editor
                { TileData.Type.CharacterDeathDown, new Vector2(TileData.TileSize.X * 0, TileData.TileSize.Y * 15) },
                { TileData.Type.CharacterDeathRight, new Vector2(TileData.TileSize.X * 1, TileData.TileSize.Y * 15) },
                { TileData.Type.CharacterDeathUp, new Vector2(TileData.TileSize.X * 2, TileData.TileSize.Y * 15) },
                { TileData.Type.CharacterDeathLeft, new Vector2(TileData.TileSize.X * 3, TileData.TileSize.Y * 15) },
            };
        }
Exemple #26
0
        public void Update(Minijam32 game)
        {
            //If player at point, then advance
            if (PlayerDataManager.tilePosition == this.TeleportPoint)
            {
                if (currentLevelId >= maxLevelId)
                {
                    hasCompletedLastLevel = true;
                    return;
                }

                currentLevelId++;
                this.ReInitializeLevelData(currentLevelId);
                game.screenPool.StartNewLevelDelay(game.musicPlayer);
            }

            //Update logic for colored plates
            RedPlatePressed    = false;
            YellowPlatePressed = false;
            BluePlatePressed   = false;
            for (int x = 0; x < tileGrid.GetLength(0); x++)
            {
                for (int y = 0; y < tileGrid.GetLength(1); y++)
                {
                    if (tileGrid[x, y].type == TileData.Type.ButtonRed && new Point(x, y) == PlayerDataManager.tilePosition)
                    {
                        RedPlatePressed = true;
                        tileGrid[x, y].PressPlate();
                    }
                    if (tileGrid[x, y].type == TileData.Type.ButtonBlue && new Point(x, y) == PlayerDataManager.tilePosition)
                    {
                        BluePlatePressed = true;
                        tileGrid[x, y].PressPlate();
                    }
                    if (tileGrid[x, y].type == TileData.Type.ButtonYellow && new Point(x, y) == PlayerDataManager.tilePosition)
                    {
                        YellowPlatePressed = true;
                        tileGrid[x, y].PressPlate();
                    }
                }
            }

            //Then it's walls:
            for (int x = 0; x < tileGrid.GetLength(0); x++)
            {
                for (int y = 0; y < tileGrid.GetLength(1); y++)
                {
                    if (RedPlatePressed && tileGrid[x, y].type == TileData.Type.ColorWallRed)
                    {
                        tileGrid[x, y - 1].RemoveColoredWallTopping();
                        tileGrid[x, y].FlattenColoredWall();
                    }
                    if (BluePlatePressed && tileGrid[x, y].type == TileData.Type.ColorWallBlue)
                    {
                        tileGrid[x, y - 1].RemoveColoredWallTopping();
                        tileGrid[x, y].FlattenColoredWall();
                    }
                    if (YellowPlatePressed && tileGrid[x, y].type == TileData.Type.ColorWallYellow)
                    {
                        tileGrid[x, y - 1].RemoveColoredWallTopping();
                        tileGrid[x, y].FlattenColoredWall();
                    }
                }
            }

            //Bombs go boom
            var bombsDeleteLocations = new List <Point> {
            };
            var iterCollection       = new List <Point>(this.plantedBombs.Keys);

            foreach (var location in iterCollection)
            {
                this.plantedBombs[location] -= Minijam32.DeltaUpdate;
                if (this.plantedBombs[location] <= 0)
                {
                    bombsDeleteLocations.Add(location);

                    Animator.NewBombAnimation(location - new Point(1, 1));
                    SoundPlayer.PlaySound(SoundPlayer.Type.BombExplosion);

                    //TODO: boooooom tiles
                    this.tileGrid[location.X, location.Y].Destroy();
                    this.tileGrid[location.X - 1, location.Y].Destroy();
                    this.tileGrid[location.X + 1, location.Y].Destroy();
                    this.tileGrid[location.X, location.Y - 1].Destroy();
                    this.tileGrid[location.X, location.Y + 1].Destroy();
                }
            }

            //Enemy go places
            var enemyDeadList = new List <EnemyAI> {
            };

            foreach (var enemy in enemies)
            {
                //Update AI
                enemy.Update(game);

                //Check if enemy is at any exploding bombs
                foreach (var location in bombsDeleteLocations)
                {
                    if ((enemy.currentPos - location).ToVector2().Length() <= 1)
                    {
                        enemy.Damage();
                    }
                }

                //If enemy is dead, mark it
                if (enemy.isDead)
                {
                    enemyDeadList.Add(enemy);
                    SoundPlayer.PlaySound(SoundPlayer.Type.BatDead);
                }

                //Check if enemy is touching the hero
                if (enemy.currentPos == PlayerDataManager.tilePosition)
                {
                    PlayerDataManager.Damage();
                }
            }

            //Heal point heals player. Then disapperear
            List <Point> removeHealDrops = new List <Point> {
            };

            foreach (var healPoint in this.healDrops)
            {
                if (healPoint == PlayerDataManager.tilePosition)
                {
                    PlayerDataManager.Heal();
                    removeHealDrops.Add(healPoint);
                    Animator.RemoveHeart(healPoint);
                }
            }

            //After we've done the job, let's remove the old junk
            foreach (var location in bombsDeleteLocations)
            {
                //To save cycles, we're checking for self-harm there for each explosion
                if ((PlayerDataManager.tilePosition - location).ToVector2().Length() <= 1)
                {
                    PlayerDataManager.Damage();
                }

                this.plantedBombs.Remove(location);
            }
            foreach (var enemy in enemyDeadList)
            {
                //On each dying enemy, there's a slight chance of spawning heal pts
                if (Minijam32.Rand.Next(100) <= enemyHealthDropChance)
                {
                    this.healDrops.Add(enemy.currentPos);
                    Animator.AddHeartAnimation(enemy.currentPos);
                }

                this.enemies.Remove(enemy);
            }
            foreach (var point in removeHealDrops)
            {
                if (healDrops.Contains(point))
                {
                    healDrops.Remove(point);
                }
            }
        }
Exemple #27
0
 private static bool IsThisNewPosOkay(Minijam32 game, Point newPos)
 {
     return(!TileData.IsSolid(game.levelData.tileGrid[newPos.X, newPos.Y].type) && !game.levelData.IsBombAtThisPosition(newPos) && !game.levelData.IsEnemyThere(newPos));
 }
Exemple #28
0
 public static void LoadAssets(Minijam32 game)
 {
     batAnim = new Animation(game, "res/mob/bat_right", 16, Minijam32.Scale, 50);
     batAnim.EnableDrawing();
 }
Exemple #29
0
 abstract public void Draw(Minijam32 game, SpriteBatch spriteBatch);