Exemple #1
0
    void StartGame()
    {
        var stringPath = HumanPlayerController.TrackedPath.AsString();

        PlayerPrefs.SetString("LatestCampPath", stringPath);
        PlayerPrefs.Save();

        // Init the run data
        var player = PlayableCharacters.GetPlayerInScene();

        CurrentRunData.StartNewRun();
        CurrentRunData.Instance.MaxLife              = player.MaxLife;
        CurrentRunData.Instance.Life                 = player.Life;
        CurrentRunData.Instance.CurrentWeapon        = player.CurrentWeapon.Id;
        CurrentRunData.Instance.BulletAmmo           = 999;
        CurrentRunData.Instance.ShellAmmo            = 999;
        CurrentRunData.Instance.StartingCharacterTag = player.tag;
        CurrentRunData.Instance.HasPlayerData        = true;

        GameProgressData.CurrentProgress.QuestProgress.ApplyAllRewards();
        CurrentRunData.StoreState();

        HumanPlayerController.CanShoot = true;
        SceneManager.LoadScene(EnterPortalSceneName, LoadSceneMode.Single);
    }
Exemple #2
0
    void CreatePlayer(Vector3 position)
    {
        string characterTag = CurrentRunData.Instance.StartingCharacterTag;
        var    player       = PlayableCharacters.Instance.InstantiateCharacter(characterTag, position);

        player.transform.SetParent(DynamicObjectRoot);
        playerScript_ = player.GetComponent <PlayableCharacterScript>();

        if (!CurrentRunData.Instance.HasPlayerData)
        {
            // Initialize current run if game is started directly from this scene, and not from camp
            CurrentRunData.StartNewRun();
            SavePlayerDataInCurrentRun(playerScript_, CurrentRunData.Instance);
            CurrentRunData.Instance.HasPlayerData = true;
            CurrentRunData.StoreState();
        }
        else
        {
            InitializePlayerWithCurrentRunData(playerScript_, CurrentRunData.Instance);
        }
    }