示例#1
0
 public void ClickNextOnName()
 {
     if (string.IsNullOrEmpty(newPlayerName.text))
     {
         return; //TODO: Show a message saying player name can't be empty
     }
     createPlayerScreen.SetActive(false);
     playersScreen.SetActive(true);
     if (!isEasyPrefab)
     {
         CreatePlayerRequest createPlayerRequest = new CreatePlayerRequest {
             playerName = newPlayerName.text
         };
         StagesManager.instance.GoToStage(StagesManager.StageID.SwapClass, createPlayerRequest);
     }
     else
     {
         StartSession();
     }
 }
示例#2
0
        public void UpdateScreenData(ILootLockerStageData stageData)
        {
            if (stageData != null)
            {
                createPlayerRequest = stageData as CreatePlayerRequest;
                LootLockerConfig.current.playerName = createPlayerRequest.playerName;
                LoadingManager.ShowLoadingScreen();
                failResponse = () => { StagesManager.instance.GoToStage(StagesManager.StageID.Player, null); };
                //Starting session first before character is chosen
                StartSession(() =>
                {
                    foreach (Transform tr in parent)
                    {
                        Destroy(tr.gameObject);
                    }

                    LootLockerSDKManager.GetCharacterLoadout((response) =>
                    {
                        if (response.success)
                        {
                            foreach (LootLockerLootLockerLoadout loadout in response.loadouts)
                            {
                                GameObject selectionButton = Instantiate(characterClassPrefab, parent);
                                selectionButton.GetComponent <ClassSelectionButton>()?.Init(loadout);
                            }
                        }
                        else
                        {
                            StagesManager.instance.GoToStage(StagesManager.StageID.CreatePlayer, null);
                        }
                        LoadingManager.HideLoadingScreen();
                    });
                });
                //if we are creating a new character then we want to set character details once it is created
                button.onClick.RemoveAllListeners();
                button.onClick.AddListener(() =>
                {
                    UpdateDefaultCharacterClass(() =>
                    {
                        if (!isEasyPrefab)
                        {
                            LocalPlayer localPlayer = new LocalPlayer {
                                playerName = createPlayerRequest.playerName, uniqueID = guid.ToString(), characterClass = loadout?.character
                            };
                            List <LocalPlayer> localPlayers = JsonConvert.DeserializeObject <List <LocalPlayer> >(PlayerPrefs.GetString("localplayers"));
                            localPlayers.Add(localPlayer);
                            PlayerPrefs.SetString("localplayers", JsonConvert.SerializeObject(localPlayers));
                            LootLockerConfig.current.deviceID    = localPlayer.uniqueID;
                            LootLockerConfig.current.playerClass = loadout.character.type.ToString();
                            //Character has been set, we can now load the home page
                            StagesManager.instance.GoToStage(StagesManager.StageID.Home, sessionResponse);
                        }
                        else
                        {
                            Debug.Log("Updated the default class for the current player");
                        }
                    });
                });
            }
            else
            {
                failResponse = () => { StagesManager.instance.GoToStage(StagesManager.StageID.Settings, null); };

                foreach (Transform tr in parent)
                {
                    Destroy(tr.gameObject);
                }

                LootLockerSDKManager.GetCharacterLoadout((response) =>
                {
                    if (response.success)
                    {
                        foreach (LootLockerLootLockerLoadout loadout in response.loadouts)
                        {
                            GameObject selectionButton = Instantiate(characterClassPrefab, parent);
                            selectionButton.GetComponent <ClassSelectionButton>()?.Init(loadout);
                        }
                    }
                    else
                    {
                        StagesManager.instance.GoToStage(StagesManager.StageID.Settings, null);
                    }
                    LoadingManager.HideLoadingScreen();
                });
                //if we are just updating the character class for player, then after it is completed. We want to return to the inventory screen
                button.onClick.RemoveAllListeners();
                button.onClick.AddListener(() =>
                {
                    UpdateDefaultCharacterClass(() =>
                    {
                        //Character has been set, we can now load inventory
                        StagesManager.instance.GoToStage(StagesManager.StageID.Settings, null);
                    });
                });
            }
        }