Beispiel #1
0
        public override void Update(GameTime gameTime, Rectangle clientBounds, Floor floor, UserControlledSprite player, Random rand)
        {
            //turnTaken = true;
            if (Turn && !turnTaken)
            {
                dir = rand.Next(1, 5);
                //Console.WriteLine("dir " + dir);

                //checking up
                if (Location.Y != 0)
                {
                    if (dir == 1)
                    {
                        if (floor[Location.X, Location.Y - 1].moveRequest(this))
                        {
                            CurrentRoom.removeContents(this);
                            distance    = 300;
                            Location    = new Point(Location.X, Location.Y - 1);
                            CurrentRoom = floor[Location.X, Location.Y];
                            CurrentRoom.addContents(this);
                        }
                    }
                }
                //checking right
                if (Location.X != 27)
                {
                    if (dir == 2)
                    {
                        if (floor[Location.X + 1, Location.Y].moveRequest(this))
                        {
                            CurrentRoom.removeContents(this);
                            distance    = 300;
                            Location    = new Point(Location.X + 1, Location.Y);
                            CurrentRoom = floor[Location.X, Location.Y];
                            CurrentRoom.addContents(this);
                        }
                    }
                }
                //checking down
                if (Location.Y != 27)
                {
                    if (dir == 3)
                    {
                        if (floor[Location.X, Location.Y + 1].moveRequest(this))
                        {
                            CurrentRoom.removeContents(this);
                            distance    = 300;
                            Location    = new Point(Location.X, Location.Y + 1);
                            CurrentRoom = floor[Location.X, Location.Y];
                            CurrentRoom.addContents(this);
                        }
                    }
                }
                //checking left
                if (Location.X != 0)
                {
                    if (dir == 4)
                    {
                        if (floor[Location.X - 1, Location.Y].moveRequest(this))
                        {
                            CurrentRoom.removeContents(this);
                            distance    = 300;
                            Location    = new Point(Location.X - 1, Location.Y);
                            CurrentRoom = floor[Location.X, Location.Y];
                            CurrentRoom.addContents(this);
                        }
                    }
                }
                turnTaken = true;
            }


            if (distance == 0)
            {
                if (turnTaken)
                {
                    changeTurn(false);
                }
                if (Animations.CurrentAnimation != "idle")
                {
                    Animations.CurrentAnimation = "idle";
                }
            }


            if (distance > 0)
            {
                if (dir == 1)
                {
                    Position = new Point(Position.X, Position.Y - 5);
                }
                if (dir == 2)
                {
                    Position = new Point(Position.X + 5, Position.Y);
                }
                if (dir == 3)
                {
                    Position = new Point(Position.X, Position.Y + 5);
                }
                if (dir == 4)
                {
                    Position = new Point(Position.X - 5, Position.Y);
                }
                distance -= 5;
            }
            CurrentRoom = floor[Location.X, Location.Y];
            base.Update(gameTime, clientBounds, floor);
        }
Beispiel #2
0
        public override void Update(GameTime gameTime, Rectangle clientBounds, Floor floor, SpriteManager spriteManager)
        {
            if (Game1.PAUSED)
            {
                base.Update(gameTime, clientBounds, floor);

                return;
            }

            if (!turnTaken && Turn)
            {
                Game1.BATTLE = spriteManager.BattleChecker();
                //oldState = Keyboard.GetState();
            }
            if (distance == 0 && rotation == 0)
            {
                if (Animations.CurrentAnimation != "idle")
                {
                    Animations.CurrentAnimation = "idle";
                }

                if (turnTaken && Turn)
                {
                    if (!rotated && rotationEnergy < rotationEnergyMax)
                    {
                        rotationEnergy += 1;
                    }
                    if (buffs.Count > 0)
                    {
                        for (int i = 0; i < buffs.Count; i++)
                        {
                            buffs[i].Duration--;
                            if (buffs[i].Duration == 0)
                            {
                                RemoveBuff(buffs[i]);
                            }
                        }
                    }
                    CurrentRoom = floor[Location.X, Location.Y];
                    CurrentRoom.AddContent(this);
                    spriteManager.NewSpawn();
                    //Console.WriteLine("end of turn");
                    Game1.BATTLE = spriteManager.BattleChecker();
                    if (CurrentRoom.Enemies.Count == 0)
                    {
                        changeTurn(false);
                        rotated = false;
                    }
                }

                if (Turn && !Game1.BATTLE)
                {
                    oldState = UpdateInput(oldState, floor, spriteManager);
                }
            }
            if (rotation > 0)
            {
                rotation -= 5;
            }
            if (distance > 0)
            {
                if (dir == 1)
                {
                    Position = new Point(Position.X, Position.Y - 5);
                }
                if (dir == 2)
                {
                    Position = new Point(Position.X + 5, Position.Y);
                }
                if (dir == 3)
                {
                    Position = new Point(Position.X, Position.Y + 5);
                }
                if (dir == 4)
                {
                    Position = new Point(Position.X - 5, Position.Y);
                }
                distance -= 5;
            }

            base.Update(gameTime, clientBounds, floor);
        }
