public void Update(Character player, H_Map.TileMap tiles, Game1 game, GameTime gameTime)
        {
            #region things to update every frame, positions
            aPosition.X = position.X - (position.Width / 2);
            aPosition.Y = position.Y - (position.Height / 2);
            Rectangle location = new Rectangle(position.X, position.Y, position.Width, position.Height);
            healthPos.X = position.X + 8;
            healthPos.Y = position.Y - 15;
            healthPos.Width = (int)healthBarWidth;
            healthPos.Height = 10;
            healthPct = (health / maxHealth);
            healthBarWidth = (float)healthTexture.Width * healthPct;
            bumpRectangle = new Rectangle(position.X + position.Width / 2, position.Y + position.Height / 2, position.Width / 2, position.Height / 2);
            animation.UpdateAnimation(gameTime);
            #endregion

            if (health <= 0)
            {
                Death(gameTime);
            }
            else
            {
                if (waypoint != null)
                {
                    waypoint.Update(game, new Vector2(position.X, position.Y));
                }

                if (!walking && health > 0)
                {
                    animation.MaxFrameCount = 1;
                    if (up)
                    {
                        if (!animation.IsAnimationPlaying(IDLE_UP))
                        {
                            animation.LoopAnimation(IDLE_UP);
                        }
                    }
                    if (down)
                    {
                        if (!animation.IsAnimationPlaying(IDLE_DOWN))
                        {
                            animation.LoopAnimation(IDLE_DOWN);
                        }
                    }
                    if (left)
                    {
                        if (!animation.IsAnimationPlaying(IDLE_LEFT))
                        {
                            animation.LoopAnimation(IDLE_LEFT);
                        }
                    }
                    if (right)
                    {
                        if (!animation.IsAnimationPlaying(IDLE_RIGHT))
                        {
                            animation.LoopAnimation(IDLE_RIGHT);
                        }
                    }
                }

                if (mob && !bossMob)
                {
                    if (!attackPlayer && IsOnMap() && health > 0)
                    {
                        RandomMovement(gameTime);
                    }
                    else
                        pathTimer = 0;
                }

                for (int i = 0; i < damageEffectList.Count; i++)
                {
                    damageEffectList[i].Effect();
                }

                if (attackPlayer)
                {
                    canInteract = false;
                    Attack(game, gameTime);
                }

                #region Player Interaction

                if (IsOnMap())
                {
                    if (position.Intersects(player.interactRect) && !attackPlayer)
                    {
                        canInteract = true;
                        if (!isInteracting)
                        {
                            if (!addA)
                            {
                                aColor.A -= 10;
                                aColor.B += 10;
                                aColor.R -= 10;
                                aColor.G += 10;
                            }
                            if (aColor.A <= 50)
                            {
                                addA = true;
                            }
                            if (addA)
                            {
                                aColor.A += 10;
                                aColor.R += 10;
                                aColor.B -= 10;
                                aColor.G -= 10;
                            }
                            if (aColor.A >= 240)
                            {
                                addA = false;
                            }
                        }
                    }
                    else
                    {
                        canInteract = false;
                    }
                }
                if (quest != null && quest.completed)
                {
                    canInteract = false;
                }
                #endregion

                if (!attackPlayer && player.positionRectangle.Intersects(position) && IsOnMap())
                {
                    if (health > 0)
                    {
                        Vector2 pos = new Vector2(location.X, location.Y);
                        Vector2 direction = Game1.character.position - pos;
                        direction.Normalize();
                        if (name != "")
                        {
                            Game1.character.Push(direction, 3);
                        }
                        else
                        {
                            if (attackPlayer)
                            {
                                Game1.character.Push(direction, 3);
                            }
                        }
                    }
                }
            }
        }
        public void Update(Game1 game, H_Map.TileMap tiles, GameTime gameTime, KeyboardState oldState, GraphicsDevice graphicsDevice)
        {
            #region Things to update every frame, positions and stuff
            healthPct = (health / maxHealth);
            healthBarWidth = (float)healthTexture.Width * healthPct;
            float elapsed = (float)gameTime.ElapsedGameTime.TotalMilliseconds;
            positionRectangle.X = (int)position.X;
            positionRectangle.Y = (int)position.Y;
            if (showInventory)
            {
                animation.PauseAnimation();
            }

            if (Game1.testBoss.attackPlayer)
            {
                if (!Game1.testBoss.enraged)
                {
                    if (positionRectangle.X + (positionRectangle.Width / 2) - 16 > bossTarget.X)
                    {
                        bossTarget.X += targetSpeed / 1.2f;
                    }
                    if (positionRectangle.X + (positionRectangle.Width / 2) - 16 < bossTarget.X)
                    {
                        bossTarget.X -= targetSpeed / 1.2f;
                    }
                    if (positionRectangle.Y + (positionRectangle.Width / 2) - 16 > bossTarget.Y)
                    {
                        bossTarget.Y += targetSpeed / 1.2f;
                    }
                    if (positionRectangle.Y + (positionRectangle.Width / 2) - 16 < bossTarget.Y)
                    {
                        bossTarget.Y -= targetSpeed / 1.2f;
                    }
                }
                else
                {
                    if (positionRectangle.X + (positionRectangle.Width / 2) - 16 > bossTarget.X)
                    {
                        bossTarget.X += targetSpeed / 1.15f;
                    }
                    if (positionRectangle.X + (positionRectangle.Width / 2) - 16 < bossTarget.X)
                    {
                        bossTarget.X -= targetSpeed / 1.15f;
                    }
                    if (positionRectangle.Y + (positionRectangle.Width / 2) - 16 > bossTarget.Y)
                    {
                        bossTarget.Y += targetSpeed / 1.15f;
                    }
                    if (positionRectangle.Y + (positionRectangle.Width / 2) - 16 < bossTarget.Y)
                    {
                        bossTarget.Y -= targetSpeed / 1.15f;
                    }
                }
            }

            if (isHit)
            {
                Bleed();
                bleedTimer -= elapsed;
            }
            if (bleedTimer <= 0)
            {
                isHit = false;
                bleedTimer = BLEEDTIMER;
            }

            if (health <= 0)
            {
                dead = true;
                DeathEffect(game);
            }

            if (inCombat)
            {
                regenTimer = REGENTIMER;
            }
            else
                regenTimer -= elapsed;

            if (regenTimer <= 0)
            {
                if (health < maxHealth && !inCombat && !dead)
                {
                    regenAmount = rand.Next(3, 7);

                    if (maxHealth - health < regenAmount)
                        regenAmount = maxHealth - health;

                    health += regenAmount;
                    damageEffectList.Add(new DamageEffect((int)regenAmount, game, new Vector2(positionRectangle.X, positionRectangle.Y - 16), new Color(0, 255, 0, 255), "regen"));
                    Regen((int)regenAmount);
                    regenTimer = REGENTIMER;
                }
            }
            tile = tiles;

            if (left)
            {
                attackRectangle.Width = positionRectangle.Width * 2;
                attackRectangle.Height = 54;
                attackRectangle.X = positionRectangle.X - (attackRectangle.Width / 2) + 12;
                attackRectangle.Y = positionRectangle.Y + 5;

                warpRectangle.Width = positionRectangle.Width / 2;
                warpRectangle.Height = 5;
                warpRectangle.X = positionRectangle.X - warpRectangle.Width;
                warpRectangle.Y = positionRectangle.Y + (positionRectangle.Height / 2) + 2;
            }
            if (right)
            {
                attackRectangle.Width = positionRectangle.Width * 2;
                attackRectangle.Height = 54;
                attackRectangle.X = positionRectangle.X;
                attackRectangle.Y = positionRectangle.Y + 5;

                warpRectangle.Width = positionRectangle.Width / 2;
                warpRectangle.Height = 5;
                warpRectangle.X = positionRectangle.X + positionRectangle.Width;
                warpRectangle.Y = positionRectangle.Y + (positionRectangle.Height / 2) + 2;
            }
            if (up)
            {
                attackRectangle.Width = 54;
                attackRectangle.Height = positionRectangle.Height * 2;
                attackRectangle.X = positionRectangle.X;
                attackRectangle.Y = positionRectangle.Y - (positionRectangle.Height / 2);

                warpRectangle.Width = 5;
                warpRectangle.Height = positionRectangle.Height / 2;
                warpRectangle.X = positionRectangle.X + (positionRectangle.Width / 2) + 2;
                warpRectangle.Y = positionRectangle.Y - warpRectangle.Height;
            }
            if (down)
            {
                attackRectangle.Width = 54;
                attackRectangle.Height = positionRectangle.Height * 2;
                attackRectangle.X = positionRectangle.X;
                attackRectangle.Y = positionRectangle.Y;

                warpRectangle.Width = 5;
                warpRectangle.Height = positionRectangle.Height / 2;
                warpRectangle.X = positionRectangle.X + (positionRectangle.Width / 2);
                warpRectangle.Y = positionRectangle.Y + positionRectangle.Height;
            }

            animation.UpdateAnimation(gameTime);
            #endregion

            if (disabled)
            {
                disabledTimer -= elapsed;
                if (disabledTimer <= 0)
                {
                    disabled = false;
                    disabledTimer = DISABLEDTIMER;
                }
            }
            #region walk
            if (!attacking && !showInventory && !dead)// && cWarp.canWalk
            {
                walking = false;
                if (!disabled)
                {
                    if (game.keyState.IsKeyDown(Keys.Up))
                    {
                        //effects
                        if (Game1.map.backgroundLayer[positionRectangle.X / Game1.map.tileWidth, positionRectangle.Y / Game1.map.tileHeight].tileID == 4
                            || Game1.map.backgroundLayer[positionRectangle.X / Game1.map.tileWidth, positionRectangle.Y / Game1.map.tileHeight].tileID == 8)
                        {
                            Splash(gameTime);
                        }
                        else
                            Walk();

                        up = true;
                        down = false;
                        left = false;
                        right = false;

                        ApplyForce(new Vector2(0, -2));

                        animation.MaxFrameCount = 3;
                        if (!animation.IsAnimationPlaying(WALK_UP))
                        {
                            animation.LoopAnimation(WALK_UP);
                        }
                        walking = true;
                    }

                    else if (game.keyState.IsKeyDown(Keys.Down))
                    {
                        //effects
                        if (Game1.map.backgroundLayer[positionRectangle.X / Game1.map.tileWidth, positionRectangle.Y / Game1.map.tileHeight].tileID == 4
                            || Game1.map.backgroundLayer[positionRectangle.X / Game1.map.tileWidth, positionRectangle.Y / Game1.map.tileHeight].tileID == 8)
                        {
                            Splash(gameTime);
                        }
                        else
                            Walk();

                        down = true;
                        up = false;
                        right = false;
                        left = false;

                        ApplyForce(new Vector2(0, 2));
                        animation.MaxFrameCount = 3;
                        if (!animation.IsAnimationPlaying(WALK_DOWN))
                        {
                            animation.LoopAnimation(WALK_DOWN);
                        }
                        walking = true;
                    }

                    if (game.keyState.IsKeyDown(Keys.Right))
                    {
                        //effects
                        if (Game1.map.backgroundLayer[positionRectangle.X / Game1.map.tileWidth, positionRectangle.Y / Game1.map.tileHeight].tileID == 4
                            || Game1.map.backgroundLayer[positionRectangle.X / Game1.map.tileWidth, positionRectangle.Y / Game1.map.tileHeight].tileID == 8)
                        {
                            Splash(gameTime);
                        }
                        else
                            Walk();

                        right = true;
                        left = false;
                        up = false;
                        down = false;

                        ApplyForce(new Vector2(2, 0));
                        animation.MaxFrameCount = 3;
                        if (!animation.IsAnimationPlaying(WALK_RIGHT))
                        {
                            animation.LoopAnimation(WALK_RIGHT);
                        }
                        walking = true;
                    }

                    else if (game.keyState.IsKeyDown(Keys.Left))
                    {
                        //effects
                        if (Game1.map.backgroundLayer[positionRectangle.X / Game1.map.tileWidth, positionRectangle.Y / Game1.map.tileHeight].tileID == 4
                            || Game1.map.backgroundLayer[positionRectangle.X / Game1.map.tileWidth, positionRectangle.Y / Game1.map.tileHeight].tileID == 8)
                        {
                            Splash(gameTime);
                        }
                        else
                            Walk();

                        left = true;
                        right = false;
                        up = false;
                        down = false;

                        ApplyForce(new Vector2(-2, 0));
                        animation.MaxFrameCount = 3;
                        if (!animation.IsAnimationPlaying(WALK_LEFT))
                        {
                            animation.LoopAnimation(WALK_LEFT);
                        }
                        walking = true;
                    }
                }

                if (Game1.map.backgroundLayer[positionRectangle.X / Game1.map.tileWidth, positionRectangle.Y / Game1.map.tileHeight].tileID == 4
                            || Game1.map.backgroundLayer[positionRectangle.X / Game1.map.tileWidth, positionRectangle.Y / Game1.map.tileHeight].tileID == 8)
                {
                    CalculateFriction(0.7f);
                }
                else
                    CalculateFriction(0.2f);

                SetPosition();

                if (leftSide.Intersects(tile.GetTileRectangleFromPosition(leftSide.X, leftSide.Y)) && !tile.CheckCellPositionPassable(new Vector2(leftSide.X, leftSide.Y)))
                {
                    position.X = tile.GetTileRectangleFromPosition(leftSide.X, leftSide.Y).Right;
                    velocity.X = 0;
                }
                if (rightSide.Intersects(tile.GetTileRectangleFromPosition(rightSide.X, rightSide.Y)) && !tile.CheckCellPositionPassable(new Vector2(rightSide.X, rightSide.Y)))
                {
                    position.X = tile.GetTileRectangleFromPosition(rightSide.X, rightSide.Y).Left - positionRectangle.Width;
                    velocity.X = 0;
                }
                if (upSide.Intersects(tile.GetTileRectangleFromPosition(upSide.X, upSide.Y)) && !tile.CheckCellPositionPassable(new Vector2(upSide.X, upSide.Y)))
                {
                    position.Y = tile.GetTileRectangleFromPosition(upSide.X, upSide.Y).Bottom;
                    velocity.Y = 0;
                }
                if (downSide.Intersects(tile.GetTileRectangleFromPosition(downSide.X, downSide.Y)) && !tile.CheckCellPositionPassable(new Vector2(downSide.X, downSide.Y)))
                {
                    position.Y = tile.GetTileRectangleFromPosition(downSide.X, downSide.Y).Top - positionRectangle.Height;
                    velocity.Y = 0;
                }

                //Second side so yo say...
                if (leftSide.Intersects(tile.GetTileRectangleFromPosition(leftSide.X, leftSide.Bottom)) && !tile.CheckCellPositionPassable(new Vector2(leftSide.X, leftSide.Bottom)))
                {
                    position.X = tile.GetTileRectangleFromPosition(leftSide.X, leftSide.Bottom).Right;
                    velocity.X = 0;
                }
                if (rightSide.Intersects(tile.GetTileRectangleFromPosition(rightSide.X, rightSide.Bottom)) && !tile.CheckCellPositionPassable(new Vector2(rightSide.X, rightSide.Bottom)))
                {
                    position.X = tile.GetTileRectangleFromPosition(rightSide.X, rightSide.Bottom).Left - positionRectangle.Width;
                    velocity.X = 0;
                }
                if (upSide.Intersects(tile.GetTileRectangleFromPosition(upSide.Right, upSide.Y)) && !tile.CheckCellPositionPassable(new Vector2(upSide.Right, upSide.Y)))
                {
                    position.Y = tile.GetTileRectangleFromPosition(upSide.Right, upSide.Y).Bottom;
                    velocity.Y = 0;
                }
                if (downSide.Intersects(tile.GetTileRectangleFromPosition(downSide.Right, downSide.Y)) && !tile.CheckCellPositionPassable(new Vector2(downSide.Right, downSide.Y)))
                {
                    position.Y = tile.GetTileRectangleFromPosition(downSide.Right, downSide.Y).Top - positionRectangle.Height;
                    velocity.Y = 0;
                }
            }

            #endregion

            if (game.keyState.IsKeyDown(Keys.Tab) && oldState.IsKeyUp(Keys.Tab) && !dead)
            {
                if (showInventory)
                {
                    showInventory = false;
                }
                else
                    showInventory = true;
            }

            if (!animation.IsAnimationPlaying(ATTACK_UP) && !animation.IsAnimationPlaying(ATTACK_DOWN) && !animation.IsAnimationPlaying(ATTACK_LEFT) && !animation.IsAnimationPlaying(ATTACK_RIGHT))
            {
                attacking = false;
            }
            #region Attack
            attackTimer -= elapsed;
            if (sword != null)
            {
                if (game.keyState.IsKeyDown(Keys.Z) && game.oldState.IsKeyUp(Keys.Z) && !dead && attackTimer <= 0)
                {
                    attackTimer = ATTACKTIMER;
                    attacking = true;
                    animation.MaxFrameCount = 1;
                    if (up)
                    {
                        animation.PlayAnimation(ATTACK_UP);
                    }
                    else if (down)
                    {
                        animation.PlayAnimation(ATTACK_DOWN);
                    }
                    else if (left)
                    {
                        animation.PlayAnimation(ATTACK_LEFT);
                    }
                    else if (right)
                    {
                        animation.PlayAnimation(ATTACK_RIGHT);
                    }

                    foreach (Npc.Npc npc in game.activeNpcs)
                    {
                        if (npc.position.Intersects(attackRectangle))
                        {
                            if (npc.health > 0 && npc.IsOnMap() && npc.vulnerable)
                            {
                                damage = game.damageObject.dealDamage(sword.minDamage, sword.maxDamage);
                                damageEffectList.Add(new DamageEffect(damage, game, new Vector2(npc.position.X, npc.position.Y - 16), new Color(255, 255, 255, 255), "player"));
                                npc.health -= damage;
                                npc.attackPlayer = true;
                                npc.attackTimer += 300;
                                Slash(npc.position);
                            }
                        }
                    }
                    if (positionRectangle.Intersects(Game1.testBoss.position))
                    {
                        if (Game1.testBoss.health > 0 && Game1.testBoss.IsOnMap())
                        {
                            damage = game.damageObject.dealDamage(sword.minDamage, sword.maxDamage) * 2;
                            damageEffectList.Add(new DamageEffect(damage, game, new Vector2(Game1.testBoss.position.X, Game1.testBoss.position.Y - 16), new Color(255, 255, 255, 255), "player"));
                            Game1.testBoss.health -= damage;
                            Game1.testBoss.currentPhase = Npc.Boss.phase.sleep;
                        }
                    }
                    for (int i = 0; i < Game1.testBoss.mobs.Count; i++)
                    {
                        if (positionRectangle.Intersects(Game1.testBoss.mobs[i].position))
                        {
                            if (Game1.testBoss.mobs[i].health > 0)
                            {
                                damage = game.damageObject.dealDamage(sword.minDamage, sword.maxDamage);
                                damageEffectList.Add(new DamageEffect(damage, game, new Vector2(Game1.testBoss.mobs[i].position.X, Game1.testBoss.mobs[i].position.Y - 16), new Color(255, 255, 255, 255), "player"));
                                Game1.testBoss.mobs[i].health -= damage;
                                if (Game1.testBoss.mobs[i].health <= 0)
                                {
                                    Game1.testBoss.health -= 1;
                                }
                            }
                        }
                    }
                    for (int i = 0; i < game.Mobs.Count; i++)
                    {
                        if (game.Mobs[i].position.Intersects(attackRectangle))
                        {
                            if (game.Mobs[i].health > 0 && game.Mobs[i].IsOnMap())
                            {
                                damage = game.damageObject.dealDamage(sword.minDamage, sword.maxDamage);
                                damageEffectList.Add(new DamageEffect(damage, game, new Vector2(game.Mobs[i].position.X, game.Mobs[i].position.Y - 16), new Color(255, 255, 255, 255), "player"));
                                game.Mobs[i].health -= damage;
                                game.Mobs[i].attackPlayer = true;
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < damageEffectList.Count; i++)
            {
                damageEffectList[i].Effect();
            }

            inCombat = false;

            for (int i = 0; i < game.activeNpcs.Count; i++)
            {
                if (game.activeNpcs[i].health > 0)
                {
                    if (game.activeNpcs[i].attackPlayer)
                    {
                        inCombat = true;
                    }
                }
            }
            for (int i = 0; i < game.Mobs.Count; i++)
            {
                if (game.Mobs[i].health > 0)
                {
                    if (game.Mobs[i].attackPlayer)
                    {
                        inCombat = true;
                    }
                }
            }
            #endregion

            if (!walking && !attacking)
            {
                animation.MaxFrameCount = 1;
                if (up && !animation.IsAnimationPlaying(IDLE_UP))
                {
                    animation.LoopAnimation(IDLE_UP);
                }
                else if (down && !animation.IsAnimationPlaying(IDLE_DOWN))
                {
                    animation.LoopAnimation(IDLE_DOWN);
                }
                else if (left && !animation.IsAnimationPlaying(IDLE_LEFT))
                {
                    animation.LoopAnimation(IDLE_LEFT);
                }
                else if (right && !animation.IsAnimationPlaying(IDLE_RIGHT))
                {
                    animation.LoopAnimation(IDLE_RIGHT);
                }
            }
        }
 public bool IsCollision(H_Map.TileMap tiles, Rectangle location)
 {
     Microsoft.Xna.Framework.Point tileIndex = tiles.GetTileIndexFromVector(new Vector2(location.X, location.Y));
     return (!tiles.interactiveLayer[tileIndex.X, tileIndex.Y].isPassable);
 }