Exemplo n.º 1
0
    public void StartHeroDefaultState()
    {
        if ((heroState == HeroStates.ENTERING) || (heroState == HeroStates.TURNING))
        {
            // Allow player input
            playerInputDenied = false;
            playerJumpDenied  = false;

            // Set state as default
            heroState = HeroStates.DEFAULT;
        }
    }
Exemplo n.º 2
0
    public void ReactTo_OffLimitWallsCollision()
    {
        if (heroState != HeroStates.DEAD)
        {
            return;
        }

        // Change state
        heroState = HeroStates.GAME_OVER;

        // ----- EVENT -----

        // Fire event: Hero is dead
        GameIsOver?.Invoke();
    }
Exemplo n.º 3
0
    // ---------- COLLISIONS AND OTHER ACTIONS ----------------------------------------------------+

    #region REACT TO PROJECTILE COLLISION
    public void ReactTo_ProjectileCollision()
    {
        // Do not react to projectiles if hero is dead
        if ((heroState == HeroStates.DEAD) || (heroState == HeroStates.GAME_OVER))
        {
            return;
        }

        // ----- CHANGE ANIMATIONS -----

        // Start getting hit animation
        animatorController.StartDeadAnimation();

        // Deny player input
        DenyPlayerInput();

        // Stop dodging
        StopDodging(true);

        // Stop jumping animation if possible
        if (!IsGrounded())
        {
            animatorController.StopJumpingAnimation();
        }

        // Start VFX animation
        //vfxTakeHit.StartAnimationCycle();

        // ----- OTHER ACTIONS -----

        // Physically react to hit
        PhysicallyReactToHit();

        // Set collider as trigger
        fullCollider.isTrigger = true;

        // Change tag
        hero.tag = "Hero Dying";

        // Set match state as "hero dying"
        heroState = HeroStates.DEAD;

        // Fire event: Hero was hit
        HeroWasHit?.Invoke();

        // Add slow mo
        Time.timeScale = 0.75f;
    }
    void Update()
    {
        LookAround();
        Reload();
        switch (hStates)
        {
        case HeroStates.Roaming:
            Roam();
            if (seeEnemy)
            {
                hStates = HeroStates.Chasing;
            }
            break;

        case HeroStates.Chasing:
            Chase();
            if (inAttackRange)
            {
                hStates = HeroStates.Attacking;
            }
            else if (!seeEnemy)
            {
                hStates = HeroStates.Roaming;
            }
            break;

        case HeroStates.Attacking:
            Attack();
            if (superAttackReady)
            {
                hStates = HeroStates.SuperAttacking;
            }
            else if (!inAttackRange)
            {
                hStates = HeroStates.Chasing;
            }
            break;

        case HeroStates.SuperAttacking:
            SuperAttack();
            if (!superAttackReady)
            {
                hStates = HeroStates.Attacking;
            }
            break;
        }
        text.text = "State : " + hStates.ToString();
    }
        public Sprite GetSpriteForStatus(HeroStates state)
        {
            switch (state)
            {
            case HeroStates.UNDISCOVERED:
                return(unknownIcon);

            case HeroStates.IDLE:
                return(idleIcon);

            case HeroStates.ON_QUEST:
                return(questingIcon);

            case HeroStates.DEAD:
                return(deathIcon);

            case HeroStates.WOUNDED:
                return(woundedIcon);

            default:
                return(unknownIcon);
            }
        }
Exemplo n.º 6
0
    // ---------- SPAWNS ----------------------------------------------------+

    #region SPAWN NEW HERO
    public void SpawnNewHero()
    {
        // Activate hero
        hero.SetActive(true);

        // Deactivate sword and hoverboard
        sword.SetActive(false);
        hoverboard.SetActive(false);

        // Deny player input
        playerInputDenied = false;
        playerJumpDenied  = false;

        // ----- STATE -----

        // Change state
        heroState = HeroStates.ENTERING;

        // Change animator controller
        animatorController.SetAnimatorController(true);

        // ----- RESET JUMPING FLAGS -----

        heroIsJumping = false;

        // ----- RESET DODGING FLAGS -----

        // Reset playerIsDodging flag
        playerIsDodging = false;

        // Stop dodging hero
        if (heroIsDodging)
        {
            StopDodging(false);
        }

        // Enable top collider only
        fullCollider.enabled   = true;
        bottomCollider.enabled = false;

        // Set collider as non trigger
        fullCollider.isTrigger = false;

        // ----- RESET ANIMATIONS -----

        // Reset hero animation
        animatorController.StopDeadAnimation();

        // ----- RESET TRANSFORM PARAMETERS -----

        // Set positions
        hero.transform.position            = basePosition;
        sword.transform.localPosition      = swordLocalPosition;
        hoverboard.transform.localPosition = hoverboardLocalPosition;

        // Reset rorations
        hero.transform.rotation       = Quaternion.identity;
        sword.transform.rotation      = Quaternion.identity;
        hoverboard.transform.rotation = Quaternion.identity;

        // ----- RESET RIGIDBODIES PARAMETERS -----

        // Reset hero's gravity
        heroRigidbody.gravityScale = normalGravityScale;
        // Set hero's movement constraints
        heroRigidbody.constraints = RigidbodyConstraints2D.FreezePositionX | RigidbodyConstraints2D.FreezeRotation;

        // Set sword's movement constraints
        swordRigidbody.constraints = RigidbodyConstraints2D.FreezeAll;

        // Set hoverboard's movement constraints
        hoverboardRigidbody.constraints = RigidbodyConstraints2D.FreezeAll;

        // ----- RESET OTHER PARAMETERS -----

        // Set the hero jumpStartTime to a previous time, so the player can dodge from the start
        jumpStartTime = Time.time - jumpDodgeCooldownDuration * 2;

        // Restore tags
        hero.tag = "Hero";
    }
