コード例 #1
0
ファイル: EditorUtil.cs プロジェクト: Fornan-II/FeastWeek
    private static void TakeControlOfPlayer()
    {
        Controller c = GameObject.FindObjectOfType <Controller>();

        if (!c)
        {
            Debug.LogError("Could not find Controller in scene.");
            return;
        }

        FPSChar playerPawn = GameObject.FindObjectOfType <FPSChar>();

        if (!playerPawn)
        {
            Debug.LogError("Could not find FPSChar in scene.");
            return;
        }

        if (!UnityEditor.EditorApplication.isPlaying)
        {
            Undo.RecordObject(c, "Take Control of Player");
        }

        c.TakeControlOf(playerPawn);
    }
コード例 #2
0
ファイル: EditorUtil.cs プロジェクト: Fornan-II/FeastWeek
    private static void PrepPlayerForGame()
    {
        if (UnityEditor.EditorApplication.isPlaying)
        {
            Debug.LogError("Can not prep player for game while game is already playing!");
            return;
        }

        Controller c          = GameObject.FindObjectOfType <Controller>();
        FPSChar    playerPawn = null;

        if (c)
        {
            if (c.ControlledPawn && c.ControlledPawn is FPSChar)
            {
                Undo.RecordObject(c, "Prep Player for Game");
                playerPawn = c.ControlledPawn as FPSChar;
                c.ReleaseControl();
            }
        }

        if (!playerPawn)
        {
            playerPawn = GameObject.FindObjectOfType <FPSChar>();
        }
        if (!playerPawn)
        {
            Debug.LogError("Could not find FPSChar in scene.");
            return;
        }

        Checkpoint defaultCheckpoint = Checkpoint.DefaultCheckPoint;

        if (!defaultCheckpoint)
        {
            Debug.LogError("Could not find Default Checkpoint in scene.");
            return;
        }

        Undo.RecordObject(playerPawn.transform, "Prep Player for Game");
        Util.MoveTransformToTarget(playerPawn.transform, defaultCheckpoint.transform);
    }
コード例 #3
0
ファイル: DebugMenu.cs プロジェクト: Fornan-II/FeastWeek
    private void SkipIntroSequence()
    {
        bool        skipIntroFailed  = false;
        IntroHelper intro            = FindObjectOfType <IntroHelper>();
        Controller  playerController = FindObjectOfType <Controller>();
        FPSChar     playerPawn       = FindObjectOfType <FPSChar>();

        if (playerController)
        {
            if (playerController.ControlledPawn == playerPawn)
            {
                Debug.Log("[DebugMenu] Already past intro sequence.");
                return;
            }
        }
        else
        {
            Debug.LogError("[DebugMenu] Failed to skip intro sequence, no player controller found!");
            skipIntroFailed = true;
        }
        if (!playerPawn)
        {
            Debug.LogError("[DebugMenu] Failed to skip intro sequence, no player pawn found!");
            skipIntroFailed = true;
        }
        if (!intro)
        {
            Debug.LogError("[DebugMenu] Failed to skip intro sequence, no IntroHelper found!");
            skipIntroFailed = true;
        }
        if (skipIntroFailed)
        {
            return;
        }

        intro.FinishFlying();
        intro.gameObject.SetActive(false);
    }