コード例 #1
0
ファイル: Room.cs プロジェクト: Gaiadin/Dank
        public void AddContent(UserControlledSprite player)
        {
            if (location == new Point(26, 26))
            {
                //Victory
                String content = "    Contratiations, brav warriar.  You have proofed yourself a true" + Environment.NewLine +
                                 "     hero.  Not manny could have fought there way thrugh this dank," + Environment.NewLine +
                                 "   dangerous dungeon and livved too tell the tail.  You're exploits" + Environment.NewLine +
                                 "    will be told thrugh the anals of history.  Bards will sing of" + Environment.NewLine +
                                 "     your glourius deeds.  Thou you still have not found an exit," + Environment.NewLine +
                                 "      no that you're efforts were not in vane.  There is a piece" + Environment.NewLine +
                                 "     of chalk on the ground where you may right your name. If you" + Environment.NewLine +
                                 "    are lucky, someone will see it someday and be like \"whoa, this" + Environment.NewLine +
                                 "   dude made it all the way through.\" and then all that cool stuff" + Environment.NewLine +
                                 "    I said earlier about the bards and your exploits will probably" + Environment.NewLine +
                                 "                                  happen." + Environment.NewLine +
                                 "                         Thank you for playing Dank!" + Environment.NewLine +
                                 "                           Press Enter to Exit Game";
                Game1.WON = true;
                UI.ShowDialogue(content, 13, 70);
            }
            else
            {
                player.Difficulty = difficulty;

                if (items.Count > 0)//Items in room
                {
                    List <Item> tItems = new List <Item>(items);
                    foreach (Item i in tItems)
                    {
                        if (player.AddItem(i))
                        {
                            items.Remove(i);
                        }
                        else
                        {
                            UI.ShowMessage("Inventory Full");
                            return;
                        }
                    }
                }
            }
        }
コード例 #2
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);
        }