Exemplo n.º 7
0
    // ---------- INITIALIZATIONS AND UPDATE ----------------------------------------------------+

    #region INITIALIZE
    public void Initialize(float _basePositionY, float _speed)
    {
        // Allow player input
        playerInputDenied = true;
        playerJumpDenied  = true;

        // ----- STATE -----

        heroState = HeroStates.AWAY;

        // ----- GAME OBJECTS -----

        // Instantiate and activate hero
        hero = Instantiate(heroPrefab);
        hero.SetActive(true);

        // Get and deactivate sword
        sword = hero.transform.GetChild(0).gameObject;
        sword.SetActive(false);

        // Get and deactivate hoverboard
        hoverboard = hero.transform.GetChild(1).gameObject;
        hoverboard.SetActive(false);

        // ----- COMPONENTS -----

        // Rigidbody
        heroRigidbody = hero.GetComponent <Rigidbody2D>();

        // Polygon collider
        fullCollider           = hero.GetComponent <PolygonCollider2D>();
        fullCollider.isTrigger = false;
        // Capsule collider
        bottomCollider           = hero.GetComponent <CapsuleCollider2D>();
        bottomCollider.isTrigger = false;

        // Collision system
        CollisionSystem heroCollisions = hero.GetComponent <CollisionSystem>();

        heroCollisions.InitializeHero(this);

        // Animator controller
        animatorController = hero.GetComponent <HeroAnimatorController>();

        // Sword rigidbody
        swordRigidbody = sword.GetComponent <Rigidbody2D>();
        swordRigidbody.gravityScale = deathGravityScale;

        // Hoverboard rigidbody
        hoverboardRigidbody = hoverboard.GetComponent <Rigidbody2D>();
        hoverboardRigidbody.gravityScale = deathGravityScale;

        // ----- SET DEFAULT ANIMATION (running) -----

        // Start iddle animation
        animatorController.StartDefaultAnimation();

        // ----- SET BASE POSITION -----

        basePosition = new Vector2(0, _basePositionY);

        // Set hero position
        hero.transform.position = basePosition;

        // ----- RESET JUMPING FLAGS -----

        heroIsJumping = false;

        // ----- INITIALIZE DROP VELOCITIES -----

        InitializeDropVelocitiesManually();
    }
 void Start()
 {
     hStates    = HeroStates.Roaming;
     roamTarget = transform.position;
 }
Exemplo n.º 9
0
    /// <summary>
    /// Processes the move.
    /// </summary>
    private void ProcessMove()
    {
        if ( (State == HeroStates.MoveForward || State == HeroStates.MoveUp || State == HeroStates.MoveDown ) && rigidbody.velocity.magnitude < 2f )
        {
            State = HeroStates.Idle;
        }

        if ( (State == HeroStates.PushOffGround || State == HeroStates.PushOffWall ) && rigidbody.velocity.magnitude < 0.5f )
        {
            State = HeroStates.Idle;
        }

        mMoveEffect.audio.volume = rigidbody.velocity.magnitude * 0.3f;
    }
Exemplo n.º 10
0
    /// <summary>
    /// Handles the on human iteract.
    /// </summary>
    /// <param name="source">Source.</param>
    /// <param name="e">E.</param>
    void HandleOnHumanIteract(object source, IteractionArgs e)
    {
        if ( e.Iteraction == IteractionArgs.EIteractions.Sweem )
        {
            Vector3 dir = (Vector3) e.Data;

            if ( State != HeroStates.Dead && State != HeroStates.StartPickingUp )
            {
                rigidbody.AddForce( dir * Constants.HeroPushForce * Time.deltaTime );
            }

            if ( (State == HeroStates.Idle || State == HeroStates.MoveForward || State == HeroStates.MoveUp || State == HeroStates.MoveDown ) )
            {
                //Check turns first
                if ( dir.x < -0.2f && mAnimator.transform.localScale.x > 0f )
                {
                    State = HeroStates.Turn;
                    return;
                }
                else if ( dir.x > 0.2f &&  mAnimator.transform.localScale.x < 0f )
                {
                    State = HeroStates.Turn;
                    return;
                }

                //Check moving
                else if ( (dir.x > 0 || dir.x < 0 ) && dir.z < 0.5f && dir.z > -0.5f && rigidbody.velocity.magnitude > 2f )
                {
                    //Move forward
                    State = HeroStates.MoveForward;
                }
                else if ( dir.z < -0.5f && rigidbody.velocity.magnitude > 2f )
                {
                    //Move down
                    State = HeroStates.MoveDown;
                }
                else if ( dir.z > 0.5f )
                {
                    //Move up
                    State = HeroStates.MoveUp;
                }
            }
        }
    }
Exemplo n.º 11
0
    /// <summary>
    /// Raises the collistion enter event.
    /// </summary>
    /// <param name="collision">Collision.</param>
    void OnCollisionEnter( Collision collision )
    {
        if ( State == HeroStates.Turn )
        {
            return;
        }

        foreach (ContactPoint cp in collision.contacts)
        {
            if ( cp.otherCollider.tag == "Thresure" )
            {
                mTakingObject = cp.otherCollider.gameObject;

                State = HeroStates.StartPickingUp;

                rigidbody.velocity = Vector3.zero;
            }
        }

        //
        ContactPoint firstContact = collision.contacts[0];
        if ( firstContact.otherCollider.transform.parent != null && collision.relativeVelocity.magnitude > Constants.HeroMinVelocityToReact )
        {
            if ( firstContact.otherCollider.transform.parent.name == "Stone" )
            {
                GameObject localSludge = Instantiate(sludgePrefab, firstContact.point, Quaternion.identity) as GameObject;
                localSludge.transform.rotation = Quaternion.Euler(0f, Quaternion.LookRotation( Vector3.down, firstContact.normal ).eulerAngles.y, 0f );

                int rndIndex = UnityEngine.Random.Range( 0, effectCollisionsStone.Length );
                GameObject.Instantiate( effectCollisionsStone[rndIndex], firstContact.point, Quaternion.identity );
            }
        }
    }
