Exemple #1
0
        public void playUpdate()
        {
            if (zone1good.State != SoundState.Playing && zone1bad.State != SoundState.Playing)
            {
                zone1good.Play();
                zone1bad.Play();
            }

            time++;
            newKeyBoardState = Keyboard.GetState();
            IsMouseVisible = false;
            if (worldState)
            {
                GraphicsDevice.Clear(Color.CornflowerBlue);
            }
            else
            {
                GraphicsDevice.Clear(Color.Black);
            }
            foreach (Miscellanious m in miscObjects)
            {
                m.onUpdate();
            }
            foreach (Creature c in creatures)
            {
                c.move();
            }
            foreach (UpdateMiscellanious i in updateMiscObjects)
            {
                i.move();
            }
            //update particles and remove dead ones
            ArrayList particlesToRemove = new ArrayList();
            foreach (Particle p in particles)
            {
                p.update();
                if (p.getLifetime() <= 0)
                {
                    particlesToRemove.Add(p);
                }
            }
            foreach (Particle q in particlesToRemove)
            {
                particles.Remove(q);
            }
            player.moveUpdate();

            checkCollisions();

            cam.update();
            //boxUpdate();
            inventoryUpdate();

            if (shiftCooldown > 0)
            {
                shiftCooldown--;
            }
            if (player.isDead())
            {
                if (!playerGhost.isActive())
                {
                    playerGhost.setX(player.getX());
                    playerGhost.setY(player.getY());
                    playerGhost.activate();
                }
                playerGhost.move();
                //uncomment these two for standard no-animation death
                //gameState = "lost";
                //IsMouseVisible = true;
            }

            if (playerGhost.getTimeAlive() <= 0)
            {
                gameState = "lost";
                //game cursor works now so should be fine
                //IsMouseVisible = true;
                playerGhost.reset();
            }

            if (((newKeyBoardState.IsKeyDown(Keys.Escape) && !oldKeyBoardState.IsKeyDown(Keys.Escape)) || (newKeyBoardState.IsKeyDown(Keys.P) && !oldKeyBoardState.IsKeyDown(Keys.P))) && !player.isReadingChalkboard())
            {
                gameState = "pause";
            }
            else if (newKeyBoardState.IsKeyDown(Keys.A) && !oldKeyBoardState.IsKeyDown(Keys.A) && !player.isReadingChalkboard())
            {
                gameState = "about";
            }
            else if (newKeyBoardState.IsKeyDown(Keys.R) && !oldKeyBoardState.IsKeyDown(Keys.R) && !player.isReadingChalkboard())
            {
                reloadLevel();
            }
            else if (newKeyBoardState.IsKeyDown(Keys.I) && !oldKeyBoardState.IsKeyDown(Keys.I) && !player.isReadingChalkboard())
            {
                showInventory = !showInventory;
            }

            if (winCondition() && !boatSpawned())
            {

                Boat boat = new Boat(40 * 32, 28 * 32, new Point(28 * 32, 28 * 32));
                Game1.updateMiscObjects.Add(boat);
                //hubLevel.addLevelItem(boat);
            }

            oldKeyBoardState = newKeyBoardState;
        }
Exemple #2
0
        public override void reportCollision(Object o)
        {
            if (o is Platform)
            {
                if(!hasBeenOnPlatform)
                {
                    engine.setState("textbox", "platform");
                    hasBeenOnPlatform = true;
                }

            }
            if (o is Boat && !onBoat)
            {
                onBoat = true;
                myBoat = (Boat)o;
                myBoat.setMotion(2);
            }

            if (o is DogBoogieman)
            {
                if (!o.getState())
                {
                    proportion = 0;
                }
            }
            if ((o is Ghost) && (!o.getState()))
            {
                damageProportion(0.3);
            }
            if(o is ChalkboardTop)
            {

                if(!readingChalkboard)
                {
                    collideChalkboard = (ChalkboardTop)o;
                    playerChalkboard = new Chalkboard(0, 0, collideChalkboard.getGate());
                    Game1.updateMiscObjects.Add(playerChalkboard);
                }
                readingChalkboard = true;

            }
            if(o is BoxTop)
            {
                if(!accessingBox)
                {
                    playerBox = ((BoxTop)o).getBox();
                    Game1.updateMiscObjects.Add(playerBox);
                    collideBoxtop = (BoxTop)o;

                }
                accessingBox = true;
            }

            if(o.getSolid())
            {
                //currentlyMove = false;
            }

            base.reportCollision(o);
            if(o is FlowerTentacles && !o.getState())
            {
                //proportion -= 0.001;
                damageProportion(0.2);
            }
            if (o is Item)
            {
                if(o is Diary)
                {
                    engine.setState("textbox", "diaryExposition");
                }
                if(o is Knife)
                {
                    engine.setState("textbox", "knifeExposition");
                }
                if(o is Rose)
                {
                    engine.setState("textbox", "roseExposition");
                }

                pickUp((Item)o);
                Textures.sounds["pickup"].Play();
            }
            if (o is GoodTile)
            {
                if (!state)
                {
                    engine.switchStates();
                }
            }
            if(o is BadTile)
            {
                if (state)
                {
                    engine.switchStates();
                }
            }
            if (o is LockTile)
            {
                if (stateLocked == false)
                    Textures.sounds["lock"].Play();
                stateLocked = true;
                if(!hasBeenLocked)
                {
                    engine.setState("textbox", "shiftLock");
                    hasBeenLocked = true;
                }

            }
            if(o is UnlockTile)
            {
                if (stateLocked == true)
                    Textures.sounds["unlock"].Play();
                stateLocked = false;

            }
            if(o is LevelTile)
            {
                if(this.x == o.getX() && this.y == o.getY())
                {
                    engine.setLevel(((LevelTile)o));
                    //engine.saveGame(((LevelTile)o));
                }
            }
        }