Ejemplo n.º 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");



            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");
            floor       = new Floor();
            Point enemyStart;

            for (int i = 0; i <= 27; i++)
            {
                for (int j = 0; j <= 27; 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);
                }
            }

            player = new UserControlledSprite(Game.Content.Load <Texture2D>(@"Images/herowalk"), new Point(0, 0));
            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.Scale = 2f;
            floor[0, 0].addContents(player);

            for (int i = 0; i < 500; i++)
            {
                enemyStart = new Point(rand.Next(1, 27), rand.Next(1, 27));
                enemies.Add(new AutomatedSprite(Game.Content.Load <Texture2D>(@"Images/player"), enemyStart));
                enemies[i].Animations.AddAnimation("idle", 60, 0, 20, 33, 3, 0.3f);
                enemies[i].Animations.Scale = 2f;
                floor[enemyStart.X, enemyStart.Y].addContents(enemies[i]);
            }
            for (int i = 500; i < 1000; i++)
            {
                enemyStart = new Point(rand.Next(1, 27), rand.Next(1, 27));
                enemies.Add(new AutomatedSprite(Game.Content.Load <Texture2D>(@"Images/rabite"), enemyStart));
                enemies[i].Animations.AddAnimation("idle", 0, 0, 30, 41, 11, 0.1f);
                enemies[i].Animations.Scale = 2f;
                floor[enemyStart.X, enemyStart.Y].addContents(enemies[i]);
            }

            //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].addContents(enemies[0]);
        }
Ejemplo n.º 2
0
Archivo: Item.cs Proyecto: Gaiadin/Dank
 public int Use(UserControlledSprite player)
 {
     if (type == "consumable")
     {
         if (Name == "Potion")
         {
             if (player.Health < player.HealthMax)
             {
                 SpriteManager.PlayCue("use");
                 player.AddHealth(this.effect);
                 uses -= 1;
             }
         }
         if (Name == "Energy Potion")
         {
             if (player.RotationEnergy < player.RotationEnergyMax)
             {
                 SpriteManager.PlayCue("use");
                 player.RotationEnergy += Effect;
                 if (player.RotationEnergy > player.RotationEnergyMax)
                 {
                     player.RotationEnergy = player.RotationEnergyMax;
                 }
                 uses -= 1;
             }
         }
         if (Name == "Elixir of Strength")
         {
             if (!player.CheckBuffs(buff))
             {
                 SpriteManager.PlayCue("use");
                 player.AddBuff(buff);
                 uses--;
             }
         }
         if (Name == "Stoneskin Potion")
         {
             if (!player.CheckBuffs(buff))
             {
                 SpriteManager.PlayCue("use");
                 player.AddBuff(buff);
                 uses--;
             }
         }
         if (uses <= 0)
         {
             player.Inventory.Remove(this);
             Console.WriteLine("Consumable Gone");
         }
         return(uses);
     }
     return(-1);
 }
Ejemplo n.º 3
0
Archivo: Room.cs Proyecto: 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;
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public void Use(UserControlledSprite player)
 {
     if (Name == "Potion")
     {
         //Code for potion
     }
     if (Name == "Energy Potion")
     {
         if (player.RotationEnergy < player.RotationEnergyMax)
         {
             player.RotationEnergy += Effect;
             if (player.RotationEnergy > player.RotationEnergyMax)
             {
                 player.RotationEnergy = player.RotationEnergyMax;
             }
             uses -= 1;
         }
     }
     if (uses <= 0)
     {
         player.Inventory.Remove(this);
     }
 }
Ejemplo n.º 5
0
 public void Update(GameTime gameTime, UserControlledSprite player)
 {
     center    = new Vector2(player.Position.X, player.Position.Y);
     transform = Matrix.CreateTranslation(view.X - player.Position.X + 100, view.Y - player.Position.Y - 125, 0f);
 }
