public static Vector3 HorizontalVector(InGameDirection dir)
        {
            float fMultiplier = 1f;

            if (dir.Equals(InGameDirection.Left_Move) || dir.Equals(InGameDirection.Top_Move) ||
                dir.Equals(InGameDirection.Right_Move) || dir.Equals(InGameDirection.Down_Move))
            {
                fMultiplier *= 1.414f;
            }
            return(Quaternion.AngleAxis(AngleOfForward(dir), Vector3.up) * Vector3.forward * fMultiplier);
        }
        void vMoveTo(InGameDirection dir)
        {
            bool bMove = dir > 0;

            if (!bMove)
            {
                dir = (InGameDirection)(-1 * (int)dir);
            }

            if (dir.Equals(InGameDirection.Dash) || (!bOnMoving && (CC.isGrounded || bFreeJumpMode)))
            {
                if (!bFreeJumpMode && dir.Equals(InGameDirection.Jump_Move))
                {
                    //CC.SimpleMove(Vector3.down * 0.1f); (CC.collisionFlags & CollisionFlags.Below) != 0 ||
                    fJumpingPowerDurationInst = fJumpingPowerDuration;
                    //_action.Play_Action(Action.Type.Jump);
                    //return;
                    dir = LastDirection;
                }

                if (bDashing = dir.Equals(InGameDirection.Dash))
                {
                    dir = LastDirection;
                }
                else
                {
                    LastDirection = dir;
                }

                float   fAngle = 0f, fLength = 1f;
                Vector3 v3Tmp        = Vector3.forward;
                Vector3 v3LocalYZero = new Vector3(CC.transform.localPosition.x, 0, CC.transform.localPosition.z);
                // if (bDashing)
                // {
                //  if (Vector3.Distance(vDestination, v3LocalYZero) > 0.5f)
                //      fLength *= 2f;
                // }

                if (dir.Equals(InGameDirection.Left_Move) || dir.Equals(InGameDirection.Top_Move) ||
                    dir.Equals(InGameDirection.Right_Move) || dir.Equals(InGameDirection.Down_Move))
                {
                    fLength *= 1.414f;
                }

                fAngle = (int)dir * 45f;
                if (bRotateToDirection)
                {
                    CC.transform.localEulerAngles = new Vector3(0, fAngle, 0);
                }

                if (bMove)
                {
                    v3Tmp   = Quaternion.AngleAxis(fAngle, Vector3.up) * v3Tmp * fLength;
                    v3Tmp   = vDestination + v3Tmp;
                    v3Tmp.y = CC.transform.position.y;                    // - fMaxDropHeight;
                    //Debug.Log(v3);
                    bMove = Physics.Raycast(v3Tmp, Vector3.down,
                                            fMaxDropHeight, 1 << LayerMask.NameToLayer(FloorLayerMask));
                }

                vDestination = bMove ? v3Tmp : (bDashing ? vDestination : v3LocalYZero);
                vDestination.Set(Mathf.RoundToInt(vDestination.x), 0, Mathf.RoundToInt(vDestination.z));

                if (Vector3.Distance(vDestination, v3LocalYZero) >= CC.minMoveDistance)
                {
                    bOnMoving = true;
                }

                // if (bDashing)
                //  _action.Play_Action(Action.Type.Dash);
                // else if (!bOnJumpingBoost)
                //  _action.Play_Action(Action.Type.Walk);
            }
            else
            {
                EnQueueTo(dir);
            }
        }
 public bool bMovingDirection(InGameDirection direction)
 {
     return(bOnMoving && LastDirection.Equals(direction));
 }
        protected void ExecuteDir(InGameDirection dir)
        {
            bool bMove = dir > 0;

            if (!bMove)
            {
                dir = (InGameDirection)(-1 * (int)dir);
            }

            if (dir.Equals(InGameDirection.Dash) || (!bOnMoving && (isOnGround || bJumpWithMove)))
            {
                if (!bJumpWithMove && dir.Equals(InGameDirection.Jump_Move))
                {
                    jumpStart();
                    dir = LastDirection;
                }

                if (bDashing = dir.Equals(InGameDirection.Dash))
                {
                    dir = LastDirection;
                }
                else
                {
                    LastDirection = dir;
                }

                // float fAngle = IsometricMovement.AngleOfForward(dir);

                if (bRotateToDirection)
                {
                    RotateTo(dir);
                    // cTransform.localEulerAngles = new Vector3(0, fAngle, 0);
                }

                if (bMove)
                {
                    Vector3 v3TmpCoordinates = IsometricMovement.HorizontalVector(dir);
                    if (!bDashing && bSnapToGroundGrid)
                    {
                        Vector3 vUnSnapedPosition = groundGridUnSnapedPosition(cTransform.position);
                        if (vUnSnapedPosition.magnitude > 0.2f &&
                            Vector3.Dot(v3TmpCoordinates.normalized, vUnSnapedPosition.normalized) > 0.866f) //0.866 means angle < 30
                        {
                            v3TmpCoordinates = -vUnSnapedPosition;
                        }
                    }

                    Vector3 v3TmpPosition = cTransform.position + groundGridPos(v3TmpCoordinates, bSnapToGroundGrid);
                    if (!bDashing && bSnapToGroundGrid)
                    {
                        v3TmpPosition += groundGridUnSnapedPosition(v3TmpPosition);
                    }

                    if (bDashing)
                    {
                        v3TmpPosition += vHorizontalMovement;
                    }

                    bMove = Grounding(v3TmpPosition, fMaxDropHeight);
                    if (bMove)
                    {
                        if (!bDashing)
                        {
                            vLastCoordinates = vDestinationCoordinates;
                        }
                        vDestinationCoordinates += v3TmpCoordinates;
                        SetHorizontalMovement(v3TmpPosition - cTransform.position);
                    }
                }
            }
            else
            {
                EnQueueDirection(dir);
            }
        }
        protected void ExecuteDir(InGameDirection dir)
        {
            isMoving = true;
            bool bMove = dir > 0 && alive;

            if (!bMove)
            {
                dir = (InGameDirection)(-1 * (int)dir);
            }

            if (dir.Equals(InGameDirection.Dash) || (!bOnMoving && (isOnGround || bJumpWithMove)))
            {
                if (!bJumpWithMove && dir.Equals(InGameDirection.Jump_Move))
                {
                    jumpStart();
                    dir = LastDirection;
                }

                if (bDashing = dir.Equals(InGameDirection.Dash))
                {
                    dir = LastDirection;
                }
                else
                {
                    LastDirection = dir;
                }

                // float fAngle = IsometricMovement.AngleOfForward(dir);

                if (bRotateToDirection)
                {
                    RotateTo(dir);
                    // cTransform.localEulerAngles = new Vector3(0, fAngle, 0);
                }

                if (bMove)
                {
                    Vector3 v3TmpCoordinates = IsometricMovement.HorizontalVector(dir);
                    if (!bDashing && bSnapToGroundGrid)
                    {
                        Vector3 vUnSnapedPosition = groundGridUnSnapedPosition(cTransform.position);
                        if (vUnSnapedPosition.magnitude > 0.2f &&
                            Vector3.Dot(v3TmpCoordinates.normalized, vUnSnapedPosition.normalized) > 0.866f) //0.866 means angle < 30
                        {
                            v3TmpCoordinates = -vUnSnapedPosition;
                        }
                    }

                    Vector3 v3TmpPosition = cTransform.position + groundGridPos(v3TmpCoordinates, bSnapToGroundGrid);
                    if (!bDashing && bSnapToGroundGrid)
                    {
                        v3TmpPosition += groundGridUnSnapedPosition(v3TmpPosition);
                    }

                    if (bDashing)
                    {
                        v3TmpPosition += vHorizontalMovement;
                    }

                    bMove = Grounding(v3TmpPosition, fMaxDropHeight);
                    if (!bDashing)
                    {
                        vLastCoordinates = vDestinationCoordinates;
                    }
                    vDestinationCoordinates += v3TmpCoordinates;
                    SetHorizontalMovement(v3TmpPosition - cTransform.position);
                    if (!bMove)
                    {
                        if (!GameObject.FindWithTag("Player").GetComponent <KeyInputAssist>().illegalJump)
                        {
                            alive = false;
                            GameObject.FindWithTag("Player").GetComponent <KeyInputAssist>().illegalJump = false;
                        }

                        //Get grid location where Player was standing before they fell to their doom.
                        deathType = deathByFalling;
                        // var deathlocation = GameObject.FindWithTag("Player").GetComponent<KeyInputAssist>().GetCurrAlpacaLocationProperty();
                    }
                }
            }
            else
            {
                EnQueueDirection(dir);
            }
        }