Ejemplo n.º 1
0
    public void moveUpdate()
    {
        if (!isMoving)
        {
            return;
        }

        float dis = Time.deltaTime * moveSpeed;

        if (posX != moveToX ||
            posBattleX != moveToBattleX)
        {
            if (moveToX > posX)
            {
                posBattleX += dis;

                if (posBattleX >= moveToBattleX)
                {
                    posX       = moveToX;
                    posBattleX = moveToBattleX;
                }
                else
                {
                    posX = GameDefine.getXFormBattle((int)posBattleX);
                }

                updatePosition();

                if (sceneFollow)
                {
                    GameRPGSceneMovement.instance.followPos(posBattleX, posBattleY);
                }

                if (gameAnimation.animationType != GameAnimationType.Move ||
                    gameAnimation.animationDirection != GameAnimationDirection.East)
                {
                    gameAnimation.playAnimationRPG(GameAnimationType.Move,
                                                   GameAnimationDirection.East, null);
                }
            }
            else
            {
                posBattleX -= dis;

                if (posBattleX <= moveToBattleX)
                {
                    posX       = moveToX;
                    posBattleX = moveToBattleX;
                }
                else
                {
                    posX = GameDefine.getXFormBattle((int)posBattleX);
                }

                updatePosition();

                if (sceneFollow)
                {
                    GameRPGSceneMovement.instance.followPos(posBattleX, posBattleY);
                }

                if (gameAnimation.animationType != GameAnimationType.Move ||
                    gameAnimation.animationDirection != GameAnimationDirection.West)
                {
                    gameAnimation.playAnimationRPG(GameAnimationType.Move,
                                                   GameAnimationDirection.West, null);
                }
            }
        }
        else if (posY != moveToY ||
                 posBattleY != moveToBattleY)
        {
            if (moveToY > posY)
            {
                posBattleY -= dis;

                if (posBattleY <= moveToBattleY)
                {
                    posY       = moveToY;
                    posBattleY = moveToBattleY;
                }
                else
                {
                    posY = GameDefine.getYFormBattle((int)posBattleY);
                }

                updatePosition();

                if (sceneFollow)
                {
                    GameRPGSceneMovement.instance.followPos(posBattleX, posBattleY);
                }

                if (gameAnimation.animationType != GameAnimationType.Move ||
                    gameAnimation.animationDirection != GameAnimationDirection.South)
                {
                    gameAnimation.playAnimationRPG(GameAnimationType.Move,
                                                   GameAnimationDirection.South, null);
                }
            }
            else
            {
                posBattleY += dis;

                if (posBattleY >= moveToBattleY)
                {
                    posY       = moveToY;
                    posBattleY = moveToBattleY;
                }
                else
                {
                    posY = GameDefine.getYFormBattle((int)posBattleY);
                }

                updatePosition();

                if (sceneFollow)
                {
                    GameRPGSceneMovement.instance.followPos(posBattleX, posBattleY);
                }

                if (gameAnimation.animationType != GameAnimationType.Move ||
                    gameAnimation.animationDirection != GameAnimationDirection.North)
                {
                    gameAnimation.playAnimationRPG(GameAnimationType.Move,
                                                   GameAnimationDirection.North, null);
                }
            }
        }
        else
        {
            // move end

            updatePosition();

            if (moveBuffer.Count > 0)
            {
                moveNext();
                return;
            }

            isMoving = false;

            if (playStartAnimation)
            {
                gameAnimation.playAnimationRPG(GameAnimationType.MoveEnd,
                                               gameAnimation.animationDirection, onMoveOver);
            }
            else
            {
                onMoveOver();
            }
        }
    }