Пример #1
0
 //constructor
 public Mugging(string name, string objective, string description, Vector2 start, Player player)
     : base(name, objective, description, start, player, WinCondition.EnemyDies, 0, 10)
 {
     mugger = new LivingEntity(new FloatRectangle(start.X, start.Y, MUGGER_WIDTH, MUGGER_WIDTH), Sprites.spritesDictionary["mugger"], 10);
     knife = new Weapon(20, 1, 3, "Knife", 1, 99);
     muggerAI = new LowAI(mugger);
     mugger.ai = muggerAI;
     entitites = new List<Entity.Entity>();
     entitites.Add(mugger);
     EnemyToKill = mugger;
     //manager.CurrentWorld.manager.AddEntity(mugger);
 }
Пример #2
0
 //Constructor
 public Quest(string name, string objective, string description, Vector2 start, Player player, WinCondition winCondition, int reward = 1, int cashReward = 10)
 {
     this.name = name;
     this.objective = objective;
     this.description = description;
     this.startPoint = start;
     this.Reward = reward;
     this.CashReward = cashReward;
     this.player = player;
     this.worldManager = Game1.Instance.worldManager;
     this.winCondition = winCondition;
     entitites = new List<Entity.Entity>();
     status = 0;
     entitiesLoaded = false;
 }
Пример #3
0
 //Constructor
 public Storyline(string name, string objective, string description, Vector2 StartPoint, Player player, WorldManager worldManager, WinCondition winCondition, int reward = 0, int cashReward = 0)
     : base(name, objective, description, StartPoint, player, winCondition, reward, cashReward)
 {
     quests = new List<Quest>();
 }
Пример #4
0
        /// <summary>
        /// loads a save file
        /// </summary>
        private void LoadSave()
        {
            Console.WriteLine(saveLoc);
            Stream inStream = null;
            BinaryReader input = null;

            try
            {
                //open the file for reading
                inStream = File.OpenRead(saveLoc);
                input = new BinaryReader(inStream);

                //red the file
                string world = input.ReadString();
                Console.WriteLine("World: " + world);
                int pX = input.ReadInt32();
                int pY = input.ReadInt32();
                Console.WriteLine("X, Y: " + pX + ", " + pY);
                int pHealth = input.ReadInt32();
                Console.WriteLine("Health: " + pHealth);
                int pCash = input.ReadInt32();
                Console.WriteLine("Cash: " + pCash);
                int pQuestPoints = input.ReadInt32();
                Console.WriteLine("QuestPoints: " + pQuestPoints);

                //read the quests
                int numQuests = input.ReadInt32();
                Console.WriteLine("Num quests: " + numQuests);
                object[,] quests = new object[numQuests,2];
                for(int i = 0; i < numQuests; i++)
                {
                    quests[i, 0] = input.ReadString();
                    Console.WriteLine("\tName: " + quests[i, 0]);
                    quests[i, 1] = input.ReadInt32();
                    Console.WriteLine("\tStatus: " + quests[i, 1]);
                }

                //read the inventory
                int numItems = input.ReadInt32();
                Console.WriteLine("Num Items: " + numItems);
                string[] items = new string[numItems];
                for(int i = 0 ; i < numItems; i++)
                {
                    items[i] = input.ReadString();
                    Console.WriteLine("\t" + items[i]);
                }

                int activeItem = input.ReadInt32();
                Console.WriteLine("Active Weapon: " + activeItem);

                //make the world
                if (MainGame.worldManager.worlds.ContainsKey(world))
                {
                    MainGame.worldManager.worlds[world] = LoadWorld(world);
                }
                else
                {
                    MainGame.worldManager.worlds.Add(world, LoadWorld(world));
                }

                //set the player in the world
                Player player = new Player(
                    new FloatRectangle(pX, pY, 32, 32),
                    Sprites.spritesDictionary["player"]
                    );
                player.Cash = pCash;
                player.health = pHealth;
                player.QuestPoints = pQuestPoints;

                MainGame.worldManager.CurrentWorld.manager.AddEntity(player);
                Game1.Instance.collisionManager.SwitchWorld();

                //load all of the quests in the quest file
                LoadQuests(MainGame.worldManager.worldQuests);

                //load the quest status
                string quest;
                QuestLog log = MainGame.worldManager.worldQuests;
                QuestLog pLog = player.log;
                for(int i = 0; i < numQuests; i++)
                {
                    quest = (string)quests[i,0];
                    if (log.ContainsQuest(quest))
                    {
                        pLog[quest] = log[quest];
                        pLog[quest].Status = (int)quests[i, 1];
                    }
                }

                //add new quests to quest log
                foreach(Quest newQuest in log)
                {
                    if(!pLog.ContainsQuest(newQuest))
                    {
                        pLog.Add(newQuest);
                    }
                }

                //load the items
                Item.Inventory inventory = player.inventory;
                Item.Item newItem;
                for(int i = 0; i < numItems; i++)
                {
                    string name = items[i];
                    //newItem.image = Sprites.spritesDictionary[newItem.name].Texture;
                    //figure out the save path
                    int startname = saveLoc.LastIndexOf('/') + 1;
                    int endname = saveLoc.LastIndexOf('.');
                    string filename = saveLoc.Substring(startname, endname - startname);
                    string directory = saveLoc.Substring(0, startname) + "/" + filename;
                    newItem = LoadItem(directory + "/" + name + ".item");
                    inventory.Add(newItem);
                }
                inventory.ActiveWeapon = activeItem;

                //add the player to the world
                MainGame.worldManager.CurrentWorld.manager.AddEntity(player);

                //add the player to the quests
                foreach(Quest loopQuest in MainGame.worldManager.worldQuests)
                {
                    loopQuest.player = player;
                }
            }
            catch(Exception e)
            {
                Console.WriteLine("Error reading file: " + e.Message);
                Console.WriteLine("Stack: \n\t" + e.StackTrace);
            }
            finally
            {
                if (input != null)
                    input.Close();
            }
        }