Beispiel #3
0
        protected override void LoadContent()
        {
            audioEngine = new AudioEngine(@"Content\Audio\GameAudio.xgs");
            waveBank    = new WaveBank(audioEngine, @"Content\Audio\Wave Bank.xwb");
            soundBank   = new SoundBank(audioEngine, @"Content\Audio\Sound Bank.xsb");
            wFont       = Game.Content.Load <SpriteFont>(@"Images/font");
            UI.SetupUI(Game.Content.Load <Texture2D>(@"Images/windowbg"), Game.Content.Load <Texture2D>(@"Images/windowfg"), Game.Content.Load <Texture2D>(@"Images/selection"), wFont);
            #region ITEMS
            //**ITEM CREATION** **ITEM CREATION** **ITEM CREATION**
            Item item;
            item             = new Item(Game.Content.Load <Texture2D>(@"Images/chest"));
            item.Name        = "Potion";
            item.Value       = 10;
            item.Effect      = 5;
            item.Uses        = 3;
            item.Description = "Restores 5 health";
            ItemList.Add(item.Name, item);
            item             = new Item(Game.Content.Load <Texture2D>(@"Images/chest"));
            item.Name        = "Energy Potion";
            item.Description = "Restores 5 Rotation Energy";
            item.Value       = 20;
            item.Effect      = 5;
            item.Uses        = 2;
            ItemList.Add(item.Name, item);
            item             = new Item(Game.Content.Load <Texture2D>(@"Images/chest"));
            item.Name        = "Elixir of Strength";
            item.Description = "Increase Strength for 5 turns";
            item.Value       = 50;
            item.Effect      = 5;
            item.Buff        = new Buff("strength", 5, 5);
            item.Uses        = 1;
            ItemList.Add(item.Name, item);
            item             = new Item(Game.Content.Load <Texture2D>(@"Images/chest"));
            item.Name        = "Stoneskin Potion";
            item.Description = "Increase Defense for 5 turns";
            item.Value       = 50;
            item.Effect      = 5;
            item.Buff        = new Buff("defense", 5, 5);
            item.Uses        = 1;
            ItemList.Add(item.Name, item);
            //**END ITEM CREATION** **END ITEM CREATION** **END ITEM CREATION**
            #endregion
            spriteBatch = new SpriteBatch(Game.GraphicsDevice);
            camera      = new Camera(Game.Window.ClientBounds);
            battleBG    = Game.Content.Load <Texture2D>(@"Images/battleBG");

            font     = Game.Content.Load <SpriteFont>(@"Images/font");
            rotFont  = Game.Content.Load <SpriteFont>(@"Images/font");
            gameOver = Game.Content.Load <SpriteFont>(@"Images/gameover");
            floor    = new Floor();
            int     itemCheck;
            Vector2 enemyStart;
            for (int i = 0; i <= 26; i++)
            {
                for (int j = 0; j <= 26; j++)
                {
                    floor[i, j] = new Room(Game.Content.Load <Texture2D>(@"Images/dungeonrooms"),
                                           new Point(400, 400), .75f, new Vector2(i * 300, j * 300), rand, i, j);
                    if ((i != 0 && j != 0) || (i != 26 && j != 26))
                    {
                        itemCheck = rand.Next(15);
                        if (itemCheck == 1)
                        {
                            floor[i, j].AddContent(ItemList.Get("Energy Potion"));
                        }
                        if (itemCheck == 2)
                        {
                            floor[i, j].AddContent(ItemList.Get("Potion"));
                        }
                        itemCheck = rand.Next(100);
                        if (i > 8 || j > 8)
                        {
                            if (itemCheck == 1)
                            {
                                floor[i, j].AddContent(ItemList.Get("Stoneskin Potion"));
                            }
                            if (itemCheck == 2)
                            {
                                floor[i, j].AddContent(ItemList.Get("Elixir of Strength"));
                            }
                        }
                    }
                }
            }


            player = new UserControlledSprite(Game.Content.Load <Texture2D>(@"Images/herowalk"), Vector2.Zero);
            player.Animations.AddAnimation("idle", 0, 140, 23, 35, 1, 0.3f);
            player.Animations.AddAnimation("walkleft", 0, 0, 23, 35, 6, 0.15f);
            player.Animations.AddAnimation("walkright", 0, 35, 23, 35, 6, 0.15f);
            player.Animations.AddAnimation("walkdown", 0, 70, 23, 35, 6, 0.15f);
            player.Animations.AddAnimation("walkup", 0, 105, 23, 35, 6, 0.15f);
            player.Animations.AddAnimation("fight", 0, 180, 68, 36, 3, 0.15f);
            player.Animations.AddAnimation("victory", 0, 217, 26, 35, 7, 0.15f);
            player.Animations.Scale = 2f;
            floor[0, 0].AddContent(player);
            player.CurrentRoom = floor[0, 0];

            for (int i = 0; i < 100; i++)
            {
                enemyStart = new Vector2(rand.Next(1, 27), rand.Next(1, 27));
                enemies.Add(new ChaserSprite(Game.Content.Load <Texture2D>(@"Images/player"), enemyStart));
                if (floor[enemyStart.X, enemyStart.Y].AddContent(enemies[i]))
                {
                    enemies[i].Animations.AddAnimation("idle", 60, 0, 20, 33, 3, 0.3f);
                    enemies[i].Animations.Scale = 2f;
                    enemies[i].index            = i;
                    setDifficulty(enemies[i]);
                }
                else
                {
                    enemies.Remove(enemies[i]);
                    i--;
                }
            }
            for (int i = 100; i < 200; i++)
            {
                enemyStart = new Vector2(rand.Next(1, 27), rand.Next(1, 27));
                enemies.Add(new AutomatedSprite(Game.Content.Load <Texture2D>(@"Images/rabite"), enemyStart));
                if (floor[enemyStart.X, enemyStart.Y].AddContent(enemies[i]))
                {
                    enemies[i].Animations.AddAnimation("idle", 0, 0, 30, 41, 11, 0.1f);
                    enemies[i].Animations.Scale = 2f;
                    setDifficulty(enemies[i]);
                }
                else
                {
                    enemies.Remove(enemies[i]);
                    i--;
                }
            }
            for (int i = 200; i < 300; i++)
            {
                enemyStart = new Vector2(rand.Next(1, 27), rand.Next(1, 27));
                enemies.Add(new WraithChaserSprite(Game.Content.Load <Texture2D>(@"Images/ghost"), enemyStart));
                if (floor[enemyStart.X, enemyStart.Y].AddContent(enemies[i]))
                {
                    enemies[i].Animations.AddAnimation("idle", 0, 0, 16, 30, 7, 0.1f);
                    enemies[i].Animations.AddAnimation("walkup", 0, 120, 16, 30, 5, 0.1f);
                    enemies[i].Animations.AddAnimation("walkright", 0, 60, 16, 30, 5, 0.1f);
                    enemies[i].Animations.AddAnimation("walkdown", 0, 30, 16, 30, 5, 0.1f);
                    enemies[i].Animations.AddAnimation("walkleft", 0, 90, 16, 30, 5, 0.1f);
                    enemies[i].Animations.Scale = 2f;
                    setDifficulty(enemies[i]);
                }
                else
                {
                    enemies.Remove(enemies[i]);
                    i--;
                }
            }


            floor[1, 0].AddContent(ItemList.Get("Energy Potion"));
            floor[1, 0].AddContent(ItemList.Get("Potion"));

            //enemyStart = new Point(3, 3);
            //enemies.Add(new WraithChaserSprite(Game.Content.Load<Texture2D>(@"Images/player"), enemyStart));
            //enemies[0].Animations.AddAnimation("idle", 60, 0, 20, 33, 3, 0.3f);
            //enemies[0].Animations.Scale = 2f;
            //floor[enemyStart.X, enemyStart.Y].AddContent(enemies[0]);
            Game1.Volume   = .3f;
            Game1.SEVolume = 1f;
            String content = "Welcome to Dank.  Actually, it's not really a very welcoming place." + Environment.NewLine +
                             "It's full of monsters that get more difficult the deeper you delve," + Environment.NewLine +
                             "but delve deep you must!  For your salvation lies in the bottom-" + Environment.NewLine +
                             "right room.  You may rotate your own room or those adjacent to it." + Environment.NewLine +
                             "Press H for a list of the game's controls.";
            UI.ShowDialogue(content, 5, 70);
        }