Exemplo n.º 12
0
    void HandleTileOnNextSpace(int nextX, int nextY)
    {
        switch (mapHandler.tileGrid[nextX, nextY].GetComponent <Tile>().tileType)
        {
        case Tile.TileType.Pit:
            if (!inventory.Contains("Ladder"))
            {
                //print("The hero is going to fall down a pit!!!");
                nextSpace.x = nextX;
                nextSpace.y = nextY;
            }
            else
            {
                int  secondX    = nextX;
                int  secondY    = nextY;
                bool horizontal = false;

                switch (heroDir)
                {
                case HeroDirections.Up:
                    secondY    = nextY + 1;
                    horizontal = false;
                    break;

                case HeroDirections.Down:
                    secondY    = nextY - 1;
                    horizontal = false;
                    break;

                case HeroDirections.Left:
                    secondX    = nextX - 1;
                    horizontal = true;
                    break;

                case HeroDirections.Right:
                    secondX    = nextX + 1;
                    horizontal = true;
                    break;
                }

                if (secondX < 0 || secondX >= mapHandler.tileGrid.GetLength(0) || secondY < 0 || secondY >= mapHandler.tileGrid.GetLength(1))
                {
                    //print("Out of bounds, so it's ok if the hero crosses with a ladder because they'll bump into a wall");
                    nextSpace.x = nextX;
                    nextSpace.y = nextY;

                    if (visibleLadder != null)
                    {
                        Destroy(visibleLadder);
                    }
                    visibleLadder = Instantiate(visibleLadderPrefab, new Vector2(nextSpace.x, nextSpace.y), Quaternion.identity);
                    if (horizontal)
                    {
                        visibleLadder.transform.Rotate(new Vector3(0, 0, 90));
                    }
                }
                else
                {
                    if (mapHandler.tileGrid[secondX, secondY] != null && mapHandler.tileGrid[secondX, secondY].GetComponent <Tile>().tileType == Tile.TileType.Pit)
                    {
                        //print("The pit is too wide to cross with a ladder, so the hero is going to fall!!!");
                        nextSpace.x = nextX;
                        nextSpace.y = nextY;
                    }
                    else
                    {
                        //print("The hero used their ladder to cross the gap!!");
                        nextSpace.x = nextX;
                        nextSpace.y = nextY;

                        if (visibleLadder != null)
                        {
                            Destroy(visibleLadder);
                        }
                        visibleLadder = Instantiate(visibleLadderPrefab, new Vector2(nextSpace.x, nextSpace.y), Quaternion.identity);
                        if (horizontal)
                        {
                            visibleLadder.transform.Rotate(new Vector3(0, 0, 90));
                        }
                    }
                }
            }
            break;

        case Tile.TileType.Rock:
            heroState = HeroStates.Frustrated;
            break;

        case Tile.TileType.Exit:
            //print("The hero is about to exit!!!");
            nextSpace.x = nextX;
            nextSpace.y = nextY;
            break;

        default:
            //print("This shouldn't ever print??");
            nextSpace.x = nextX;
            nextSpace.y = nextY;
            break;
        }
    }
Exemplo n.º 13
0
    //Look ahead to see if there's something the hero has to deal with (e.g. walking out of bounds, running into an impassable tile, etc)
    void SetNextSpace()
    {
        //First, check if the hero saw the pot
        bool sawPot = CheckForLineOfSightWithPot();

        if (sawPot)
        {
            heroState = HeroStates.SawPot;
            gameOverUI.ActivateGameOver("Game over!\n(The hero saw a pot)");
            return;
        }



        int curX = (int)curSpace.x;
        int curY = (int)curSpace.y;

        int nextX = curX;
        int nextY = curY;

        //Update where the hero is going next
        switch (heroDir)
        {
        case HeroDirections.Up:
            nextY = curY + 1;
            break;

        case HeroDirections.Down:
            nextY = curY - 1;
            break;

        case HeroDirections.Left:
            nextX = curX - 1;
            break;

        case HeroDirections.Right:
            nextX = curX + 1;
            break;
        }

        if (!mapHandler.GetIfInsideTileGrid(nextX, nextY))
        {
            if (heroState == HeroStates.Victory)
            {
                //print("The hero is currently escaping, so it's ok to move out of bounds!");
                nextSpace.x = nextX;
                nextSpace.y = nextY;
            }
            else
            {
                //print("Out of bounds!!");
                heroState = HeroStates.Frustrated;
            }
        }

        //If the space we're looking at isn't null, figure out what it is and what we should do about it
        else if (mapHandler.tileGrid[nextX, nextY] != null)
        {
            HandleTileOnNextSpace(nextX, nextY);
        }

        //If the space we're looking at is null, just move forward
        else
        {
            //print("All clear to keep moving!");
            nextSpace.x = nextX;
            nextSpace.y = nextY;
        }
    }
