コード例 #1
0
ファイル: Hero.cs プロジェクト: Milun/KBARF
    public void LeaveGameScreen()
    {
        // Move away from the screen.
        Vector3 normPos   = (this.transform.position - gameScreen.transform.position).normalized;
        Vector3 targetPos = new Vector3(gameScreen.targetPos.x + normPos.x * GAME_SCREEN_LEAVE_DISTANCE,
                                        gameScreen.targetPos.y + normPos.y * GAME_SCREEN_LEAVE_DISTANCE,
                                        gameScreen.targetPos.z + normPos.z * GAME_SCREEN_LEAVE_DISTANCE);

        // If we've finished leaving the screen, free both it and the screen.
        Vector3 move = Stat3DMove.MoveToPos(transform.position,
                                            targetPos,
                                            GAME_SCREEN_LOOK_SPEED);

        if (move == transform.position)
        {
            gameScreen.Leave();
            gameScreen = null;

            state = "";

            return;
        }

        transform.position = move;
    }
コード例 #2
0
ファイル: Hero.cs プロジェクト: Milun/KBARF
    // Update is called once per frame
    void Update()
    {
        // Check if the player has clicked on a game screen.
        ClickGameScreen();

        // If the player is looking at the screen, move them to the ideal position.
        if (state == "screen_lock")
        {
            // Stop any velocity you had.
            rigidbody.velocity = Vector3.zero;
            rot = 0.0f;

            // Move towards the screen
            transform.position    = Stat3DMove.MoveToPos(transform.position, gameScreen.targetPos, GAME_SCREEN_LOOK_SPEED);
            transform.eulerAngles = Stat3DMove.MoveToRot(transform.eulerAngles, gameScreen.targetRot, GAME_SCREEN_LOOK_SPEED);

            // Manipulate the MouseAim to make the game think we're moving the mouse like this.
            mouseLook.SetMouseAim(gameScreen.targetRot.y, gameScreen.targetRot.x);

            return;
        }

        // Allow player to move around while leaving the screen.
        mouseLook.MouseAim();

        // Stop looking at a screen you're locked into when you leave.
        if (state == "screen_leave")
        {
            LeaveGameScreen();

            return;
        }

        // Otherwise allow movement normally.
        Move();
    }