Пример #5
0
        public void Update(GameTime gameTime)
        {
            // Switch statement needed for on the fly texture loading
            // OTF texture loading will only be done for game generated textures, they will not be loaded from files!
            // Things that are loaded from texture files are found in spriteDicitionary.
            // (one exception is Font files, this will be fixed later on)
            switch (Game1.state)
            {
                case GameState.Menu:
                    //Controls.guiElements["mainMenu"].Update(gameTime);
                    break;

                case GameState.Pause:
                    //Controls.guiElements["pauseMenu"].Update(gameTime);
                    break;

                    // START FROM HERE

                case GameState.Inventory:
                    InventoryMenu inventoryMenu = Controls.guiElements["inventoryMenu"] as InventoryMenu;
                    if (!inventoryMenu.IsInventoryLoaded)
                    {
                        inventoryMenu.Load(player.inventory);
                        //inventoryMenu.LoadVisuals(mainGame.Content, graphics);
                        //inventoryMenu.Update(gameTime);
                    }

                    //Controls.guiElements["inventoryMenu"].Update(gameTime);
                    break;

                case GameState.FastTravel:
                    break;

                case GameState.Game:
                    // casting takes a lot of time, a way to check if user changed weapon??
                    // UI (health, current wep, other stuff)
                    //Controls.guiElements["livingEntityInfoUI"].Update(gameTime);

                    // WHAT IF PLAYER CHANGES WORLD (?) -Fixed?(Sean)
                    player = mainGame.worldManager.CurrentWorld.manager.GetPlayer();

                    // VV Very Slow VV
                    (Controls.guiElements["livingEntityInfoUI"] as LivingEntityInfoUI).LivingEntity = player;

                    if (player.inventory.ActiveWeapon >= 0)
                    {
                        (Controls.guiElements["weaponInfoUI"] as WeaponInfoUI).Item = player.inventory.EntityInventory[player.inventory.ActiveWeapon];
                        //Controls.guiElements["weaponInfoUI"].LoadVisuals(mainGame.Content, graphics);
                        Controls.guiElements["weaponInfoUI"].Update(gameTime);
                    }
                    else
                        (Controls.guiElements["weaponInfoUI"] as WeaponInfoUI).Item = null;

                    // PARTICLES
                    for (int i = 0; i < particles.Count; i++ )
                    {
                        if (particles[i].CurrentTime <= 0) // possible problems (?)
                            particles.Remove(particles[i]);
                        else
                            particles[i].Update(gameTime);
                    }

                    //Controls.guiElements["weaponInfoUI"].Update(gameTime);
                    //Controls.guiElements["livingEntityInfoUI"].Update(gameTime);
                    break;

                case GameState.QuestLog:

                    QuestLogUI questLogUI = Controls.guiElements["questLog"] as QuestLogUI;
                    if (!questLogUI.IsQuestLogLoaded)
                    {
                        questLogUI.Load(player.log);
                        //questLogUI.LoadVisuals(mainGame.Content, graphics);
                        //questLogUI.Update(gameTime);
                    }
                    //Controls.guiElements["questLog"]
                    /*
                    if(tempQuest == null)
                    {
                        tempQuest = new QuestUI();
                        tempQuest.Load(player.log.GetByStatus(1)[0]);
                        tempQuest.LoadVisuals(mainGame.Content, graphics);
                        tempQuest.Update(gameTime);
                    }
                     * */
                    break;

                case GameState.Shop:
                    break;

                case GameState.WeaponWheel:

                    WeaponWheelUIV2 weaponWheelUI = Controls.guiElements["weaponWheel"] as WeaponWheelUIV2;
                    if (!weaponWheelUI.IsInventoryLoaded)
                    {
                        weaponWheelUI.Load(player.inventory);
                        //weaponWheelUI.LoadVisuals(mainGame.Content, graphics);
                        //weaponWheelUI.Update(gameTime);
                    }
                    //Controls.guiElements["weaponWheel"].Update(gameTime);
                    //weapons come from holster
                    break;
            }

            // DO THIS FOR SPRITES AND OTHER MOVING THINGS
            // if the GUI is not visible, dont update it.
            foreach (KeyValuePair<string, Control> c in Controls.guiElements)
                if (c.Value.IsVisible) // or just loaded.
                    c.Value.Update(gameTime);

            for (int i = 0; i < dialogs.Count; i++)
            {
                if (dialogs[i].EventsCompleted == true) // possible problems (?)
                    dialogs.Remove(dialogs[i]);
                else
                    dialogs[i].Update(gameTime);
            }
        }