Exemplo n.º 14
0
    //If something is at the hero's space, decide what to do (e.g. change direction, pick up item, etc)
    void HandleCurrentTile()
    {
        int curX = (int)curSpace.x;
        int curY = (int)curSpace.y;

        Tile checkTile = mapHandler.tileGrid[curX, curY].GetComponent <Tile>();

        switch (checkTile.tileType)
        {
        case Tile.TileType.TurnUp:
            ChangeHeroDirection(HeroDirections.Up);
            break;

        case Tile.TileType.TurnDown:
            ChangeHeroDirection(HeroDirections.Down);
            break;

        case Tile.TileType.TurnLeft:
            ChangeHeroDirection(HeroDirections.Left);
            break;

        case Tile.TileType.TurnRight:
            ChangeHeroDirection(HeroDirections.Right);
            break;

        case Tile.TileType.Pit:
            if (!inventory.Contains("Ladder"))
            {
                gameOverUI.ActivateGameOver("Game over!\n(The hero fell into a pit)");
            }
            else
            {
                int  x = (int)curSpace.x;
                int  y = (int)curSpace.y;
                Tile extraPitCheck;

                switch (heroDir)
                {
                case HeroDirections.Up:
                    extraPitCheck = mapHandler.GetTileAtCoords(x, y + 1);
                    if (extraPitCheck && extraPitCheck.tileType == Tile.TileType.Pit)
                    {
                        gameOverUI.ActivateGameOver("Game over!\n(The pit was too wide to cross with a ladder)");
                    }
                    break;

                case HeroDirections.Down:
                    extraPitCheck = mapHandler.GetTileAtCoords(x, y - 1);
                    if (extraPitCheck && extraPitCheck.tileType == Tile.TileType.Pit)
                    {
                        gameOverUI.ActivateGameOver("Game over!\n(The pit was too wide to cross with a ladder)");
                    }
                    break;

                case HeroDirections.Left:
                    extraPitCheck = mapHandler.GetTileAtCoords(x - 1, y);
                    if (extraPitCheck && extraPitCheck.tileType == Tile.TileType.Pit)
                    {
                        gameOverUI.ActivateGameOver("Game over!\n(The pit was too wide to cross with a ladder)");
                    }
                    break;

                case HeroDirections.Right:
                    extraPitCheck = mapHandler.GetTileAtCoords(x + 1, y);
                    if (extraPitCheck && extraPitCheck.tileType == Tile.TileType.Pit)
                    {
                        gameOverUI.ActivateGameOver("Game over!\n(The pit was too wide to cross with a ladder)");
                    }
                    break;
                }
            }
            break;

        case Tile.TileType.Ladder:
            if (!inventory.Contains("Ladder"))
            {
                inventory.Add("Ladder");
            }
            Destroy(mapHandler.tileGrid[curX, curY].gameObject);
            break;

        case Tile.TileType.Sword:
            if (!inventory.Contains("Sword"))
            {
                inventory.Add("Sword");
            }
            Destroy(mapHandler.tileGrid[curX, curY].gameObject);
            break;

        case Tile.TileType.Exit:
            heroState = HeroStates.Victory;
            sightGraphic.GetComponent <SpriteRenderer>().enabled = false;
            //Top player exit
            if (curY == (mapHandler.tileGrid.GetLength(1) - 1))
            {
                ChangeHeroDirection(HeroDirections.Up);
            }
            //Bottom player exit
            else if (curY == 0)
            {
                ChangeHeroDirection(HeroDirections.Down);
            }
            //Left player exit
            else if (curX == 0)
            {
                ChangeHeroDirection(HeroDirections.Left);
            }
            //Right player exit
            else if (curX == (mapHandler.tileGrid.GetLength(0) - 1))
            {
                ChangeHeroDirection(HeroDirections.Right);
            }
            else
            {
                print("The exit was in an illegal position (not along the edges of the map) so we're leaving the hero's direction alone");
            }
            break;
        }

        //Cheeky check to see if we should delete a visible ladder
        if (visibleLadder != null)
        {
            if (checkTile.tileType != Tile.TileType.Pit)
            {
                Destroy(visibleLadder);
            }
        }
    }
Exemplo n.º 15
0
    public override void OnMapAction()
    {
        switch (heroState)
        {
        case HeroStates.Entering:
            curSpace.x = nextSpace.x;
            curSpace.y = nextSpace.y;

            switch (heroDir)
            {
            case HeroDirections.Up:
                nextSpace.y = nextSpace.y + 1;
                break;

            case HeroDirections.Down:
                nextSpace.y = nextSpace.y - 1;
                break;

            case HeroDirections.Left:
                nextSpace.x = nextSpace.x - 1;
                break;

            case HeroDirections.Right:
                nextSpace.x = nextSpace.x + 1;
                break;
            }

            //When the player enters the mapHandler.tileGrid, set them to HeroStates.Moving
            if (nextSpace.x >= 0 && nextSpace.y >= 0 && nextSpace.x < mapHandler.tileGrid.GetLength(0) && nextSpace.y < mapHandler.tileGrid.GetLength(1))
            {
                heroState = HeroStates.Moving;
            }
            break;

        case HeroStates.Moving:
            curSpace.x = nextSpace.x;
            curSpace.y = nextSpace.y;

            //If the hero is over a tile, do something
            if (mapHandler.tileGrid[(int)curSpace.x, (int)curSpace.y])
            {
                HandleCurrentTile();
            }
            else
            {
                if (visibleLadder != null)
                {
                    Destroy(visibleLadder);                             //Really bad, kinda hope we can move this elsewhere at some point
                }
            }

            //If the hero is over an entity, do something
            if (mapHandler.entityGrid[(int)curSpace.x, (int)curSpace.y])
            {
                HandleCurrentEntity();
            }

            SetNextSpace();
            break;

        case HeroStates.Frustrated:
            switch (heroDir)
            {
            case HeroDirections.Up:
                ChangeHeroDirection(HeroDirections.Down);
                break;

            case HeroDirections.Down:
                ChangeHeroDirection(HeroDirections.Up);
                break;

            case HeroDirections.Left:
                ChangeHeroDirection(HeroDirections.Right);
                break;

            case HeroDirections.Right:
                ChangeHeroDirection(HeroDirections.Left);
                break;
            }
            heroState = HeroStates.Moving;
            SetNextSpace();
            break;

        case HeroStates.SawPot:
            break;

        case HeroStates.Victory:
            if (!GameMaster.instance.GetIfCoordsAreInsideCam(curSpace.x, curSpace.y))
            {
                victoryUI.ActivateVictoryScreen();
            }
            else
            {
                curSpace.x = nextSpace.x;
                curSpace.y = nextSpace.y;

                switch (heroDir)
                {
                case HeroDirections.Up:
                    nextSpace.y = nextSpace.y + 1;
                    break;

                case HeroDirections.Down:
                    nextSpace.y = nextSpace.y - 1;
                    break;

                case HeroDirections.Left:
                    nextSpace.x = nextSpace.x - 1;
                    break;

                case HeroDirections.Right:
                    nextSpace.x = nextSpace.x + 1;
                    break;
                }
            }
            break;
        }
    }
