// Class Functions:
    protected override void InitializeStates()
    {
        #region Create States:
        #region Movement States:
        standingState       = new PlayerStandingState(this, stateMachine);
        combatIdleState     = new PlayerCombatIdleState(this, stateMachine);
        movingState         = new PlayerMovingState(this, stateMachine);
        jumpingState        = new PlayerJumpingState(this, stateMachine);
        fallingState        = new PlayerFallingState(this, stateMachine);
        crouchingState      = new PlayerCrouchingState(this, stateMachine);
        dashingState        = new PlayerDashingState(this, stateMachine);
        sprintingState      = new PlayerSprintingState(this, stateMachine);
        sprintRecoveryState = new PlayerSprintRecoveryState(this, stateMachine);
        slidingState        = new PlayerSlidingState(this, stateMachine);
        slidingJumpState    = new PlayerSlidingJumpState(this, stateMachine);
        standingGuardState  = new PlayerStandingGuardState(this, stateMachine);
        walkingState        = new PlayerWalkingState(this, stateMachine);
        crouchingGuardState = new PlayerCrouchingGuardState(this, stateMachine);
        #endregion // Movement States
        #region Action States:
        lightActionState  = new PlayerLightActionState(this, stateMachine);
        mediumActionState = new PlayerMediumActionState(this, stateMachine);
        heavyActionState  = new PlayerHeavyActionState(this, stateMachine);
        #endregion // Action States
        #region Reaction States:
        //burstState = new PlayerBurstState(this, stateMachine);
        //hitHighState = new PlayerHitHighState(this, stateMachine);
        //hitMedState = new PlayerHitMedState(this, stateMachine);
        //hitLowState = new PlayerHitLowState(this, stateMachine);
        //hitAirState = new PlayerHitAirState(this, stateMachine);
        //recoveryState = new PlayerRecoveryState(this, stateMachine);
        //knockbackState = new PlayerKnockbackState(this, stateMachine);
        //knockdownState = new PlayerKnockdownState(this, stateMachine);
        //deathState = new PlayerDeathState(this, stateMachine);
        #endregion // Reaction States
        #region Combat States:
        #region Unarmed States:
        #region Normals:
        #endregion // Normals
        #region Specials:
        //airAxeKick = new AirAxeKick(this, stateMachine);
        //airDragonPunch = new AirDragonPunch(this, stateMachine);
        feintRoll = new FeintRoll(this, stateMachine);
        //groundDragonPunch = new GroundDragonPunch(this, stateMachine);
        //hookKick = new HookKick(this, stateMachine);
        //lowKick = new LowKick(this, stateMachine);
        //rollingAxeKick = new RollingAxeKick(this, stateMachine);
        //snapKick = new SnapKick(this, stateMachine);
        //thrustKick = new ThrustKick(this, stateMachine);
        //verticalKick = new VerticalKick(this, stateMachine);
        #endregion // Specials
        #endregion // Unarmed States
        #endregion // Combat States
        #endregion // Create States

        // Initialize the starting states
        startState = standingState;
    }
    public void Init(PlayerController pl)
    {
        player          = pl;
        blinkController = player.GetComponent <BlinkController>();

        animator = player.GetComponent <Animator>();

        hexagons = new List <HexagonController>();

        specialAttackDetector = player.specialDetector;
        specialAttackDetector.GetComponent <PlayerSpecialAttackDetector>().Blackboard = this;
        specialAttackDetector.GetComponent <SphereCollider>().radius = player.specialAttackAffectationRadius;

        dashPSRotator = player.transform.Find("ParticleSystems/DashPSRotation");

        if (InputManager.Devices.Count >= player.Id)
        {
            controller = InputManager.Devices[player.Id - 1];
        }

        spawningState        = new PlayerSpawningState();
        idleState            = new PlayerIdleState();
        longIdleState        = new PlayerLongIdleState();
        movingState          = new PlayerMovingState();
        dashingState         = new PlayerDashingState();
        speedBumpState       = new PlayerSpeedBumpState();
        specialState         = new PlayerSpecialState();
        receivingDamageState = new PlayerReceivingDamageState();
        pushedState          = new PlayerPushedState();
        fallingState         = new PlayerFallingState();
        dyingState           = new PlayerDyingState();
        blockedState         = new PlayerBlockedState();
        invisibleState       = new PlayerInvisibleState();
        levelClearedState    = new PlayerLevelClearedState();

        spawningState.Init(this);
        idleState.Init(this);
        longIdleState.Init(this);
        movingState.Init(this);
        dashingState.Init(this);
        speedBumpState.Init(this);
        specialState.Init(this);
        receivingDamageState.Init(this);
        pushedState.Init(this);
        fallingState.Init(this);
        dyingState.Init(this);
        blockedState.Init(this);
        invisibleState.Init(this);
        levelClearedState.Init(this);

        string playerStr = "";

        switch (player.Id)
        {
        case 1: playerStr = "P1"; break;

        case 2: playerStr = "P2"; break;
        }

        moveHorizontal = playerStr + "_Horizontal";
        moveVertical   = playerStr + "_Vertical";
        aimHorizontal  = playerStr + "_AimHorizontal";
        aimVertical    = playerStr + "_AimVertical";
        fire           = playerStr + "_Fire";
        dash           = playerStr + "_Dash";
        special        = playerStr + "_Special";
        greenButton    = playerStr + "_Green";
        redButton      = playerStr + "_Red";
        blueButton     = playerStr + "_Blue";
        yellowButton   = playerStr + "_Yellow";

        playerRayCastMask  = LayerMask.GetMask(playerStr + "RayCast");
        playerPhysicsLayer = LayerMask.NameToLayer("Player");
        enemyPhysicsPlayer = LayerMask.NameToLayer("Enemy");

        ResetLifeVariables();
    }
    //Unity methods
    void Awake()
    {
        Debug.Log("Player " + playerId + " created.");
        rend = GetComponentInChildren<Renderer>();
        ctrl = GetComponent<CharacterController>();
        voxelization = GetComponent<VoxelizationClient>();

        spawningState = new PlayerSpawningState();
        idleState = new PlayerIdleState();
        longIdleState = new PlayerLongIdleState();
        movingState = new PlayerMovingState();
        dashingState = new PlayerDashingState();
        specialState = new PlayerSpecialState();
        swingingState = new PlayerSwingingState();
        receivingDamageState = new PlayerReceivingDamageState();
        fallingState = new PlayerFallingState();
        dyingState = new PlayerDyingState();

        spawningState.Init(this);
        idleState.Init(this);
        longIdleState.Init(this);
        movingState.Init(this);
        dashingState.Init(this);
        specialState.Init(this);
        swingingState.Init(this);
        receivingDamageState.Init(this);
        fallingState.Init(this);
        dyingState.Init(this);

        currentState = spawningState;

        string player = "";
        switch (playerId)
        {
            case 1: player = "P1"; break;
            case 2: player = "P2"; break;
        }

        moveHorizontal = player + "_Horizontal";
        moveVertical = player + "_Vertical";
        aimHorizontal = player + "_AimHorizontal";
        aimVertical = player + "_AimVertical";
        fire = player + "_Fire";
        dash = player + "_Dash";
        special = player + "_Special";

        playerRayCastMask = LayerMask.GetMask(player + "RayCast");
        animator = GetComponent<Animator>();
    }