Пример #6
0
        /// <summary>
        /// Constructs RenderManager using a SpriteBatch object which will be used for drawing.
        /// </summary>
        /// <param name="spriteBatch">MonoGames SpriteBatch object.</param>
        /// <param name="graphics">MonoGames GraphicsDevice object.</param>
        /// <param name="mainGame">Game1 class to interact with other managers.</param>
        public RenderManager(SpriteBatch spriteBatch, GraphicsDevice graphics, WorldManager worldManager)
        {
            this.spriteBatch = spriteBatch;
            this.graphics = graphics;
            this.worldManager = worldManager;
            this.mainGame = Game1.Instance;

            particles = new List<Particle>();
            dialogs = new List<Dialog>();

            viewportHeight = graphics.Viewport.Height;
            viewportWidth = graphics.Viewport.Width;

            viewportDeltaWidth = 0;
            viewportDeltaHeight = 0;

            mainGame.Window.ClientSizeChanged += Window_ClientSizeChanged;

            //lastWep = -1;

            // WHAT IF PLAYER CHANGES WORLD (?)
            player = mainGame.worldManager.CurrentWorld.manager.GetPlayer();

            // Load all textures once (constructor will only be called once, so will this method)
            LoadTextures();
        }
Пример #7
0
        //Josiah S DeVizia, implemented world importation
        public WorldManager()
        {
            worlds = new Dictionary<String, World>();
            worldQuests = new QuestLog();
            //TODO: Load/Save worlds.
            current = "main";

            player = new Player(new FloatRectangle(384, 72, 32, 32), Sprites.spritesDictionary["player"]);

            player.inventory.ActiveWeapon = 0;

            if(!worlds.ContainsKey(current))
                worlds.Add(current, Game1.Instance.saveManager.LoadWorld(current));

            worlds["main"].manager.AddEntity(player);
            // DEBUG
            #region debug
            #if false

            LivingEntity mugger = new LivingEntity(new FloatRectangle(384, 150, 32, 32), Sprites.spritesDictionary["player"], 10);
            mugger.ai = new MidAI(mugger);
            mugger.inventory.Add(new Item.Weapon(50, 1, 10, "Bam", 100, 0.5));
            mugger.inventory.ActiveWeapon = 0;
            //mugger.interactData = new Entity.Entity.InteractionData(new List<String>() { "I bite my thumb at you, sir!" });
            worlds["main"].manager.AddEntity(mugger);

            //LivingEntity civvie = new LivingEntity(new FloatRectangle(384, 247, 32, 32), Sprites.spritesDictionary["player"], 4);
            //civvie.ai = new CivilianAI(civvie);
            //civvie.interactData = new Entity.Entity.InteractionData(new List<String>() { "pls no." });
            //worlds["main"].manager.AddEntity(civvie);

            worlds["main"].manager.AddEntity(player);

            Quest mugging = SaveManager.ParseQuest("./Content/Quests/Mugging.quest");
            mugging.SetAvailable();
            mugging.worldManager = this;
            player.log.Add(mugging);
            this.worldQuests.Add(mugging);
            mugging.player = player;

            Quest gunman = SaveManager.ParseQuest("./Content/Quests/Crazed Gunman.quest");
            gunman.SetAvailable();
            player.log.Add(gunman);
            this.worldQuests.Add(gunman);

            Quest war = SaveManager.ParseQuest("./Content/Quests/Gang war.quest");
            war.SetAvailable();
            player.log.Add(war);
            this.worldQuests.Add(war);

            Quest sniper = SaveManager.ParseQuest("./Content/Quests/Sniper.quest");
            sniper.SetAvailable();
            player.log.Add(sniper);
            this.worldQuests.Add(sniper);
            /*
            Quest sniper1 = SaveManager.ParseQuest("./Content/Quests/Sniper1.quest");
            sniper1.SetAvailable();
            player.log.Add(sniper1);
            this.worldQuests.Add(sniper1);

            Quest sniper2 = SaveManager.ParseQuest("./Content/Quests/Sniper2.quest");
            sniper2.SetAvailable();
            player.log.Add(sniper2);
            this.worldQuests.Add(sniper2);

            Quest sniper3 = SaveManager.ParseQuest("./Content/Quests/Sniper3.quest");
            sniper3.SetAvailable();
            player.log.Add(sniper3);
            this.worldQuests.Add(sniper3);

            Quest mugging1 = SaveManager.ParseQuest("./Content/Quests/Mugging1.quest");
            mugging1.SetAvailable();
            player.log.Add(mugging1);
            this.worldQuests.Add(mugging1);

            Quest mugging2 = SaveManager.ParseQuest("./Content/Quests/Mugging2.quest");
            mugging2.SetAvailable();
            player.log.Add(mugging2);
            this.worldQuests.Add(mugging2);

            Quest mugging3 = SaveManager.ParseQuest("./Content/Quests/Mugging3.quest");
            mugging3.SetAvailable();
            player.log.Add(mugging3);
            this.worldQuests.Add(mugging3);
            */
            /*
            Quest test = new Quest("Mugging", "Kill the mugger", "You are being attacked", new Vector2(100, 1000), player, this, WinCondition.EnemyDies, 4, 50);
            test.EnemyToKill = mugger;
            test.entitites.Add(mugger);
            test.Status = 1;
            player.log.Add(test);
             */
            #endif
            // need to fix fleemap lag before renabling the above.
            #endregion
            worldQuests = new QuestLog();
            spawnDaemon = new SpawnDaemon();
            spawnThread = new Thread(new ThreadStart(spawnDaemon.startDaemon));
        }