Exemplo n.º 16
0
        private void move(KeyboardState keyState, KeyboardState oldKeyState, Rectangle viewportRect, double elapsedTime, GameTime gameTime)
        {
            if (keyState.IsKeyDown(Keys.LeftShift) && !oldKeyState.IsKeyDown(Keys.LeftShift)) // testing weapon switching //
            {
                changeWeapon(keyState, oldKeyState);
            }
            // Idle To Crouch Transition Cases //
            if (heroState == HeroStates.StandStill && !oldKeyState.IsKeyDown(Keys.Down) && keyState.IsKeyDown(Keys.Down) && !airborn) // case for idle -> crouch transition
                drawCrouchingTransition(keyState, oldKeyState);
            if ((heroState == HeroStates.CrouchStill || heroState == HeroStates.CrouchWalking) && oldKeyState.IsKeyDown(Keys.Down) && keyState.IsKeyUp(Keys.Down) && !airborn) // case for crouch/crouchwalking -> uncrouch transition
                drawUnCrouchingTransition(keyState, oldKeyState);

            // Crouch Idle //
            if (keyState.IsKeyDown(Keys.Down) && (!keyState.IsKeyDown(Keys.Right) || !keyState.IsKeyDown(Keys.Left)) && !airborn)
            {
                crouching = true;
                heroState = HeroStates.CrouchStill;
                for (int counter = 0; counter < 3; counter++)
                    weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.CrouchIdle);
                setCurrentActiveWeaponSprite((int)BodySpriteIndex.CrouchIdle);
                legs.setCurrentActiveSprite((int)LegSpriteIndex.CrouchIdle);
                setCheckStrings("crouchidle");
            }

            // Hero Idle //
            if ( !keyState.IsKeyDown(Keys.Down) &&  (!keyState.IsKeyDown(Keys.Right) || !keyState.IsKeyDown(Keys.Left)))
            {
                crouching = false;
                heroState = HeroStates.StandStill;
                for (int counter = 0; counter < 3; counter++)
                    weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.Idle);
                setCurrentActiveWeaponSprite((int)BodySpriteIndex.Idle);
                legs.setCurrentActiveSprite((int)LegSpriteIndex.Idle);
                setCheckStrings("idle");
                checkMidToUpConditions(keyState, oldKeyState);
                checkUpToMidConditions(keyState, oldKeyState);
            }

            // Hero Walking Right Conditions (Right Walking, Right Crouch Walking, Etc...) //
            if (keyState.IsKeyDown(Keys.Right))
            {
                if (keyState.IsKeyDown(Keys.Down)) // Right Down //
                {
                    spriteFlipping = false;
                    crouching = true;
                    checkFacingLeft(keyState, oldKeyState);
                    setLegsOffsetFalse();

                    // Crouching Transitions //
                    if (!oldKeyState.IsKeyDown(Keys.Down) && keyState.IsKeyDown(Keys.Down) && !airborn)
                        drawCrouchingTransition(keyState, oldKeyState);
                    else if (keyState.IsKeyDown(Keys.Down) && oldKeyState.IsKeyDown(Keys.Up) && !keyState.IsKeyDown(Keys.Up) && !airborn)
                        drawCrouchingTransition(keyState, oldKeyState);

                    // Crouch Walking Right Condition //
                    if (keyState.IsKeyDown(Keys.Left) && !airborn)                                       // condition for right, down, left & not airborn //
                    {
                        heroState = HeroStates.CrouchStill;
                        for (int counter = 0; counter < 3; counter++)
                            weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.CrouchIdle);
                        setCurrentActiveWeaponSprite((int)BodySpriteIndex.CrouchIdle);
                        legs.setCurrentActiveSprite((int)LegSpriteIndex.CrouchIdle);
                    }
                    else if (!keyState.IsKeyDown(Keys.Left) && !airborn)                                 // condition for crouched movement (right) on ground//
                    {
                        for (int counter = 0; counter < 3; counter++)
                            weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.CrouchIdle);
                        setCurrentActiveWeaponSprite((int)BodySpriteIndex.CrouchIdle);
                        legs.setCurrentActiveSprite((int)LegSpriteIndex.CrouchWalk);
                        moveRight(gameTime);
                    }
                    else if (keyState.IsKeyDown(Keys.Left) && airborn)                                   // right down left and airborn //
                    {
                        crouching = false;
                        for (int counter = 0; counter < 3; counter++)
                            weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.IdleDown);
                        setCurrentActiveWeaponSprite((int)BodySpriteIndex.IdleDown);
                        legs.setCurrentActiveSprite((int)LegSpriteIndex.Jump);
                        if (!movementlock)
                        {
                            moveRight(gameTime);
                            movementlock = true;
                        }
                    }
                    else if (!keyState.IsKeyDown(Keys.Left) && airborn)                                  // right and down and airborn //
                    {
                        crouching = false;
                        for (int counter = 0; counter < 3; counter++)
                            weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.IdleDown);
                        setCurrentActiveWeaponSprite((int)BodySpriteIndex.IdleDown);
                        legs.setCurrentActiveSprite((int)LegSpriteIndex.Jump);
                        if (!movementlock)
                        {
                            moveRight(gameTime);
                            movementlock = true;
                        }
                    }
                }
                else if(keyState.IsKeyDown(Keys.Left)) // Right Left //
                {
                    spriteFlipping = false;
                    crouching = false;
                    checkFacingLeft(keyState, oldKeyState);
                    setLegsOffsetFalse();

                    if (!keyState.IsKeyDown(Keys.Down) && !airborn)                                     // case for right left & not airborn//
                    {
                        crouching = false;
                        for (int counter = 0; counter < 3; counter++)
                            weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.Idle);
                        setCurrentActiveWeaponSprite((int)BodySpriteIndex.Idle);
                        legs.setCurrentActiveSprite((int)LegSpriteIndex.Idle);
                    }
                    else if (keyState.IsKeyDown(Keys.Down) && !airborn)                                 // right left down (not in the air) [Results in crouch idle] //
                    {
                        crouching = true;
                        heroState = HeroStates.CrouchStill;

                        // Crouching Transitions //
                        if (!oldKeyState.IsKeyDown(Keys.Down) && keyState.IsKeyDown(Keys.Down) && !airborn)
                            drawCrouchingTransition(keyState, oldKeyState);
                        else if (keyState.IsKeyDown(Keys.Down) && oldKeyState.IsKeyDown(Keys.Up) && !keyState.IsKeyDown(Keys.Up) && !airborn)
                            drawCrouchingTransition(keyState, oldKeyState);

                        for (int counter = 0; counter < 3; counter++)
                            weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.CrouchIdle);
                        setCurrentActiveWeaponSprite((int)BodySpriteIndex.CrouchIdle);
                        legs.setCurrentActiveSprite((int)LegSpriteIndex.CrouchIdle);
                    }
                    else if (keyState.IsKeyDown(Keys.Down) && airborn)                                   // right left down & airborn//
                    {
                        crouching = false;
                        for (int counter = 0; counter < 3; counter++)
                            weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.IdleDown);
                        setCurrentActiveWeaponSprite((int)BodySpriteIndex.IdleDown);
                        legs.setCurrentActiveSprite((int)LegSpriteIndex.Jump);
                        if (!movementlock)
                        {
                            moveRight(gameTime);
                            movementlock = true;
                        }
                    }
                    checkMidToUpConditions(keyState, oldKeyState);
                    checkUpToMidConditions(keyState, oldKeyState);
                }
                else                                                                                     // case for running right //
                {
                    spriteFlipping = false;
                    checkFacingLeft(keyState, oldKeyState);
                    setLegsOffsetFalse();
                    heroState = HeroStates.Running;
                    moveRight(gameTime);

                    for (int counter = 0; counter < 3; counter++)
                        weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.Idle);
                    setCurrentActiveWeaponSprite((int)BodySpriteIndex.Idle);
                    legs.setCurrentActiveSprite((int)LegSpriteIndex.Running);

                    checkMidToUpConditions(keyState, oldKeyState);
                    checkUpToMidConditions(keyState, oldKeyState);
                }
            }
            if (keyState.IsKeyDown(Keys.Left)) // Left Key Check
            {
                if (keyState.IsKeyDown(Keys.Down))                                                       //  Left & Down //
                {
                    spriteFlipping = true;
                    checkFacingRight(keyState, oldKeyState);
                    setLegsOffsetTrue();

                    // Crouching Transition //
                    if (!oldKeyState.IsKeyDown(Keys.Down) && keyState.IsKeyDown(Keys.Down) && !airborn)
                        drawCrouchingTransition(keyState, oldKeyState);
                    else if (keyState.IsKeyDown(Keys.Down) && oldKeyState.IsKeyDown(Keys.Up) && !keyState.IsKeyDown(Keys.Up) && !airborn)
                        drawCrouchingTransition(keyState, oldKeyState); // CASE FOR LOOKING UP, THEN PRESS CROUCH, THEN LET GO OF LOOKING UP //

                    if (!keyState.IsKeyDown(Keys.Right) && !airborn)                                    // Left Down And Not Airborn //
                    {
                        crouching = true;
                        heroState = HeroStates.CrouchWalking;
                        for (int counter = 0; counter < 3; counter++)
                            weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.CrouchIdle);
                        setCurrentActiveWeaponSprite((int)BodySpriteIndex.CrouchIdle);
                        legs.setCurrentActiveSprite((int)LegSpriteIndex.CrouchWalk);
                        moveLeft(gameTime);
                    }
                    if(keyState.IsKeyDown(Keys.Right) && !airborn)                                 // Left Down Right and Not Airborn//
                    {
                        crouching = true;
                        heroState = HeroStates.CrouchStill;
                        for (int counter = 0; counter < 3; counter++)
                            weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.CrouchIdle);
                        setCurrentActiveWeaponSprite((int)BodySpriteIndex.CrouchIdle);
                        legs.setCurrentActiveSprite((int)LegSpriteIndex.CrouchIdle);

                    }
                    if (!keyState.IsKeyDown(Keys.Right) && airborn)                                // Left Down Jumping //
                    {
                        crouching = false;
                        for (int counter = 0; counter < 3; counter++)
                            weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.IdleDown);
                        setCurrentActiveWeaponSprite((int)BodySpriteIndex.IdleDown);
                        legs.setCurrentActiveSprite((int)LegSpriteIndex.Jump);
                        if (!movementlock)
                        {
                            moveLeft(gameTime);
                            movementlock = true;
                        }
                    }
                    if (keyState.IsKeyDown(Keys.Right) && airborn)                                 // Left Down Right And Airborn //
                    {
                        crouching = false;
                        for (int counter = 0; counter < 3; counter++)
                            weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.IdleDown);
                        setCurrentActiveWeaponSprite((int)BodySpriteIndex.IdleDown);
                        legs.setCurrentActiveSprite((int)LegSpriteIndex.Jump);
                        if (!movementlock)
                        {
                            moveLeft(gameTime);
                            movementlock = true;
                        }
                    }
                    checkMidToUpConditions(keyState, oldKeyState);
                    checkUpToMidConditions(keyState, oldKeyState);
                }
                else if (keyState.IsKeyDown(Keys.Right))                                                // Left & Right //
                {
                    if (!keyState.IsKeyDown(Keys.Down) && !airborn)                                     // Right Left  Only //
                    {
                        crouching = false;
                        heroState = HeroStates.StandStill;
                        for (int counter = 0; counter < 3; counter++)
                            weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.Idle);
                        setCurrentActiveWeaponSprite((int)BodySpriteIndex.Idle);
                        legs.setCurrentActiveSprite((int)LegSpriteIndex.Idle);
                    }
                    else if (keyState.IsKeyDown(Keys.Down) && !airborn)                                 // Right Left Down Grounded //
                    {
                        crouching = true;
                        heroState = HeroStates.CrouchStill;
                        for (int counter = 0; counter < 3; counter++)
                            weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.CrouchIdle);
                        setCurrentActiveWeaponSprite((int)BodySpriteIndex.CrouchIdle);
                        legs.setCurrentActiveSprite((int)LegSpriteIndex.CrouchIdle);
                    }
                    else if (keyState.IsKeyDown(Keys.Down) && airborn)                                  // Left Right Down airborn //
                    {
                        crouching = true;
                        heroState = HeroStates.CrouchStill;
                        setCurrentActiveWeaponSprite((int)BodySpriteIndex.CrouchIdle);
                        legs.setCurrentActiveSprite((int)LegSpriteIndex.CrouchIdle);
                        if (!movementlock)
                        {
                            moveRight(gameTime);
                            movementlock = true;
                        }
                    }
                    checkMidToUpConditions(keyState, oldKeyState);
                    checkUpToMidConditions(keyState, oldKeyState);
                }
                else                                                                                    // Running //
                {
                    spriteFlipping = true;
                    checkFacingRight(keyState, oldKeyState);
                    setLegsOffsetTrue();
                    heroState = HeroStates.Running;

                    moveLeft(gameTime);
                    for (int counter = 0; counter < 3; counter++)
                        weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.Idle);
                    setCurrentActiveWeaponSprite((int)BodySpriteIndex.Idle);
                    legs.setCurrentActiveSprite((int)LegSpriteIndex.Running);

                    checkMidToUpConditions(keyState, oldKeyState);
                    checkUpToMidConditions(keyState, oldKeyState);
                }
            }
            if (keyState.IsKeyDown(Keys.Down) && (!keyState.IsKeyDown(Keys.Right) && !keyState.IsKeyDown(Keys.Left)) && airborn) // crouched, and in the air (no right or left) //
            {
                for (int counter = 0; counter < 3; counter++)
                    weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.IdleDown);
                setCurrentActiveWeaponSprite((int)BodySpriteIndex.IdleDown);
                legs.setCurrentActiveSprite((int)LegSpriteIndex.Jump);
            }

            // Reload //
            if (keyState.IsKeyDown(Keys.S) && !oldKeyState.IsKeyDown(Keys.S))
            {
                checkReloadTransition(keyState, oldKeyState);
                switch (getCurrentWeapon())
                {
                    case CurrentWeapon.Pistol:
                        Weapon.reloadPistol();
                        break;
                    case CurrentWeapon.Rifle:
                        Weapon.reloadRifle();
                        break;
                    case CurrentWeapon.Rocket:
                        Weapon.reloadRckt();
                        break;
                }
            }

            // Auto-Reload System //
            if (currentActiveWeapon == (int)CurrentWeapon.Pistol)
            {
                if (Weapon.pistolclipEmpty && !crouching)
                {
                    if (keyState.IsKeyDown(Keys.Up))
                        weaponTransitionArsenal[(int)CurrentWeapon.Pistol].setCurrentActiveSprite((int)BodyTransitionIndex.ReloadUp);
                    else
                        weaponTransitionArsenal[(int)CurrentWeapon.Pistol].setCurrentActiveSprite((int)BodyTransitionIndex.Reload);
                    Weapon.reloadPistol();
                }
                else if (Weapon.pistolclipEmpty && crouching)
                {
                    weaponTransitionArsenal[(int)CurrentWeapon.Pistol].setCurrentActiveSprite((int)BodyTransitionIndex.CrouchReload);
                    Weapon.reloadPistol();
                }
            }
            else if (currentActiveWeapon == (int)CurrentWeapon.Rifle)
            {
                if (Weapon.rifleclipEmpty && !crouching)
                {
                    if (keyState.IsKeyDown(Keys.Up))
                        weaponTransitionArsenal[(int)CurrentWeapon.Rifle].setCurrentActiveSprite((int)BodyTransitionIndex.ReloadUp);
                    else
                        weaponTransitionArsenal[(int)CurrentWeapon.Rifle].setCurrentActiveSprite((int)BodyTransitionIndex.Reload);
                    Weapon.reloadRifle();
                }
                else if (Weapon.rifleclipEmpty && crouching)
                {
                    weaponTransitionArsenal[(int)CurrentWeapon.Rifle].setCurrentActiveSprite((int)BodyTransitionIndex.CrouchReload);
                    Weapon.reloadRifle();
                }
            }

            else if (currentActiveWeapon == (int)CurrentWeapon.Rocket)
            {
                if (Weapon.rcktclipEmpty && !crouching)
                {
                    if (keyState.IsKeyDown(Keys.Up))
                        weaponTransitionArsenal[(int)CurrentWeapon.Rocket].setCurrentActiveSprite((int)BodyTransitionIndex.ReloadUp);
                    else
                        weaponTransitionArsenal[(int)CurrentWeapon.Rocket].setCurrentActiveSprite((int)BodyTransitionIndex.Reload);
                    Weapon.reloadRckt();
                }
                else if (Weapon.rcktclipEmpty && crouching)
                {
                    weaponTransitionArsenal[(int)CurrentWeapon.Rocket].setCurrentActiveSprite((int)BodyTransitionIndex.CrouchReload);
                    Weapon.reloadRckt();
                }
            }

            //Shooting Animation Logic //
            if (keyState.IsKeyDown(Keys.D) && !oldKeyState.IsKeyDown(Keys.D))
            {
                firing = true;
                    checkShootingStartTransition(keyState, oldKeyState);
            }
            else if (!keyState.IsKeyDown(Keys.D) && oldKeyState.IsKeyDown(Keys.D))
            {
                firing = false;
                    checkShootingEndTransition(keyState, oldKeyState);
            }
            else if (keyState.IsKeyDown(Keys.D) && oldKeyState.IsKeyDown(Keys.D))
            {
                if (crouching)
                {
                    if (currentActiveWeapon == (int)CurrentWeapon.Rifle)
                    {
                        for (int counter = 0; counter < 3; counter++)
                            weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.CrouchShoot);
                        setCurrentActiveWeaponSprite((int)BodySpriteIndex.CrouchShoot);
                    }
                }
                else if (!crouching && !airborn && !keyState.IsKeyDown(Keys.Up))
                {
                    if (currentActiveWeapon == (int)CurrentWeapon.Rifle)
                    {
                        for (int counter = 0; counter < 3; counter++)
                            weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.Shoot);
                        setCurrentActiveWeaponSprite((int)BodySpriteIndex.Shoot);
                    }
                }
                else if (!crouching && !airborn && keyState.IsKeyDown(Keys.Up))
                {
                    if (currentActiveWeapon == (int)CurrentWeapon.Rifle)
                    {
                        for (int counter = 0; counter < 3; counter++)
                            weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.ShootUp);
                        setCurrentActiveWeaponSprite((int)BodySpriteIndex.ShootUp);
                    }
                }
                else if (airborn && keyState.IsKeyDown(Keys.Down))
                {
                    if (currentActiveWeapon == (int)CurrentWeapon.Rifle)
                    {
                        for (int counter = 0; counter < 3; counter++)
                            weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.ShootDown);
                        setCurrentActiveWeaponSprite((int)BodySpriteIndex.ShootDown);
                    }
                }
                else if (airborn && !keyState.IsKeyDown(Keys.Down) && !keyState.IsKeyDown(Keys.Up))
                {
                    if (currentActiveWeapon == (int)CurrentWeapon.Rifle)
                    {
                        for (int counter = 0; counter < 3; counter++)
                            weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.Shoot);
                        setCurrentActiveWeaponSprite((int)BodySpriteIndex.Shoot);
                    }
                }
                else if (airborn && !keyState.IsKeyDown(Keys.Down) && keyState.IsKeyDown(Keys.Up))
                {
                    if (currentActiveWeapon == (int)CurrentWeapon.Rifle)
                    {
                        for (int counter = 0; counter < 3; counter++)
                            weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.ShootUp);
                        setCurrentActiveWeaponSprite((int)BodySpriteIndex.ShootUp);
                    }
                }
            }

            // Magic Animation Logic //
            if (keyState.IsKeyDown(Keys.A) && !oldKeyState.IsKeyDown(Keys.A))
            {
                firingmagic = true;
                checkMagicStartTransition(keyState, oldKeyState);
            }
            else if (!keyState.IsKeyDown(Keys.A) && oldKeyState.IsKeyDown(Keys.A))
            {
                firingmagic = false;
                checkMagicEndTransition(keyState, oldKeyState);
            }
            else if (keyState.IsKeyDown(Keys.A) && oldKeyState.IsKeyDown(Keys.A))
            {
                if (crouching)
                {
                    for (int counter = 0; counter < 3; counter++)
                        weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.CrouchMagic);
                    setCurrentActiveWeaponSprite((int)BodySpriteIndex.CrouchMagic);
                }
                else if (!crouching && !airborn && !keyState.IsKeyDown(Keys.Up))
                {
                    for (int counter = 0; counter < 3; counter++)
                        weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.Magic);
                    setCurrentActiveWeaponSprite((int)BodySpriteIndex.Magic);
                }
                else if (!crouching && !airborn && keyState.IsKeyDown(Keys.Up))
                {
                    for (int counter = 0; counter < 3; counter++)
                        weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.MagicUp);
                    setCurrentActiveWeaponSprite((int)BodySpriteIndex.MagicUp);
                }
                else if (airborn && keyState.IsKeyDown(Keys.Down))
                {
                    for (int counter = 0; counter < 3; counter++)
                        weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.MagicDown);
                    setCurrentActiveWeaponSprite((int)BodySpriteIndex.MagicDown);
                }
                else if (airborn && !keyState.IsKeyDown(Keys.Down) && !keyState.IsKeyDown(Keys.Up))
                {
                    for (int counter = 0; counter < 3; counter++)
                        weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.Magic);
                    setCurrentActiveWeaponSprite((int)BodySpriteIndex.Magic);
                }
                else if (airborn && !keyState.IsKeyDown(Keys.Down) && keyState.IsKeyDown(Keys.Up))
                {
                    for (int counter = 0; counter < 3; counter++)
                        weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.MagicUp);
                    setCurrentActiveWeaponSprite((int)BodySpriteIndex.MagicUp);
                }
            }

            // Jumping Logic //
            if (keyState.IsKeyDown(Keys.Space) && !oldKeyState.IsKeyDown(Keys.Space))
            {
                if (jumpsLeft <= 2 && jumpsLeft > 0)
                {
                    heroState = HeroStates.Jumping;
                    for (int counter = 0; counter < 3; counter++)
                        weaponArsenal[counter].setCurrentActiveSprite((int)BodySpriteIndex.Jump);
                    setCheckStrings("jumping");
                    jump();
                }
            }
            if (airborn)
                legs.setCurrentActiveSprite((int)LegSpriteIndex.Fall);
        }