コード例 #1
0
        static InGameDirection convert_4Dir(Vector3 vMoveTo)
        {
            bool            isXAxis = Mathf.Abs(vMoveTo.x) >= Mathf.Abs(vMoveTo.z);
            InGameDirection result  = InGameDirection.Jump_Move;

            if (isXAxis)
            {
                if (vMoveTo.x > 0)
                {
                    result = InGameDirection.RD_Move;
                }
                else
                {
                    result = InGameDirection.LT_Move;
                }
            }
            else
            {
                if (vMoveTo.z > 0)
                {
                    result = InGameDirection.RT_Move;
                }
                else
                {
                    result = InGameDirection.LD_Move;
                }
            }
            return(result);
        }
コード例 #2
0
        void EnQueueTo(InGameDirection direction)
        {
            bool bDash = target.bMovingDirection(direction) && (Time.time - fLastInputTime < fMaxDashInputInterval);

            fLastInputTime = Time.time;

            target.EnQueueDirection(bDash ? InGameDirection.Dash : direction);
        }
コード例 #3
0
 override public bool EnQueueDirection(InGameDirection dir)
 {
     if (EnQueueDirectionWithoutReset(dir))
     {
         ResetPath();
         return(true);
     }
     return(false);
 }
コード例 #4
0
        bool EnQueueDirectionWithoutReset(InGameDirection dir)
        {
            if (isControllable)
            {
                return(base.EnQueueDirection(dir));
            }

            return(false);
        }
コード例 #5
0
        void ContinuousMove(InGameDirection direction)
        {
            if (direction < 0)
            {
                direction = (InGameDirection )(-1 * (int)direction);
            }
            Vector3 vMovement = IsometricMovement.HorizontalVector(direction);

            target.DirectTranslate(vMovement * Time.deltaTime);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
 public void EnQueueTo(InGameDirection dir)
 {
     if (bOnMoving && LastDirection == dir &&
         (Time.time - fLastInputTime < fMaxDashInputInterval))
     {
         vMoveTo(InGameDirection.Dash);
     }
     else if (DirQ.Count < iMaxQSize)
     {
         DirQ.Enqueue(dir);
     }
     fLastInputTime = Time.time;
 }
コード例 #8
0
        protected void SetHorizontalMovement(Vector3 vTmp)
        {
            LastDirection         = Convert(vTmp);
            vHorizontalMovement   = vTmp;
            vHorizontalMovement.y = 0;

            if (vHorizontalMovement.sqrMagnitude >= fSqrtMinMovement)
            {
                bOnMoving = true;
            }

            UpdateAnimatorParams();
        }
コード例 #9
0
        static InGameDirection convert_8Dir(Vector3 vMoveTo)
        {
            InGameDirection result     = InGameDirection.None;
            float           x          = vMoveTo.x;
            float           z          = vMoveTo.z;
            float           absX       = Mathf.Abs(x);
            float           absZ       = Mathf.Abs(z);
            bool            bPositiveX = x > 0;
            bool            bPositiveZ = z > 0;

            if (x * z == 0)
            {
                if (bPositiveX)
                {
                    result = InGameDirection.RD_Move;
                }
                else if (!bPositiveX)
                {
                    result = InGameDirection.LT_Move;
                }
                else if (bPositiveZ)
                {
                    result = InGameDirection.RT_Move;
                }
                else if (!bPositiveZ)
                {
                    result = InGameDirection.LD_Move;
                }
            }
            else if (absX / absZ > 1.5f)
            {
                result = bPositiveX ? InGameDirection.RD_Move : InGameDirection.LT_Move;
            }
            else if (absX / absZ < 0.5f)
            {
                result = bPositiveZ ? InGameDirection.RT_Move : InGameDirection.LD_Move;
            }
            else // 1.5f > x / z > 0.5f
            {
                if (bPositiveX)
                {
                    result = bPositiveZ ? InGameDirection.Right_Move : InGameDirection.Down_Move;
                }
                else
                {
                    result = bPositiveZ ? InGameDirection.Top_Move : InGameDirection.Left_Move;
                }
            }

            return(result);
        }
コード例 #10
0
        virtual public bool EnQueueDirection(InGameDirection dir)
        {
            if (dir == InGameDirection.Dash)
            {
                Dash();
                return(true);
            }

            if (DirQ.Count >= iMaxQSize)
            {
                return(false);
            }

            DirQ.Enqueue(dir);
            return(true);
        }
コード例 #11
0
        bool keyMacro(InGameDirection direction,
                      bool bShift,
                      System.Func <IEnumerable <KeyCode>,
                                   System.Func <KeyCode, bool>, bool> action,
                      System.Func <KeyCode, bool> subAction,
                      System.Func <int, bool> keyCheck,
                      System.Action <InGameDirection> Do,
                      params KeyCode[] codes)
        {
            if (bShift) // Rotate
            {
                direction = (InGameDirection)(-1 * (int)direction);
            }

            if (action(codes, subAction))
            {
                Do(direction);
                return(true);
            }

            Console.WriteLine(keyCheck(0));
            if (keyCheck(0))
            {
                Vector2 click = Input.mousePosition;
                if (codes[1] == KeyCode.W && ((click.x > middle_w) && (click.y > middle_h)))
                {
                    Do(direction);
                    return(true);
                }
                else if (codes[1] == KeyCode.A && ((click.x < middle_w) && (click.y > middle_h)))
                {
                    Do(direction);
                    return(true);
                }
                else if (codes[1] == KeyCode.S && ((click.x < middle_w) && (click.y < middle_h)))
                {
                    Do(direction);
                    return(true);
                }
                else if (codes[1] == KeyCode.D && ((click.x > middle_w) && (click.y < middle_h)))
                {
                    Do(direction);
                    return(true);
                }
            }
            return(false);
        }
コード例 #12
0
        bool keyMacro(InGameDirection direction, bool bShift,
                      System.Func <IEnumerable <KeyCode>, System.Func <KeyCode, bool>, bool> action,
                      System.Func <KeyCode, bool> subAction,
                      System.Action <InGameDirection> Do,
                      params KeyCode[] codes)
        {
            if (bShift) // Rotate
            {
                direction = (InGameDirection)(-1 * (int)direction);
            }

            if (action(codes, subAction))
            {
                Do(direction);
                return(true);
            }
            return(false);
        }
コード例 #13
0
        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);
            }
        }
コード例 #14
0
 public bool bMovingDirection(InGameDirection direction)
 {
     return(bOnMoving && LastDirection.Equals(direction));
 }
コード例 #15
0
 protected static bool IsOppositSide(InGameDirection dirA, InGameDirection dirB)
 {
     return(Mathf.Abs(dirA - dirB) == (int)InGameDirection.OppositeDir);
 }
コード例 #16
0
        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);
            }
        }
コード例 #17
0
 protected static float AngleOfForward(InGameDirection dir)
 {
     return((int)dir * 45f);
 }
コード例 #18
0
        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);
            }
        }
コード例 #19
0
        void RotateTo(InGameDirection dir)
        {
            Vector3 vDir = HorizontalVector(dir);

            UpdateAnimatorParams(false, vDir.x, vDir.z);
        }