Beispiel #4
0
        private KeyboardState UpdateInput(KeyboardState oldState, Floor floor, SpriteManager spriteManager)
        {
            KeyboardState newState = Keyboard.GetState();

            //checking if at the top of the map
            if (Location.Y != 0)
            {
                if (oldState.IsKeyDown(Keys.Up) && !(newState.IsKeyDown(Keys.Up)))
                {
                    dir = 1;
                    move(floor, new Vector2(0, 1));
                }
            }
            //checking right
            if (Location.X != 26)
            {
                if (oldState.IsKeyDown(Keys.Right) && !(newState.IsKeyDown(Keys.Right)))
                {
                    dir = 2;
                    move(floor, new Vector2(-1, 0));
                }
            }
            //checking down
            if (Location.Y != 26)
            {
                if (oldState.IsKeyDown(Keys.Down) && !(newState.IsKeyDown(Keys.Down)))
                {
                    dir = 3;
                    move(floor, new Vector2(0, -1));
                }
            }
            //checking left
            if (Location.X != 0)
            {
                if (oldState.IsKeyDown(Keys.Left) && !(newState.IsKeyDown(Keys.Left)))
                {
                    dir = 4;
                    move(floor, new Vector2(1, 0));
                }
            }
            if (oldState.IsKeyDown(Keys.Enter) && !(newState.IsKeyDown(Keys.Enter)))
            {
                //ROTATE ADJACENT ROOMS

                if (newState.IsKeyDown(Keys.A) && Location.X > 0 && rotationEnergy >= 5)
                {
                    rotate(floor, spriteManager, new Vector2(1, 0));
                }
                else if (newState.IsKeyDown(Keys.D) && Location.X < 26 && rotationEnergy >= 5)
                {
                    rotate(floor, spriteManager, new Vector2(-1, 0));
                }
                else if (newState.IsKeyDown(Keys.W) && Location.Y > 0 && rotationEnergy >= 5)
                {
                    rotate(floor, spriteManager, new Vector2(0, 1));
                }
                else if (newState.IsKeyDown(Keys.S) && Location.Y < 26 && rotationEnergy >= 5)
                {
                    rotate(floor, spriteManager, new Vector2(0, -1));
                }
                else if ((newState.GetPressedKeys().Length == 0) && rotationEnergy >= 2)
                {
                    //Rotate current room
                    rotate(floor, spriteManager, Vector2.Zero);
                }
                //else
                //spriteManager.PlayCue("error");
            }

            if (oldState.IsKeyDown(Keys.Back) && !(newState.IsKeyDown(Keys.Back)) && level >= 5)
            {
                if (newState.IsKeyDown(Keys.A) && Location.X > 0)
                {
                    if (SubtractEnergy(10))
                    {
                        CurrentRoom.AddExit(4);
                        floor[Location.X - 1, Location.Y].AddExit(2);
                    }
                }
                else if (newState.IsKeyDown(Keys.D) && Location.X < 26)
                {
                    if (SubtractEnergy(10))
                    {
                        CurrentRoom.AddExit(2);
                        floor[Location.X + 1, Location.Y].AddExit(4);
                    }
                }
                else if (newState.IsKeyDown(Keys.W) && Location.Y > 0)
                {
                    if (SubtractEnergy(10))
                    {
                        CurrentRoom.AddExit(1);
                        floor[Location.X, Location.Y - 1].AddExit(3);
                    }
                }
                else if (newState.IsKeyDown(Keys.S) && Location.Y < 26)
                {
                    if (SubtractEnergy(10))
                    {
                        CurrentRoom.AddExit(3);
                        floor[Location.X, Location.Y + 1].AddExit(1);
                    }
                }
            }
            //if (oldState.IsKeyDown(Keys.Delete) && !(newState.IsKeyDown(Keys.Delete)))
            //{
            //    if (newState.IsKeyDown(Keys.A) && Location.X > 0)
            //    {
            //        CurrentRoom.RemoveExit(4);
            //        floor[Location.X - 1, Location.Y].RemoveExit(2);
            //    }
            //    else if (newState.IsKeyDown(Keys.D) && Location.X < 26)
            //    {
            //        CurrentRoom.RemoveExit(2);
            //        floor[Location.X + 1, Location.Y].RemoveExit(4);
            //    }
            //    else if (newState.IsKeyDown(Keys.W) && Location.Y > 0)
            //    {
            //        CurrentRoom.RemoveExit(1);
            //        floor[Location.X, Location.Y - 1].RemoveExit(3);
            //    }
            //    else if (newState.IsKeyDown(Keys.S) && Location.Y < 26)
            //    {
            //        CurrentRoom.RemoveExit(3);
            //        floor[Location.X, Location.Y + 1].RemoveExit(1);
            //    }

            //}
            if (oldState.IsKeyDown(Keys.Home) && !(newState.IsKeyDown(Keys.Home)))
            {
                SpriteManager.SkipTurn = !SpriteManager.SkipTurn;
            }
            if (oldState.IsKeyDown(Keys.E) && !(newState.IsKeyDown(Keys.E)))
            {
                Item check = checkInventory(ItemList.Get("Energy Potion"));
                if (check != null)
                {
                    check.Use(this);
                }
            }
            if (oldState.IsKeyDown(Keys.P) && !(newState.IsKeyDown(Keys.P)))
            {
                Item check = checkInventory(ItemList.Get("Potion"));
                if (check != null)
                {
                    check.Use(this);
                }
            }
            //if (oldState.IsKeyDown(Keys.F) && !newState.IsKeyDown(Keys.F))
            //{
            //    AddItem(ItemList.Get("Elixir of Strength"));
            //    AddItem(ItemList.Get("Stoneskin Potion"));
            //}
            if (oldState.IsKeyDown(Keys.Escape) && !newState.IsKeyDown(Keys.Escape))
            {
                SpriteManager.ShowOptions();
            }
            if (oldState.IsKeyDown(Keys.Space) && !newState.IsKeyDown(Keys.Space))
            {
                turnTaken = true;
            }
            if (oldState.IsKeyDown(Keys.I) && !newState.IsKeyDown(Keys.I))
            {
                ShowInventory();
            }
            if (oldState.IsKeyDown(Keys.C) && !newState.IsKeyDown(Keys.C))
            {
                ShowStatus();
            }
            if (oldState.IsKeyDown(Keys.H) && !newState.IsKeyDown(Keys.H))
            {
                UI.ShowMessage("Controls:  ");
                UI.ShowMessage("Skip Turn: SPACE  Quick Use Energy Potion: E  Quick Use Potion: P");
                UI.ShowMessage("Status: C  Inventory: I  Volume Controls: ESC  Help: H  Move: ARROWS");
                UI.ShowMessage("Rotate Room: ENTER  Rotate Adjacent room: W,A,S,D + ENTER");
                UI.ShowMessage("Rotating rooms consumes your energy. 2 for your room, 5 for adjacent");
                if (level >= 5)
                {
                    UI.ShowMessage("(Level 5)Alternate Exit blasts a hole into an adjacent room");
                    UI.ShowMessage("Alternate Exit: W,A,S,D + BACKSPACE  Costs 10 energy");
                }
            }
            oldState = newState;
            return(oldState);
        }