コード例 #1
0
ファイル: InputBox.cs プロジェクト: dqtoy/ActDemo
        void UpdateMoveInput(float deltaTime)
        {
            if (mController == null ||
                mActionStatus == null ||
                mActionStatus.ActiveAction == null)
            {
                return;
            }

            // check the rotate & move.
            Vector2 direction = mInputVector;

            if (direction == Vector2.zero)
            {
                return;
            }

            // process moving.
            if (mActionStatus.CanMove && mActionStatus.ActiveAction.MoveSpeed > 0)
            {
                direction.Normalize();

                float   moveSpeed = mOwner.Speed * 0.01f;
                Vector2 moveTrans = direction * moveSpeed * deltaTime;

                float x = -moveTrans.x, y = moveTrans.y;
                MathUtility.Rotate(ref x, ref y, mController.CameraModify);

                // rotating
                if (mActionStatus.CanRotate && mInputVector.x != 0)
                {
                    mOwner.SetOrientation(Mathf.Atan2(x, 0));
                }

                // moving.
                mOwner.Move(new Vector3(x, 0, y));

                if (mActionStatus.Listener != null)
                {
                    mActionStatus.Listener.OnInputMove();
                }
            }
            else if (mActionStatus.CanRotate) // just rotate.
            {
                float x = -mInputVector.x, y = mInputVector.y;
                MathUtility.Rotate(ref x, ref y, mController.CameraModify);

                if (mInputVector.x != 0)
                {
                    mOwner.SetOrientation(Mathf.Atan2(x, 0));
                }
            }
        }
コード例 #2
0
        //-----------------------------------------------------------------------
        void faceTarget(IActUnit target)
        {
            if (target == null)
            {
                return;
            }

            float x   = target.Position.x - mOwner.Position.x;
            float z   = target.Position.z - mOwner.Position.z;
            float dir = Mathf.Atan2(x, 0);

            mOwner.SetOrientation(dir);
        }