Ejemplo n.º 6
0
 public virtual void Update(GameTime gameTime, Rectangle clientBounds, Floor floor, UserControlledSprite player, Random rand)
 {
     animations.Update(gameTime);
 }
Ejemplo n.º 7
0
        public override void Update(GameTime gameTime, Rectangle clientBounds, Floor floor, UserControlledSprite player, Random rand)
        {
            //turnTaken = true;
            if (Turn && !turnTaken)
            {
                CurrentRoom = floor[Location.X, Location.Y];
                if (player.Difficulty == Difficulty)
                {
                    float xDif = player.Location.X - Location.X;
                    float yDif = player.Location.Y - Location.Y;

                    if (Math.Abs(xDif) > Math.Abs(yDif)) //If player is farther in X than Y
                    {
                        //Try to move X
                        if (xDif > 0) //Right
                        {
                            move(2, floor);
                        }
                        else  //Left
                        {
                            move(4, floor);
                        }
                    }
                    if (Math.Abs(xDif) < Math.Abs(yDif)) // Farther on Y than X
                    {
                        if (yDif > 0)                    //Down
                        {
                            move(3, floor);
                        }
                        else //Up
                        {
                            move(1, floor);
                        }
                    }
                    if (Math.Abs(xDif) == Math.Abs(yDif)) //Same distance X and Y
                    {
                        if (xDif > 0)                     //Right
                        {
                            move(2, floor);
                        }
                        else if (xDif < 0) //Left
                        {
                            move(4, floor);
                        }
                        else if (yDif > 0) //Down
                        {
                            move(3, floor);
                        }
                        else //Up
                        {
                            move(1, floor);
                        }
                    }
                }

                if (!(distance > 0))
                {
                    do
                    {
                        dir = rand.Next(1, 5);
                        //Console.WriteLine("dir " + dir);
                        if (!(dir == lastDir))
                        {
                            lastDir = dir;
                            move(dir, floor);
                        }
                        count += 1;
                        //Console.WriteLine("Count " + count);
                        //Console.WriteLine("Distance " + distance);
                    } while (!(distance > 0) && count <= 10);
                }
                if (!(distance > 0))
                {
                    lastDir = 0;
                    noMove  = true;
                }
                if (!center)
                {
                    centerDistance = 20; centering = oldCentering;
                }
                turnTaken = true;
            }


            if (Turn)                   //Cycled until turn is over
            {
                if (centerDistance > 0) //Sprite needs to move towards center
                {
                    Offset += centering;
                    centerDistance--;
                    //Console.WriteLine(index + " Offset: " + Offset + " Rate: " + centering + " EnemyCount: " + CurrentRoom.EnemyCount);
                    if (centerDistance == 0)
                    {
                        center = true;
                    }
                }
                if (center && distance > 0) //Sprite has moved to middle of room and is ready to move to new room
                {
                    if (this is WraithChaserSprite)
                    {
                        this.Animations.Tint = StaticTint * .2f;
                    }
                    if (dir == 1)
                    {
                        if (this is WraithChaserSprite && Animations.CurrentAnimation != "walkup")
                        {
                            Animations.CurrentAnimation = "walkup";
                        }
                        Position = new Point(Position.X, Position.Y - 5);
                    }
                    if (dir == 2)
                    {
                        if (this is WraithChaserSprite && Animations.CurrentAnimation != "walkright")
                        {
                            Animations.CurrentAnimation = "walkright";
                        }
                        Position = new Point(Position.X + 5, Position.Y);
                    }
                    if (dir == 3)
                    {
                        if (this is WraithChaserSprite && Animations.CurrentAnimation != "walkdown")
                        {
                            Animations.CurrentAnimation = "walkdown";
                        }
                        Position = new Point(Position.X, Position.Y + 5);
                    }
                    if (dir == 4)
                    {
                        if (this is WraithChaserSprite && Animations.CurrentAnimation != "walkleft")
                        {
                            Animations.CurrentAnimation = "walkleft";
                        }
                        Position = new Point(Position.X - 5, Position.Y);
                    }
                    distance--;
                    if (distance == 0) //Sprite is in center of new room
                    {
                        outsideDistance = 20;
                        center          = false;
                        centering       = getRate(CurrentRoom.Enemies.IndexOf(this));
                        oldCentering    = centering; //Always go back the same way it came
                    }
                }
                if (noMove && center) // Didn't change rooms but still in the center
                {
                    outsideDistance = 20;
                    center          = false;
                    centering       = getRate(CurrentRoom.Enemies.IndexOf(this));
                    oldCentering    = centering; //Always go back the same way it came
                }
                if (outsideDistance > 0)         //Sprite has moved into the new room but the turn isn't over
                {
                    if (this is WraithChaserSprite)
                    {
                        this.Animations.Tint = StaticTint * .5f;
                    }
                    Offset += -centering;
                    outsideDistance--;
                }
                if (outsideDistance == 0 && distance == 0 && centerDistance == 0) //END OF TURN Sprite has changed rooms and walked to its offset
                {
                    //Console.WriteLine("Turn End " + index + " Offset: " + Offset + " Rate: " + centering + " EnemyCount: " + CurrentRoom.EnemyCount);
                    if (Animations.CurrentAnimation != "idle")
                    {
                        Animations.CurrentAnimation = "idle";
                    }
                    changeTurn(false);
                }
            }

            base.Update(gameTime, clientBounds, floor);
        }
