void SelectCharacter(string characterTag) { bool isUnLocked = GameProgressData.CharacterIsUnlocked(characterTag); if (!isUnLocked) { return; } PlayerPrefs.SetString(PlayerPrefsNames.SelectedCharacterTag, characterTag); PlayerPrefs.Save(); PlayableCharacters.Instance.SetCharacterToHumanControlled(characterTag, showChangeEffect: true); }
void CreateCharacters() { for (int i = 0; i < PlayableCharacters.Instance.CharacterPrefabList.CharacterPrefabs.Length; ++i) { var characterPrefab = PlayableCharacters.Instance.CharacterPrefabList.CharacterPrefabs[i]; var position = CharacterDefaultPositions[i].position; bool isUnlocked = GameProgressData.CharacterIsUnlocked(characterPrefab.tag); if (isUnlocked) { CreateCharacter(characterPrefab.tag, position); } else { CreateGhost(characterPrefab.tag, position); } } }
void ActivateLatestSelectedCharacter() { string startCharacterTag = PlayerPrefs.GetString(PlayerPrefsNames.SelectedCharacterTag); if (string.IsNullOrEmpty(startCharacterTag)) { startCharacterTag = "Character1"; } // When developing we might experience the selected character is no longer unlocked. Revert to default. bool isUnlocked = GameProgressData.CharacterIsUnlocked(startCharacterTag); if (!isUnlocked) { startCharacterTag = PlayableCharacters.Instance.CharacterPrefabList.CharacterPrefabs[0].tag; } PlayableCharacters.Instance.SetCharacterToHumanControlled(startCharacterTag); Helpers.SetCameraPositionToActivePlayer(); }