public override void OnInteract(BaseObject caller)
        {
            if (caller is Slime)
            {
                Damage(((Slime)caller).damage);
            }
            else if (caller is Walls)
            {
                bounds.X += -(int)vector.X;
                bounds.Y += -(int)vector.Y;
            }

            else if (caller is Doors)
            {
                Slime goblinQuestionmark = parent.SearchFirst <Slime>();
                if (((Doors)caller).enterable == true)
                {
                    if (((Doors)caller).direction == 2)
                    {
                        RoomShower.playerRoomY -= 1;
                        bounds = new Rectangle(7 * Walls.wallSize + 13, 7 * Walls.wallSize, bounds.Width, bounds.Height);
                    }
                    if (((Doors)caller).direction == 3)
                    {
                        RoomShower.playerRoomX += 1;
                        bounds = new Rectangle(1 * Walls.wallSize + 5, 4 * Walls.wallSize, bounds.Width, bounds.Height);
                    }
                    if (((Doors)caller).direction == 4)
                    {
                        RoomShower.playerRoomY += 1;
                        bounds = new Rectangle(7 * Walls.wallSize + 13, 1 * Walls.wallSize + 5, bounds.Width, bounds.Height);
                    }
                    if (((Doors)caller).direction == 5)
                    {
                        RoomShower.playerRoomX -= 1;
                        bounds = new Rectangle(13 * Walls.wallSize + 20, 4 * Walls.wallSize, bounds.Width, bounds.Height);
                    }

                    parent.RemoveObject <Projectile>();
                    parent.RemoveObject <Particle>();
                    parent.RemoveObject <Balloon>();

                    RoomShower.SpawnRoom();
                }
                else
                {
                    bounds.Location -= vector.ToPoint();
                }
            }
            else if (caller is Coin)
            {
                caller.destroy = true;
                Game1.coinCount++;
                totalXP += 200;
                Game1.coinPickupSfx.Play(0.5f, 0, 0);
            }
            else if (caller is TrapDoor)
            {
                ((TrapDoor)caller).EnterTrapDoor();
            }
            else if (caller is Purchasable)
            {
                if (Game1.coinCount >= ((Purchasable)caller).price && Game1.Key.IsPressed(Keys.E) && ((Purchasable)caller).cooldown.Triggered)
                {
                    Game1.coinCount -= ((Purchasable)caller).price;
                    ((Purchasable)caller).cooldown.ResetTimer();
                    ((Purchasable)caller).pickup.Effect(((Purchasable)caller).pickup.effID);
                    if (((Purchasable)caller).pickup.name != "Reroller")
                    {
                        caller.destroy = true;
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (Key.IsPressed(Keys.D1))
            {
                weaponHandler.ChangeWeapon(new Wand());
                playPressed = true;
            }
            else if (Key.IsPressed(Keys.D2))
            {
                weaponHandler.ChangeWeapon(new Pistol());
                playPressed = true;
            }


            if (Key.IsPressed(Keys.Back))
            {
                Exit();
            }

            if (!started)
            {
                TileHandler.GenerateTiles();
                SpawnCharacter();
                character          = objectHandler.SearchFirst <Character>();
                currentDoorTexture = doorTexture;

                ProcGen2.GenerateDungeon();
                Minimap.GenerateMinimap();

                Minimap.MinimapDebug();
                RoomShower.StartingThing();
                RoomShower.SpawnRoom();
                objectHandler.AddObject(new ReloadIndicator());
                if (!File.Exists("scores.txt"))
                {
                    File.Create("scores.txt");
                    Console.WriteLine("score file created");
                }
                started = true;
            }
            if (Character.life <= 0)
            {
                gameOver = true;
            }
            else
            {
                gameOver = false;
            }
            MagicMissile.maxMissiles = objectHandler.SearchFirst <Character>().level + 3;
            List <Slime> slimes = objectHandler.SearchArray <Slime>();

            //input
            var mouseState = Mouse.GetState();

            Key.Update(gameTime);
            mouseOneTap.Update(gameTime);
            if (Key.IsPressed(Keys.Tab))
            {
                showMiniMap = !showMiniMap;
            }

            // TODO: Add your update logic here
            objectHandler.Update(gameTime);
            heartManager.Update(gameTime);
            debugTimer.Update(gameTime);
            weaponHandler.Update(gameTime);

            foreach (MinimapRoom miniRoom in minirooms)
            {
                miniRoom.Update(gameTime);
            }
            base.Update(gameTime);
        }