Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        replays         = new List <PlayerReplay>();
        isLevelFinished = false;

        GameObject player = GameObject.Find("Player");

        if (player)
        {
            recordingReplay = new PlayerReplay();
            PlayerReplayRecordBehaviour prrb = player.AddComponent <PlayerReplayRecordBehaviour>();
            prrb.SetReplay(recordingReplay);
            spawnPosition = player.transform.position;
        }
        else
        {
            Debug.LogError("No Player object in scene");
        }

        if (replayPrefab == null)
        {
            Debug.LogError("replayPrefab is missing from GameController");
        }

        if (playerPrefab == null)
        {
            Debug.LogError("playerPrefab is missing from GameController");
        }

        if (levelCompletePrefab == null)
        {
            Debug.LogError("levelCompletePrefab is missing from GameController");
        }
    }
Beispiel #2
0
    public void SetReplay(PlayerReplay _replay)
    {
        Debug.Log("Starting replay " + _replay.snapshots.Count + "snapshots");

        replay        = _replay;
        snapshotIndex = 0;
    }
    public PlayerReplayModel DoneRecording(string levelName, float replayTime)
    {
        AddState(_timePassed);
        _recording = false;
        PlayerReplayModel playerReplayModel = new PlayerReplayModel(PlayerPrefs.GetString(Constants.USERNAME_KEY), levelName, replayTime, _playerPlayback.ReplayData);

        PlayerReplay.Instance.StartCoroutine(PlayerReplay.SavePlayerPlayback(playerReplayModel, (Success) => {
            // placeholder if needed
        }));

        return(playerReplayModel);
    }
 void Awake()
 {
     Application.targetFrameRate = 60;
     _playerRecorder             = Player.GetComponentInChildren <PlayerRecorderController>();
     _playerAudio             = GetComponent <AudioSource>();
     _song                    = Resources.Load("Songs/BeatOfTheTerror") as AudioClip;
     _playerAudio.clip        = _song;
     _playerAudio.loop        = true;
     _mainCamera              = Camera.main;
     _mainCameraStartPosition = _mainCamera.transform.position;
     PlayerReplay.InitLocalRecords();
     _username  = PlayerPrefs.GetString(Constants.USERNAME_KEY);
     _levelName = _startLevelName;
 }
Beispiel #5
0
    // Reset the level, immedietly
    public void ResetLevel()
    {
        levelResetTimer = 0.0f;

        // Send reset message to all game objects, slow but works
        GameObject[] allObjects = UnityEngine.Object.FindObjectsOfType <GameObject>();
        foreach (GameObject go in allObjects)
        {
            if (go.activeInHierarchy)
            {
                go.SendMessage("OnLevelReset", null, SendMessageOptions.DontRequireReceiver);
            }
        }

        GameObject player;

        // Remove any old copies of the player, should be destroyed already but
        // better safe than sorry
        foreach (GameObject p in GameObject.FindGameObjectsWithTag("Player"))
        {
            GameObject.Destroy(p);
        }

        // Store the replay
        if (recordingReplay != null)
        {
            replays.Add(recordingReplay);
            recordingReplay = null;
        }

        // Re-instantiate the player
        if (playerPrefab)
        {
            player = Instantiate(playerPrefab);
            player.transform.position = spawnPosition;

            // Reattach camera
            Camera.main.GetComponent <CameraBehaviour>().SetTarget(player.transform);

            PlayerReplayRecordBehaviour prrb = player.AddComponent <PlayerReplayRecordBehaviour>();
            recordingReplay = new PlayerReplay();
            prrb.SetReplay(recordingReplay);
        }

        SpawnGhosts();
    }
Beispiel #6
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.Escape))
        {
            GameObject.Find("SoundManager").GetComponent <FmodBehaviour>().gameBGM.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);

            Application.LoadLevel(1);
        }

        if (isLevelFinished)
        {
            return;
        }

        if (Input.GetKeyDown("r"))
        {
            // Ignore replay when reseting
            recordingReplay = null;
            ResetLevel();
        }
    }
 void ResetData()
 {
     PlayerReplay.ClearData();
     SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
 }
 void GhostRecordsValueChanged(int value)
 {
     PlayerPrefs.SetInt(Constants.NUM_OF_LOCAL_GHOST_RECORDS, value);
     PlayerReplay.InitLocalRecords();
     GrappleUI.TotalGhostRecordsLocal.text = PlayerReplay.NumOfLocalRecords.ToString();
 }
Beispiel #9
0
 public void SetReplay(PlayerReplay _replay)
 {
     replay = _replay;
 }