예제 #1
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);
        }
예제 #2
0
        public void NewSpawn()
        {
            int     monCheck  = 0;
            int     itemCheck = 0;
            Vector2 enemyStart;

            for (int i = 0; i <= 26; i++)
            {
                for (int j = 0; j <= 26; j++)
                {
                    if ((i != 0 && j != 0) || (i != 26 && j != 26))
                    {
                        if (i < player.CurrentRoom.Location.X - 2 || i > player.CurrentRoom.Location.X + 2 || j < player.CurrentRoom.Location.Y - 2 || j > player.CurrentRoom.Location.Y + 2)
                        {
                            monCheck = rand.Next(1500);
                            if (monCheck == 1)
                            {
                                enemyStart = new Vector2(i, j);
                                enemies.Add(new AutomatedSprite(Game.Content.Load <Texture2D>(@"Images/rabite"), enemyStart));
                                if (floor[enemyStart.X, enemyStart.Y].AddContent(enemies[enemies.Count - 1]))
                                {
                                    enemies[enemies.Count - 1].Animations.AddAnimation("idle", 0, 0, 30, 41, 11, 0.1f);
                                    enemies[enemies.Count - 1].Animations.Scale = 2f;
                                    setDifficulty(enemies[enemies.Count - 1]);
                                }
                                else
                                {
                                    enemies.Remove(enemies[enemies.Count - 1]);
                                }
                            }
                            if (monCheck == 2)
                            {
                                enemyStart = new Vector2(i, j);
                                enemies.Add(new WraithChaserSprite(Game.Content.Load <Texture2D>(@"Images/ghost"), enemyStart));
                                if (floor[enemyStart.X, enemyStart.Y].AddContent(enemies[enemies.Count - 1]))
                                {
                                    enemies[enemies.Count - 1].Animations.AddAnimation("idle", 0, 0, 16, 30, 7, 0.1f);
                                    enemies[enemies.Count - 1].Animations.AddAnimation("walkup", 0, 120, 16, 30, 5, 0.1f);
                                    enemies[enemies.Count - 1].Animations.AddAnimation("walkright", 0, 60, 16, 30, 5, 0.1f);
                                    enemies[enemies.Count - 1].Animations.AddAnimation("walkdown", 0, 30, 16, 30, 5, 0.1f);
                                    enemies[enemies.Count - 1].Animations.AddAnimation("walkleft", 0, 90, 16, 30, 5, 0.1f);
                                    enemies[enemies.Count - 1].Animations.Scale = 2f;
                                    setDifficulty(enemies[enemies.Count - 1]);
                                }
                                else
                                {
                                    enemies.Remove(enemies[enemies.Count - 1]);
                                }
                            }
                            if (monCheck == 3)
                            {
                                enemyStart = new Vector2(i, j);
                                enemies.Add(new ChaserSprite(Game.Content.Load <Texture2D>(@"Images/player"), enemyStart));
                                if (floor[enemyStart.X, enemyStart.Y].AddContent(enemies[enemies.Count - 1]))
                                {
                                    enemies[enemies.Count - 1].Animations.AddAnimation("idle", 60, 0, 20, 33, 3, 0.3f);
                                    enemies[enemies.Count - 1].Animations.Scale = 2f;
                                    setDifficulty(enemies[enemies.Count - 1]);
                                }
                                else
                                {
                                    enemies.Remove(enemies[enemies.Count - 1]);
                                }
                            }
                            itemCheck = rand.Next(2000);
                            if (itemCheck == 1)
                            {
                                floor[i, j].AddContent(ItemList.Get("Energy Potion"));
                            }
                            if (itemCheck == 2)
                            {
                                floor[i, j].AddContent(ItemList.Get("Potion"));
                            }
                            itemCheck = rand.Next(3000);
                            if (i > 8 || j > 8)
                            {
                                if (itemCheck == 1)
                                {
                                    floor[i, j].AddContent(ItemList.Get("Stoneskin Potion"));
                                    Console.WriteLine("def" + i + " " + j);
                                }
                                if (itemCheck == 2)
                                {
                                    floor[i, j].AddContent(ItemList.Get("Elixir of Strength"));
                                    Console.WriteLine("str" + i + " " + j);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #3
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);
        }