예제 #1
0
    public void initPos(int i)
    {
        GameRPGPosInfo info = activeInfo.Pos[i];

//        GameRPGSceneMovement.instance.moveTo( info.MapPosX , info.MapPosY );

        GameMusicManager.instance.playMusic(0, "Music/Music_" + GameDefine.getString2(info.Music));

        string path = "Prefab/RPG/Rpgman";

        GameObject obj = Instantiate <GameObject>(Resources.Load <GameObject>(path));

        gameAnimation = obj.GetComponent <GameAnimation>();
        obj.name      = "Rpgman";

        gameAnimation.playAnimationRPG(GameAnimationType.Stand, GameAnimationDirection.South, null);

        Transform trans = obj.transform;

        trans.SetParent(transUnit);
        trans.localScale = new Vector3(1.0f, 1.0f, 1.0f);

        movement = obj.AddComponent <GameRPGMovement>();
        movement.setPos(info.PosX, info.PosY);
        movement.setDirection((GameAnimationDirection)info.Direction);

        GameRPGSceneMovement.instance.followPos(movement.PosBattleX, movement.PosBattleY);
    }
예제 #2
0
    public void moveTo(GameAnimationDirection dir)
    {
        if (movement.isMoving)
        {
            return;
        }

        int posX = movement.PosX;
        int posY = movement.PosY;

        bool exit = false;

        switch (dir)
        {
        case GameAnimationDirection.South:
        {
            if (posY + 1 == activeDTL.Height)
            {
                exit = true;
                break;
            }

            posY++;
        }
        break;

        case GameAnimationDirection.West:
        {
            if (posX == 0)
            {
                exit = true;
                break;
            }

            posX--;
        }
        break;

        case GameAnimationDirection.North:
        {
            if (posY == 0)
            {
                exit = true;
                break;
            }

            posY--;
        }
        break;

        case GameAnimationDirection.East:
        {
            if (posX + 1 == activeDTL.Width)
            {
                exit = true;
                break;
            }

            posX++;
        }
        break;
        }

        if (exit || GameRPGPathFinder.instance.isBlock(posX, posY))
        {
            gameAnimation.playAnimationRPG(GameAnimationType.Stand,
                                           dir, null);

            return;
        }

        movement.moveTo(posX, posY, false, true, false, 2, onMoveOver);
    }
예제 #3
0
    public void stopMove()
    {
        startMoving = false;
        isMoving    = false;
        nextMove    = false;

        gameAnimation.playAnimationRPG(GameAnimationType.Stand,
                                       gameAnimation.animationDirection, null);
    }