Пример #8
0
        public void Reset()
        {
            spawnThread.Abort();
            worlds = new Dictionary<String, World>();
            worldQuests = new QuestLog();

            //reset the worlds
            foreach(string key in worlds.Keys.ToList())
            {
                worlds[key] = Game1.Instance.saveManager.LoadWorld(key);
            }

            current = "main";

            player = new Player(new FloatRectangle(384, 72, 32, 32), Sprites.spritesDictionary["player"]);

            player.inventory.ActiveWeapon = 0;

            //reset player quest log
            for (int i = 0; i < player.log.Count; i++)
            {
                player.log[i] = SaveManager.ParseQuest(SaveManager.QUEST_DIRECTORY + player.log[i].Name + ".quest");
            }

            if (!worlds.ContainsKey(current))
                worlds.Add(current, Game1.Instance.saveManager.LoadWorld(current));

            worlds["main"].manager.AddEntity(player);

            worldQuests = new QuestLog();
            spawnDaemon = new SpawnDaemon();
            spawnThread = new Thread(new ThreadStart(spawnDaemon.startDaemon));
        }
Пример #9
0
        /// <summary>
        /// saves the game
        /// </summary>
        public void Save()
        {
            // Create a stream, then a writer
            Stream       outStream = null;
            BinaryWriter output    = null;

            try
            {
                if (!Directory.Exists("./Content/SaveFiles"))
                {
                    Directory.CreateDirectory("./Content/SaveFiles");
                }
                //initialize them
                outStream = File.OpenWrite(saveLoc);
                output    = new BinaryWriter(outStream);

                //Get the player
                Entity.Player player = MainGame.worldManager.CurrentWorld.manager.GetPlayer();

                //get the current world
                string world = MainGame.worldManager.CurrentWorldString;

                //get the player's stats
                int playerX      = player.location.IntX;
                int playerY      = player.location.IntY;
                int playerHealth = player.health;
                int pCash        = player.Cash;
                int pQuestPoints = player.QuestPoints;

                //get the quest statuses
                QuestLog log = player.log;
                object[,] questStatuses = new object[log.Count, 2];
                for (int i = 0; i < log.Count; i++)
                {
                    questStatuses[i, 0] = log[i].Name;
                    questStatuses[i, 1] = log[i].Status;
                }

                //get the items in the inventory
                List <string>  items     = new List <string>();
                Item.Inventory inventory = player.inventory;
                foreach (Item.Item item in inventory)
                {
                    items.Add(item.name);
                }

                //store all of the data in the file
                output.Write(world);
                output.Write(playerX);
                output.Write(playerY);
                output.Write(playerHealth);
                output.Write(pCash);
                output.Write(pQuestPoints);
                output.Write((Int32)log.Count);
                Console.WriteLine(log.Count);
                for (int i = 0; i < log.Count; i++)
                {
                    output.Write((string)questStatuses[i, 0]);
                    output.Write((int)questStatuses[i, 1]);
                }
                output.Write(items.Count);
                foreach (Item.Item item in inventory)
                {
                    if (SaveItem(item))
                    {
                        output.Write(item.name);
                    }
                }
                output.Write(inventory.ActiveWeapon);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error while saving the game: " + e.Message);
                Console.WriteLine("Stack: \n\t" + e.StackTrace);
            }
            finally
            {
                if (output != null)
                {
                    // Done writing
                    output.Close();
                }
            }
        }
