コード例 #1
0
    // Move the player through their stack
    IEnumerator MovementMachine()
    {
        GetComponent <SpriteRenderer>().sortingOrder = -1 * (int)transform.position.y;
        mLastMovement = transform.position;
        while (mMovementStack.Count != 0)
        {
            if (mPause)
            {
                yield return(null);

                continue;
            }
            Vector3 Movement = mMovementStack.Peek() + new Vector3(.5f, .5f, 0);
            SetAnimationDirection(transform.position, Movement);
            transform.position = Vector3.MoveTowards(transform.position, Movement, mCharacterStats.Speed * Time.deltaTime);
            if (transform.position == Movement)
            {
                GetCharacterOnTile();
                mLastMovement = transform.position;
                mMovementStack.Pop();


                switch (mAction)
                {
                // Character is rushing, moves count half
                case 2:
                    mMoveCount += 0.5f;
                    break;

                // Character is fortified, moves count double
                case 3:
                    mMoveCount += 2;
                    break;

                default:
                    ++mMoveCount;
                    break;
                }

                // Notify everyone it's action time
                if (mMoveCount > mFlowController.mActionNum)
                {
                    mFlowController.mActionNum = mMoveCount;
                    mFlowController.NotifyAction();
                }
            }
            yield return(null);
        }
        mAnimator.SetBool("Walking", false);
        mCharacterStats.ActionStop();
        Unlock();
    }