Beispiel #1
0
 void PlayerInfoChanged()
 {
     // we could move this into the Player class, but we may have more than one value to change in the player
     // this function should be called once per set of changes
     PlayerInfoLoader.SavePlayer(_player.Coins, _player.MostCoins, _player.Streak, _player.BestStreak);
     OnPlayerInfoUpdated?.Invoke();
 }
Beispiel #2
0
    //void Awake()
    //{
    // instead of Find which hurts performance, i made the variables as SerializeField and set them in the inspector
    //_nameLabel = transform.Find ("Canvas/Name").GetComponent<Text>();
    //_moneyLabel = transform.Find ("Canvas/Money").GetComponent<Text>();
    //}

    void Start()
    {
        _playerInfoLoader           = new PlayerInfoLoader();
        _playerInfoLoader.OnLoaded += OnPlayerInfoLoaded;
        _playerInfoLoader.Load();
        bettingAmount.text = "10";
    }
Beispiel #3
0
 void Start()
 {
     if (AudioManager.Instance == null)
     {
         // we know that the audio manager is only in the game mode scene, so they must have started the game from the game scene
         SceneManager.LoadScene("GameModeSelectScene");
         return;
     }
     // we don't need to create an instance of an object
     PlayerInfoLoader.LoadPlayer(PlayerInfoLoaded);
     _opponent = new OpponentDecider();
     AudioManager.Instance.PlayLoopingMusic(gameMusic);
 }
Beispiel #4
0
    void Start()
    {
        // I move the update game loader initialization to here, to avoid garbage.
        _playerInfoLoader           = new PlayerInfoLoader();
        _playerInfoLoader.OnLoaded += OnPlayerInfoLoaded;
        _playerInfoLoader.Load(GameInstance.Instance.CurrentGameData.Player);
        _updateGameLoader           = new UpdateGameLoader();
        _updateGameLoader.OnLoaded += OnGameUpdated;

        // I am changing the name label only once instead of every frame.
        //Displaying the player's name
        _nameLabel.text = "Name: " + _player.GetName();

        // I am going to reuse the wait for seconds in my coroutine
        _resultWaitInterval = new WaitForSeconds(_resultInterval);
    }
Beispiel #5
0
 public void ResetPlayer()
 {
     PlayerInfoLoader.CreatePlayer(PlayerInfoLoaded);
 }
Beispiel #6
0
 public void NewPlayerButton()
 {
     AudioManager.Instance.PlayButtonPressedSFX();
     PlayerInfoLoader.CreatePlayer(null);
 }