// // Unity Events // // Use this for initialization void Start() { this.stringBuilder = new StringBuilder(); Debug.Assert(this.xpProgressor != null, "Could not assign a null XpProgressor"); if (this.loadSlot1OnStart) { bool slot1Loaded = this.LoadCharacterFromFileWithCheck(1); if (!slot1Loaded) { Debug.Log("Since Slot 1 was empty, a new character will be made instead"); this.character = new RpgCharacterData(new Guid(this.givenGuid), this.xpProgressor, this.startingHealthPoints, this.startingHealthPoints, RpgDataRegistry.Instance.DefaultStatPointAssignment, this.givenCharacterName); this.AddXp(this.startingXp); } } else { this.character = new RpgCharacterData(new Guid(this.givenGuid), this.xpProgressor, this.startingHealthPoints, this.startingHealthPoints, RpgDataRegistry.Instance.DefaultStatPointAssignment, this.givenCharacterName); this.AddXp(this.startingXp); } this.RefreshUI(); }
/// <summary> /// Randomizes the data of the current character. Does not save changes to file /// </summary> public void RandomizeCharacter() { RpgCharacterPacket newPacket = new RpgCharacterPacket(); int randomIndex = Random.Range(0, this.randomNames.Length); newPacket.name = this.randomNames[randomIndex]; newPacket.id = this.randomGuids[randomIndex]; newPacket.hp = Random.Range(5, 150); newPacket.maxHp = 150; newPacket.additionalMaxHp = 0; newPacket.unallocatedSpPool = Random.Range(0, 33); newPacket.assignmentType = RpgDataRegistry.Instance.DefaultStatPointAssignment; XpPacket xpPacket = new XpPacket(); xpPacket.xpProgessorId = this.xpProgressor.Id.ToString(); xpPacket.level = Random.Range(1, 10); xpPacket.xp = Random.Range(0, 301); xpPacket.xpToNextLevel = 300; xpPacket.currentLevelMultiplier = this.xpProgressor.LevelMultiplier; xpPacket.currentOldValueMultiplier = this.xpProgressor.OldXtnlMultiplier; newPacket.xpDataPacket = xpPacket; this.character = new RpgCharacterData(newPacket); Debug.Log("Current character was randomized. Note that nothing was saved to disk."); this.RefreshUI(); }
// // Unity Events // // Use this for initialization void Start() { this.stringBuilder = new StringBuilder(); Debug.Assert(this.xpProgressor != null, "Could not assign a null XpProgressor"); this.character = new RpgCharacterData(Guid.NewGuid(), this.xpProgressor, this.startingHealthPoints, this.startingHealthPoints, RpgDataRegistry.Instance.DefaultStatPointAssignment, this.givenCharacterName); this.AddXp(this.startingXp); this.RefreshUI(); }
/// <summary> /// Loads a player from file using the name and id of the player saved in the given slot. /// Returns true if the slot is not empty and the character was loaded /// </summary> /// <param name="slotNumber">Slot number.</param> public void LoadCharacterFromFile(int slotNumber) { SaveSlot slot = SaveSlotRegistry.Instance.GetSlotAt(slotNumber); Debug.Assert(slot != null, "Invalid SaveSlot"); if (slot.isSlotOccupied == false) { Debug.LogWarning("Save Slot " + slotNumber.ToString() + " is empty. No character was loaded."); return; } this.character = RpgCharacterSerializer.LoadCharacter(slot.playerName, slot.playerId); Debug.Assert(this.character != null, "Unknown Error when loading character from file! " + slot.playerName + " " + slot.playerId); Debug.Log("The character \"" + this.character.Name + "\" was loaded from Slot " + slotNumber.ToString()); this.RefreshUI(); }
// Use this for initialization void Start() { Debug.Assert(string.IsNullOrEmpty(this.xpProgressorName) == false, "Please provide an proper XpProgressor in the Inspector"); this.xpProgressor = RpgDataRegistry.Instance.SearchXpProgressor(this.xpProgressorName); Debug.Assert(this.xpProgressor != null, "Could not find an XpProgressor by the name " + this.xpProgressorName); this.character = new RpgCharacterData(Guid.NewGuid(), this.xpProgressor, this.startingHealthPoints, this.startingHealthPoints, RpgDataRegistry.Instance.DefaultStatPointAssignment, this.givenCharacterName); this.AddXp(this.startingXp); this.RefreshUI(); }