Пример #10
0
        /// <summary>
        /// What happens with Update?
        /// </summary>
        public void HandleInput(KeyboardState keyState, MouseState mouseState, GameTime time)
        {
            player = Game1.Instance.worldManager.CurrentWorld.manager.GetPlayer();
            if (Game1.state == GameState.Game)
            {
                //Detects if the player wants to move
                #region Movement Input
                int speed = 4;

                //int deltaX = 0;
                //int deltaY = 0;

                //The following statements check the movement keys
                if (keyState.IsKeyDown(Keys.W))    //Move up
                {
                    //deltaY -= speed;
                    player.movement.Y = speed * -1;
                }
                if (keyState.IsKeyDown(Keys.A))    //move down
                {
                    //deltaX -= speed;
                    player.movement.X = speed * -1;
                }
                if (keyState.IsKeyDown(Keys.S))    //move left
                {
                    //deltaY += speed;
                    player.movement.Y = speed;
                }
                if (keyState.IsKeyDown(Keys.D))    //move right
                {
                    //deltaX += speed;
                    player.movement.X = speed;
                }

                if (player.movement.X == 0)
                {
                    if (player.movement.Y < 0)
                    {
                        player.direction = Entity.Direction.Up;
                    }
                    else if (player.movement.Y > 0)
                    {
                        player.direction = Entity.Direction.Down;
                    }
                }
                else if (player.movement.X < 0)
                {
                    if (player.movement.Y < 0)
                    {
                        player.direction = Entity.Direction.UpLeft;
                    }
                    else if (player.movement.Y == 0)
                    {
                        player.direction = Entity.Direction.Left;
                    }
                    else if (player.movement.Y > 0)
                    {
                        player.direction = Entity.Direction.DownLeft;
                    }
                }
                else
                {
                    if (player.movement.Y < 0)
                    {
                        player.direction = Entity.Direction.UpRight;
                    }
                    else if (player.movement.Y == 0)
                    {
                        player.direction = Entity.Direction.Right;
                    }
                    else if (player.movement.Y > 0)
                    {
                        player.direction = Entity.Direction.DownRight;
                    }
                }
                /*
                if (Game1.Instance.worldManager.CurrentWorld.tiles[(int)(player.location.X / GUI.Tile.SIDE_LENGTH)][(int)(player.location.Y / GUI.Tile.SIDE_LENGTH)] is GUI.Door)
                {
                    GUI.Door door = Game1.Instance.worldManager.CurrentWorld.tiles[(int)(player.location.X / GUI.Tile.SIDE_LENGTH)][(int)(player.location.Y / GUI.Tile.SIDE_LENGTH)] as GUI.Door;
                    Game1.Instance.worldManager.current = door.World;
                    player.location.X = door.Destination.X * GUI.Tile.SIDE_LENGTH;
                    player.location.Y = door.Destination.Y * GUI.Tile.SIDE_LENGTH;
                }*/
                #endregion

                Item.Weapon weapon = Game1.Instance.worldManager.CurrentWorld.manager.GetPlayer().inventory.GetEquippedPrimary();
                //Selects the weapon the player wants
                #region Quick Weapon Select
                if (keyState.IsKeyDown(Keys.D1))    //Quick Weapon Select
                {
                    weapon.Reloading = false;
                    player.lastShot = 0D;
                    player.inventory.ActiveWeapon = 1;
                }
                if (keyState.IsKeyDown(Keys.D2))    //Quick Weapon Select
                {
                    weapon.Reloading = false;
                    player.lastShot = 0D;
                    player.inventory.ActiveWeapon = 2;
                }
                if (keyState.IsKeyDown(Keys.D3))    //Quick Weapon Select
                {
                    weapon.Reloading = false;
                    player.lastShot = 0D;
                    player.inventory.ActiveWeapon = 3;
                }
                if (keyState.IsKeyDown(Keys.D4))    //Quick Weapon Select
                {
                    weapon.Reloading = false;
                    player.lastShot = 0D;
                    player.inventory.ActiveWeapon = 4;
                }
                if (keyState.IsKeyDown(Keys.D5))    //Quick Weapon Select
                {
                    weapon.Reloading = false;
                    player.lastShot = 0D;
                    player.inventory.ActiveWeapon = 5;
                }
                if (keyState.IsKeyDown(Keys.D6))    //Quick Weapon Select
                {
                    weapon.Reloading = false;
                    player.lastShot = 0D;
                    player.inventory.ActiveWeapon = 6;
                }
                if (keyState.IsKeyDown(Keys.D7))    //Quick Weapon Select
                {
                    weapon.Reloading = false;
                    player.lastShot = 0D;
                    player.inventory.ActiveWeapon = 7;
                }
                if (keyState.IsKeyDown(Keys.D8))    //Quick Weapon Select
                {
                    weapon.Reloading = false;
                    player.lastShot = 0D;
                    player.inventory.ActiveWeapon = 8;
                }
                if (keyState.IsKeyDown(Keys.D9))    //Quick Weapon Select
                {
                    weapon.Reloading = false;
                    player.lastShot = 0D;
                    player.inventory.ActiveWeapon = 9;
                }
                if (keyState.IsKeyDown(Keys.D0))    //Quick Weapon Select
                {
                    weapon.Reloading = false;
                    player.lastShot = 0D;
                    player.inventory.ActiveWeapon = 0;
                }
                #endregion

                player.cursor = mouseState.Position;

                // Douglas Gliner
                #region mouse aim (move to player?)

                // mouse location relative to CENTER OF SCREEN (not player since those coords are in a different system)
                //float newAngle = 0f;

                /*
                if (mouseState.Position.X != RenderManager.ViewportWidth / 2 || mouseState.Position.Y != RenderManager.ViewportHeight / 2)
                {
                    newAngle = (float)Math.Acos(Vector2.Dot(new Vector2(0, -1), mousePositionVector) / mousePositionVector.Length()); // original angle vector length should always be 1
                }

                // i dont remember how to math.........
                // range of invCos is 0-pi, can i extend it to 2pi using multiplication or whatever? i dont remember ;-;....
                // PERHAPS SLOW DOWN PLAYER IF NOT MOVING IN SAME DIRECTION AS FACING (as an interval of course, otherwise always slow unless at the exact angle.)
                if (mousePositionVector.X < 0)
                    WorldManager.player.faceDirection = newAngle * -1;
                else
                    WorldManager.player.faceDirection = newAngle;
                */

                // Its this simple!!
                Vector2 mousePositionVector = new Vector2(mouseState.Position.X - (RenderManager.ViewportWidth / 2), mouseState.Position.Y - (RenderManager.ViewportHeight / 2));
                player.faceDirection = (float)(Math.Atan2(mousePositionVector.Y, mousePositionVector.X) + (Math.PI / 2));

                #endregion

                //handles mouse input
                if (mouseState.LeftButton == ButtonState.Pressed)   //Primary fire
                {
                        player.Attack(0, player.inventory.GetEquippedPrimary());
                    }
                }
            if ((keyState.IsKeyDown(Keys.Q) && !previousState.IsKeyDown(Keys.Q))|| mouseState.MiddleButton == ButtonState.Pressed)    //weapon wheel
            {
                if (Game1.state == GameState.Game)
                {
                    Game1.state = GameState.WeaponWheel;
                }
            }
            if (keyState.IsKeyDown(Keys.E))    //Interact
            {
                player.Interact();
                //Game1.Instance.worldManager.CurrentWorld.playerMap.printMap();
            }
            if (keyState.IsKeyDown(Keys.R))    //Reload
            {
                if (player.inventory.GetEquippedPrimary().LoadedAmmo != player.inventory.GetEquippedPrimary().maxClip && player.inventory.GetEquippedPrimary().Ammo > 0 && !player.inventory.GetEquippedPrimary().Reloading)
                {
                    player.Reload();
                }
            }
            if (keyState.IsKeyDown(Keys.I))    //Inventory
            {
                if (Game1.state == GameState.Game || Game1.state == GameState.Pause || Game1.state == GameState.QuestLog)
                {
                    Game1.state = GameState.Inventory;
                }
            }
            if (keyState.IsKeyDown(Keys.G))    //Quest log
            {
                if (Game1.state == GameState.Game || Game1.state == GameState.Pause || Game1.state == GameState.Inventory)
                {

                    // DEBUG DIALOG TEST

                    //DialogBox test = new DialogBox(new Vector2(200, 150), DialogBoxType.OkCancel, "Test dialog!!", "You've opened the quest log!", new Vector2(300, 300));
                    //test.yesEvent += test_yesEvent;
                    //test.noEvent += test_noEvent;
                    //NPCTalkUI test = new NPCTalkUI(new Vector2(200, 150), "TESTER", "lololo wow ok hi XD!!");
                    //RenderManager.AddDialog(test);

                    Game1.state = GameState.QuestLog;
                }
            }
            if (keyState.IsKeyDown(Keys.Escape) && !previousState.IsKeyDown(Keys.Escape))    //Escape
            {
                if (Game1.state == GameState.Game || Game1.state == GameState.Inventory || Game1.state == GameState.QuestLog)
                {
                    Game1.state = GameState.Pause;
                }
                else if (Game1.state == GameState.Pause)
                {
                    Game1.state = GameState.Game;
                }
            }

            previousState = keyState;
        }