/// <summary> /// Removes any cached data from previous player, stores data of new player, loads main menu scene. /// </summary> /// <param name="playerInfo">info of newly logged player</param> public void OnLoggedIn(LoggedPlayerInfo playerInfo) { connectionMode = ConnectionMode.Online; RemoveCachedData(); loggedPlayerInfo = playerInfo; if (ChatController.Instance != null) { ChatController.Instance.Initialize(); } TradeBazaar.Instance.Init(); Initialize(); PersistIfStayLoggedIn(); if (loggedPlayerInfo.Fraction == Fraction.None) { var param = new Dictionary <string, string> { { Scenes.BATTLE_TYPE, BattleType.TutorialBattle.ToString() }, { Scenes.GAME_MODE, GameMode.Standard.ToString() } }; Scenes.Load(Scenes.BATTLE_SCENE, param); } else { Scenes.Load(Scenes.MAIN_MENU_SCENE); } }
/// <summary> /// Clears logged player's locally stored data. /// </summary> public void Logout() { loggedPlayerInfo = null; UserPassword = ""; avatar = null; FruitonTeamList = null; StayLoggedIn = false; Serializer.ClearPlayerLocalData(); }
/// <summary> /// Loads last saved player's data from local cache and server, sets up fruiton database. /// </summary> private void Initialize() { FruitonDatabase = new FruitonDatabase(KernelUtils.LoadTextResource(FRUITON_DB_FILE)); AllFruitons = ClientFruitonFactory.CreateAllKernelFruitons(); if (IsInTrial) { AvailableFruitons = AllPlayableFruitons.Select(fruiton => fruiton.dbId).ToList(); FruitonTeamList = new FruitonTeamList(); loggedPlayerInfo = new LoggedPlayerInfo(); } else { PlayerOptions = Serializer.LoadPlayerSettings(); Serializer.DeserializeFruitonTeams(); AvailableFruitons = Serializer.LoadAvailableFruitons(); } if (IsOnline) { PlayerHelper.GetAllFruitonTeams(MergeTeamLists, Debug.Log); PlayerHelper.GetAvailableFruitons((list) => Debug.Log("Available fruitons loaded from server."), Debug.Log); } }