Example #1
0
        byte MiniScreen.Update(GameTime gameTime, KeyboardState prevStateKb, MouseState prevStateM)
        {
            if(speaking)
                hud.Update(gameTime, prevStateKb, prevStateM);
            if (hud.IsWaiting() || hud.isFinished() && hud.visible)
                talkingNPC.CloseMouth();

            HandleInput(gameTime);

            mapRenderer.Update(tMap, gameTime);

            menu.Update(gameTime, prevState, Mouse.GetState(), 0, 0);

            if (!speaking)
            {
                world.Step((float)gameTime.ElapsedGameTime.TotalSeconds);
                player.Update(gameTime, false);
                foreach (NPC n in npcs)
                {
                    if(Keyboard.GetState().IsKeyDown(Keys.Space) && prevState.IsKeyUp(Keys.Space))
                        if (n.body.LinearVelocity == Vector2.Zero && n.touchingPlayer)
                        {
                            //Make a check here to ensure the player is facing the NPC
                            if (player.getStateH() == Player.HorizontalState.Left && n.touchingRight || player.getStateH() == Player.HorizontalState.Right && n.touchingLeft || player.getStateV() == Player.VerticalState.Up && n.touchingDown || player.getStateV() == Player.VerticalState.Down && n.touchingUp)
                            {
                                talkingNPC = n;
                                n.speaking = true;
                                n.FacePlayer(player.getStateH(), player.getStateV());
                                speaking = true;
                                hud = new Hud(n.messages, cont, n.textWidth, n.textHeight);
                            }
                        }

                    n.Update(gameTime);
                }

            }
            else
            {
                player.Update(gameTime, true);
                foreach (NPC n in npcs)
                    n.Update(gameTime);
                if (hud.messageComplete())
                {
                    speaking = false;
                    talkingNPC.ResetSpeaking();
                    //foreach (NPC n in npcs)
                        //n.ResetSpeaking();
                }
            }

            //camera.Position = new Vector2(player.body.Position.X - 400 / 2, player.body.Position.Y - 240 / 2 + 16);
            prevState = Keyboard.GetState();
            AdjustCamera();
            InsertionSortEntities();

            return 1;
        }