Ejemplo n.º 8
0
        public override void Update(GameTime gameTime, Rectangle clientBounds, Floor floor, UserControlledSprite player, Random rand)
        {
            if (Turn && !turnTaken) //Once per turn
            {
                CurrentRoom = floor[Location.X, Location.Y];
                dir         = rand.Next(1, 5);                               //Choose direction
                if (dir == 1 && Location.Y != 0)                             //Up and not at top
                {
                    if (floor[Location.X, Location.Y - 1].moveRequest(this)) //Allowed to move up
                    {
                        distance = 60;
                        newLoc   = new Vector2(0, -1);
                    }
                }
                if (dir == 2 && Location.X != 26)                            //Right and not at right edge
                {
                    if (floor[Location.X + 1, Location.Y].moveRequest(this)) //Allowed to move right
                    {
                        distance = 60;
                        newLoc   = new Vector2(1, 0);
                    }
                }
                if (dir == 3 && Location.Y != 26) //Down and not at bottom edge
                {
                    if (floor[Location.X, Location.Y + 1].moveRequest(this))
                    {
                        distance = 60;
                        newLoc   = new Vector2(0, 1);
                    }
                }
                if (dir == 4 && Location.X != 0) //Down and not at bottom edge
                {
                    if (floor[Location.X - 1, Location.Y].moveRequest(this))
                    {
                        distance = 60;
                        newLoc   = new Vector2(-1, 0);
                    }
                }
                if (distance == 0)
                {
                    newLoc = Vector2.Zero;
                }
                else
                {
                    CurrentRoom.RemoveContent(this);
                    Location   += newLoc;
                    CurrentRoom = floor[Location.X, Location.Y];
                    CurrentRoom.AddContent(this);
                } //Remove from room if it is moving
                if (!center)
                {
                    centerDistance = 20; centering = oldCentering;
                }

                turnTaken = true;
            }//^^Once per turn^^

            if (Turn) //Cycled until turn is over
            {
                if (centerDistance > 0) //Sprite needs to move towards center
                {
                    Offset += centering;
                    centerDistance--;
                    //Console.WriteLine(index + " Offset: " + Offset + " Rate: " + centering + " EnemyCount: " + CurrentRoom.EnemyCount);
                    if (centerDistance == 0)
                    {
                        center = true;
                    }
                }
                if (center && distance > 0) //Sprite has moved to middle of room and is ready to move to new room
                {
                    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--;
                    if (distance == 0) //Sprite is in center of new room
                    {
                        outsideDistance = 20;
                        center          = false;
                        centering       = getRate(CurrentRoom.Enemies.IndexOf(this));
                        oldCentering    = centering; //Always go back the same way it came
                    }
                }
                if (newLoc == Vector2.Zero && center) // Didn't change rooms but still in the center
                {
                    outsideDistance = 20;
                    center          = false;
                    centering       = getRate(CurrentRoom.Enemies.IndexOf(this));
                    oldCentering    = centering; //Always go back the same way it came
                }
                if (outsideDistance > 0)         //Sprite has moved into the new room but the turn isn't over
                {
                    Offset += -centering;
                    outsideDistance--;
                }
                if (outsideDistance == 0 && distance == 0 && centerDistance == 0) //END OF TURN Sprite has changed rooms and walked to its offset
                {
                    //Console.WriteLine("Turn End " + index + " Offset: " + Offset + " Rate: " + centering + " EnemyCount: " + CurrentRoom.EnemyCount);
                    if (Animations.CurrentAnimation != "idle")
                    {
                        Animations.CurrentAnimation = "idle";
                    }
                    changeTurn(false);
                }
            }

            base.Update(gameTime, clientBounds, floor);
        }
