/// <summary> /// Prepares the Items for Saving and saves the given playerData with the given current position /// </summary> /// <param name="playerData"></param> /// <param name="currentPosition"></param> public void SavePlayer(PlayerData playerData, Vector2 currentPosition) { PlayerTimeData playerTimeData = DisplayTime.instance.GetCurrentPlayerTimeData(); int armor = EquipmentManager.instance.GetCurrentAmor(); Item[] toolbarItems = ToolbarManager.instance.items; Item[] inventoryItems = Inventory.instance.items; List <ArmorItem> currentEquipment = EquipmentManager.instance.currentEquipment; ItemForSaveConverter itemForSaveConverter = new ItemForSaveConverter(); ItemForSave[] toolBarItemsForSave = PrepareItemsForSave(toolbarItems, itemForSaveConverter); ItemForSave[] inventoryItemsForSave = PrepareItemsForSave(inventoryItems, itemForSaveConverter); ItemForSave[] currentEquipmentForSave = PrepareItemsForSave(currentEquipment.ToArray(), itemForSaveConverter); float[] position = new float[2]; position[0] = currentPosition.x; position[1] = currentPosition.y; playerData.position = position; playerData.armor = armor; playerData.playerTimeData = playerTimeData; playerData.currentEquipment = currentEquipmentForSave; playerData.toolbarItems = toolBarItemsForSave; playerData.inventoryItems = inventoryItemsForSave; Save(playerData); }
public void Load() { timeData = JsonConvert.DeserializeObject <PlayerTimeData>(PlayerPrefs.GetString(KeyUtils.TIME_DATA)); if (timeData == null) { timeData = new PlayerTimeData(); Save(); } }
void Start() { clockText = GameObject.Find("Clock").GetComponent <Text>(); dayText = GameObject.Find("Day").GetComponent <Text>(); yearText = GameObject.Find("Year").GetComponent <Text>(); if (playerTimeData == null) { playerTimeData = new PlayerTimeData(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); } }
public static void LogTime(Torch.API.IPlayer player) { if (player == null) { return; } ulong steamId = player.SteamId; PlayerTimeData data = new PlayerTimeData(); bool found = false; if (PlayerTimes == null) { PlayerTimes = new List <PlayerTimeData>(); } foreach (var time in PlayerTimes) { if (time.SteamId != steamId) { continue; } found = true; break; } if (found) { return; } BlockLimiter.Instance.Log.Info($"Logging time for player {player.Name}"); data.SteamId = steamId; data.Player = player.Name; var lastLogout = MySession.Static.Players.TryGetIdentity(Utilities.GetPlayerIdFromSteamId(steamId))?.LastLoginTime; if (lastLogout != null && DateTime.Now > lastLogout) { data.FirstLogTime = (DateTime)lastLogout; } else { data.FirstLogTime = DateTime.Now; } PlayerTimes.Add(data); SaveTimeData(); }
/// <summary> /// Overrides the ui time with the given time /// </summary> /// <param name="playerTimeData"></param> private void SetTimeValue(PlayerTimeData playerTimeData) { DisplayTime.instance.SetCurrentPlayerTimeData(playerTimeData); }
/// <summary> /// Set the current player time data and calls the ui update for the time /// </summary> /// <param name="playerTimeData"></param> public void SetCurrentPlayerTimeData(PlayerTimeData playerTimeData) { this.playerTimeData = playerTimeData; TextCallFunction(); }