/// <summary> /// Constructor requires an XpProgressor, starting HP, maximum HP, and optionally, a name /// </summary> public RpgCharacterData(Guid newId, XpProgressor newXpProgressor, int newHP, int newMaxHp, GlobalSpAssignmentType typeOfSpAssignment, string newName = RpgCharacterData.DefaultName) { Debug.Assert(newXpProgressor != null, "RpgCharacterData consturctor is being given a null XpProgressor!"); if (string.IsNullOrEmpty(newName)) { Debug.LogWarning("RpgCharacterData constructor was given a null or empty new name string"); newName = RpgCharacterData.DefaultName; } if (newMaxHp <= 0) { if (newMaxHp != 0) { newMaxHp = -newMaxHp; Debug.LogWarning("A new RPG Character " + newName + " was given negative Max HP. Negating to positive."); } else { newMaxHp = RpgCharacterData.DefaultHealthPoints; Debug.LogWarning("A new RPG Character " + newName + " was given 0 Max HP. As this is not allowed, the new HP will be " + RpgCharacterData.DefaultHealthPoints.ToString()); } } if (newHP <= 0) { if (newHP != 0) { newHP = -newHP; Debug.LogWarning("A new RPG Character " + newName + " was given negative HP. Negating to positive."); } else { newHP = newMaxHp; Debug.LogWarning("A new RPG Character " + newName + " was given 0 HP. As this is not allowed at start, the new HP will be the same as the given Max HP"); } } this.id = new SaveableGuid(newId); this.name = newName; this.hp = newHP; this.maxHp = newMaxHp; this.additionalMaxHp = 0; this.unallocatedSpPool = 0; this.assignmentType = typeOfSpAssignment; this.xpData = new XpData(newXpProgressor); this.appliedAbilities = new List <AbilityData>(); this.appliedStats = new List <StatData>(); this.numOfStats = 0; this.numOfAbilities = 0; this.UpdateReadOnlyStatsList(); this.UpdateReadOnlyAbilitiesList(); }
private static void CreateXpProgressorAsset() { XpProgressor newData = CustomDataAssetUtility.CreateAndReturnDataAsset <XpProgressor>(); newData.Init(); RpgDataRegistry registry = RpgDataAssetUtility.FindRpgDataRegistry(); RpgRegistryUtility.AdderOfXpProgressor newAdder; newAdder.xpProgressor = newData; registry.AddRpgDataObject(newAdder); }
/// <summary> /// Constructor needs an XpProgressor /// </summary> public XpData(XpProgressor newXpProgressor) { Debug.Assert(newXpProgressor != null, "XpData's constructor is being given a null XpProgressor!"); this.xpProgressor = newXpProgressor; this.xpProgressorId = new SaveableGuid(newXpProgressor.Id); this.level = 1; this.xp = 0; this.xpToNextLevel = newXpProgressor.InitialOldXtnl; this.currentLevelMultiplier = newXpProgressor.LevelMultiplier; this.currentOldValueMultiplier = newXpProgressor.OldXtnlMultiplier; this.xpToNextLevel = this.CalculateXpProgression(this.level, this.xpToNextLevel); }
/// <summary> /// Deserialization constructor /// </summary> public XpData(XpPacket xpDataPacket) { Debug.Assert(xpDataPacket != null, "XpData's constructor is being given a null XpPacket!"); this.xpProgressorId = new SaveableGuid(xpDataPacket.xpProgessorId); this.xpProgressor = RpgDataRegistry.Instance.SearchXpProgressor(this.xpProgressorId.GuidData); Debug.Assert(this.xpProgressor != null, "Deserializaing XpData failed because the XpProgressor was not found! ID: " + xpDataPacket.xpProgessorId); this.level = xpDataPacket.level; this.xp = xpDataPacket.xp; this.xpToNextLevel = xpDataPacket.xpToNextLevel; this.currentLevelMultiplier = xpDataPacket.currentLevelMultiplier; this.currentOldValueMultiplier = xpDataPacket.currentOldValueMultiplier; }
/// <summary> /// Search for an XpProgressor by name (not filename). Will return null if not found /// </summary> public XpProgressor SearchXpProgressor(string byName) { XpProgressor foundObject = null; foreach (XpProgressor entry in this.xpProgressors) { if (entry.Name.Equals(byName)) { foundObject = entry; break; } } return(foundObject); }
/// <summary> /// Search for an XpProgressor by ID. Will return null if not found /// </summary> public XpProgressor SearchXpProgressor(Guid byId) { XpProgressor foundObject = null; foreach (XpProgressor entry in this.xpProgressors) { if (entry.Id.Equals(byId)) { foundObject = entry; break; } } return(foundObject); }
void OnEnable() { this.dataObject = target as XpProgressor; }