Ejemplo n.º 9
0
        public override void Update(GameTime gameTime, Rectangle clientBounds, Floor floor, UserControlledSprite player, Random rand)
        {
            //turnTaken = true;
            if (Turn && !turnTaken)
            {
                if (player.Difficulty == Difficulty)
                {
                    int xDif = player.Location.X - Location.X;
                    int yDif = player.Location.Y - Location.Y;

                    if (Math.Abs(xDif) > Math.Abs(yDif)) //If player is farther in X than Y
                    {
                        //Try to move X
                        if (xDif > 0) //Right
                        {
                            move(2, floor);
                        }
                        else  //Left
                        {
                            move(4, floor);
                        }
                    }
                    if (Math.Abs(xDif) < Math.Abs(yDif)) // Farther on Y than X
                    {
                        if (yDif > 0)                    //Down
                        {
                            move(3, floor);
                        }
                        else //Up
                        {
                            move(1, floor);
                        }
                    }
                    if (Math.Abs(xDif) == Math.Abs(yDif)) //Same distance X and Y
                    {
                        if (xDif > 0)                     //Right
                        {
                            move(2, floor);
                        }
                        else if (xDif < 0) //Left
                        {
                            move(4, floor);
                        }
                        else if (yDif > 0) //Down
                        {
                            move(3, floor);
                        }
                        else //Up
                        {
                            move(1, floor);
                        }
                    }
                }

                if (!(distance > 0))
                {
                    do
                    {
                        dir = rand.Next(1, 5);
                        Console.WriteLine("dir " + dir);
                        if (!(dir == lastDir))
                        {
                            lastDir = dir;
                            move(dir, floor);
                        }
                        count += 1;
                        Console.WriteLine("Count " + count);
                        Console.WriteLine("Distance " + distance);
                    } while (!(distance > 0) && count <= 10);
                }
                if (!(distance > 0))
                {
                    lastDir = 0;
                }
                turnTaken = true;
            }


            if (distance == 0)
            {
                if (turnTaken)
                {
                    count = 0;
                    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);
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
0
 public static void Update(GameTime gameTime, UserControlledSprite player)
 {
     message.Update(gameTime, player);
     options.Update(gameTime, player);
     inventory.Update(gameTime, player);
 }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
0
        public void Update(GameTime gameTime, UserControlledSprite player)
        {
            if (wContent != "")
            {
                Game1.PAUSED = true;
                unpause      = false;
            }
            KeyboardState newState = Keyboard.GetState();

            volumePer += gameTime.ElapsedGameTime.Milliseconds;

            if (unpause)
            {
                pauseTime += gameTime.ElapsedGameTime.Milliseconds;
                if (pauseTime >= 200)
                {
                    Game1.PAUSED = false;
                    unpause      = false;
                    pauseTime    = 0;
                }
            }



            if (wType == "inventory")
            {
                Window description = new Window();
                if (wContent != "Empty")
                {
                    description = UI.ShowMessage(player.Inventory[wIndex].Description + "  Worth: " + player.Inventory[wIndex].Value.ToString(), new Point(this.wPosition.X + this.wPosition.Width + borderWidth * 2 + 5, this.wPosition.Y), "description");
                }

                setSelection();
                if (oldState.IsKeyDown(Keys.Up) && !newState.IsKeyDown(Keys.Up))
                {
                    if (wIndex != 0)
                    {
                        wIndex--;
                    }
                }
                if (oldState.IsKeyDown(Keys.Down) && !newState.IsKeyDown(Keys.Down))
                {
                    if (wIndex < wLines - 1)
                    {
                        wIndex++;
                    }
                }
                if (oldState.IsKeyDown(Keys.Enter) && !newState.IsKeyDown(Keys.Enter))
                {
                    //Use Item
                    if (wContent != "Empty")
                    {
                        if (player.UseItem(wIndex) <= 0 && wIndex != 0)
                        {
                            wIndex--;
                        }
                        player.ShowInventory();
                        if (wContent == "Empty")
                        {
                            description.closeWindow();
                        }
                    }
                }
                if (oldState.IsKeyDown(Keys.I) && !newState.IsKeyDown(Keys.I))
                {
                    closeWindow();
                    description.closeWindow();
                }
                if (oldState.IsKeyDown(Keys.Escape) && !newState.IsKeyDown(Keys.Escape))
                {
                    closeWindow();
                    description.closeWindow();
                }
            }
            else if (wType == "options")
            {
                setSelection();
                if (oldState.IsKeyDown(Keys.Up) && !newState.IsKeyDown(Keys.Up))
                {
                    if (wIndex != 0)
                    {
                        wIndex--;
                    }
                }
                if (oldState.IsKeyDown(Keys.Down) && !newState.IsKeyDown(Keys.Down))
                {
                    if (wIndex < wLines - 1)
                    {
                        wIndex++;
                    }
                }
                if (wIndex == 0) //Music
                {
                    if (newState.IsKeyDown(Keys.Left))
                    {
                        if (Game1.Volume > 0.0f || oldVolume > 0.0f)
                        {
                            if (volumePer >= volumeMax)
                            {
                                if (oldVolume > 0)
                                {
                                    Game1.Volume = oldVolume;
                                    oldVolume    = 0;
                                }
                                if (Game1.Volume > 0.0f)
                                {
                                    Game1.Volume -= .01f;
                                }
                                volumePer = 0;
                                SpriteManager.ShowOptions();
                            }
                        }
                    }
                    if (newState.IsKeyDown(Keys.Right))
                    {
                        if (Game1.Volume < 1.0f)
                        {
                            //volumePer += gameTime.ElapsedGameTime.Milliseconds;
                            if (volumePer >= volumeMax)
                            {
                                if (oldVolume > 0)
                                {
                                    Game1.Volume = oldVolume;
                                    oldVolume    = 0;
                                }
                                if (Game1.Volume < 1.0f)
                                {
                                    Game1.Volume += .01f;
                                }
                                volumePer = 0;
                                SpriteManager.ShowOptions();
                            }
                        }
                    }
                    if (oldState.IsKeyDown(Keys.Enter) && !newState.IsKeyDown(Keys.Enter))
                    {
                        if (oldVolume > 0)
                        {
                            Game1.Volume = oldVolume;
                            oldVolume    = 0f;
                            SpriteManager.ShowOptions();
                        }
                        else
                        {
                            oldVolume    = Game1.Volume;
                            Game1.Volume = 0.0f;
                            SpriteManager.ShowOptions();
                        }
                    }
                }
                else if (wIndex == 1)
                {
                    if (newState.IsKeyDown(Keys.Left))
                    {
                        if (Game1.SEVolume > 0.0f || oldSEVolume > 0.0f)
                        {
                            if (volumePer >= volumeMax)
                            {
                                if (oldSEVolume > 0)
                                {
                                    Game1.SEVolume = oldSEVolume;
                                    Game1.SE       = true;
                                    oldSEVolume    = 0;
                                }
                                if (Game1.SEVolume > 0.0f)
                                {
                                    Game1.SEVolume -= .01f;
                                }
                                volumePer = 0;
                                SpriteManager.SetVolumeSE();
                                SpriteManager.ShowOptions();
                            }
                        }
                    }
                    if (newState.IsKeyDown(Keys.Right))
                    {
                        if (Game1.SEVolume < 1.0f)
                        {
                            //volumePer += gameTime.ElapsedGameTime.Milliseconds;
                            if (volumePer >= volumeMax)
                            {
                                if (oldSEVolume > 0)
                                {
                                    Game1.SEVolume = oldSEVolume;
                                    Game1.SE       = true;
                                    oldSEVolume    = 0;
                                }
                                if (Game1.SEVolume < 1.0f)
                                {
                                    Game1.SEVolume += .01f;
                                }
                                volumePer = 0;
                                SpriteManager.SetVolumeSE();
                                SpriteManager.ShowOptions();
                            }
                        }
                    }
                    if (oldState.IsKeyDown(Keys.Enter) && !newState.IsKeyDown(Keys.Enter))
                    {
                        if (oldSEVolume > 0)
                        {
                            Game1.SEVolume = oldSEVolume;
                            Game1.SE       = !Game1.SE;
                            SpriteManager.ShowOptions();
                        }
                        else
                        {
                            oldSEVolume = Game1.SEVolume;
                            Game1.SE    = !Game1.SE;
                            SpriteManager.ShowOptions();
                        }
                    }
                }
                if (oldState.IsKeyDown(Keys.Escape) && !newState.IsKeyDown(Keys.Escape))
                {
                    closeWindow();
                }
            }
            if (wType == "message")
            {
                if (oldState.GetPressedKeys().Length > 0 && newState.GetPressedKeys().Length <= 0)
                {
                    closeWindow();
                }
            }
            if (wType == "status")
            {
                if (oldState.GetPressedKeys().Length > 0 && newState.GetPressedKeys().Length <= 0)
                {
                    closeWindow();
                }
            }
            if (wType == "shop")
            {
                setSelection();
                if (oldState.IsKeyDown(Keys.Up) && !newState.IsKeyDown(Keys.Up))
                {
                    if (wIndex != 0)
                    {
                        wIndex--;
                    }
                }
                if (oldState.IsKeyDown(Keys.Down) && !newState.IsKeyDown(Keys.Down))
                {
                    if (wIndex < wLines - 1)
                    {
                        wIndex++;
                    }
                }
                if (oldState.IsKeyDown(Keys.Enter) && !newState.IsKeyDown(Keys.Enter))
                {
                    if (wIndex == 0) //Buy
                    {
                    }
                    if (wIndex == 1) //Sell
                    {
                    }
                }
            }
            if (wType == "dialogue")
            {
                if (oldState.IsKeyDown(Keys.Escape) && !newState.IsKeyDown(Keys.Escape) && !Game1.WON)
                {
                    closeWindow();
                }
                if (newState.IsKeyDown(Keys.Enter) && contentIndex < wContent.Length)
                {
                    messageSpeedMax = 15;
                    speedText       = true;
                }
                if (!oldState.IsKeyUp(Keys.Enter) && newState.IsKeyUp(Keys.Enter) && contentIndex >= wContent.Length && !speedText)
                {
                    if (Game1.WON)
                    {
                        Game1.CLOSEGAME = true;
                    }
                    else
                    {
                        closeWindow();
                    }
                }
                if (!newState.IsKeyDown(Keys.Enter))
                {
                    messageSpeedMax = 50;
                    speedText       = false;
                }
            }
            oldState = newState;
        }