/// <summary> /// 创建独有角色数据 /// </summary> /// <param name="characterId"></param> /// <returns></returns> private RoleData CreateUniqueRoleData(int characterId) { Character character = GetOrCreateCharacter(characterId); if (character == null) { return(null); } Class cls = GetOrCreateClass(character.Info.classId); if (cls == null) { return(null); } RoleData self = new RoleData { characterId = characterId, classId = character.Info.classId, level = Mathf.Clamp(character.Info.level, 0, SettingVars.MaxLevel), exp = 0, fightProperties = FightProperties.Clamp(character.Info.fightProperties + cls.Info.fightProperties, cls.Info.maxFightProperties) }; self.hp = self.fightProperties.hp; self.luk = Mathf.Clamp(character.Info.luk, 0, SettingVars.MaxLuk); //self.money = character.info.money; self.movePoint = cls.Info.movePoint; return(self); }
public static FightProperties Clamp(FightProperties value, FightProperties max) { FightProperties fight = new FightProperties { hp = Mathf.Clamp(value.hp, 1, SettingVars.MaxHp), str = Mathf.Clamp(value.str, 0, max.str), mag = Mathf.Clamp(value.mag, 0, max.mag), skl = Mathf.Clamp(value.skl, 0, max.skl), spd = Mathf.Clamp(value.spd, 0, max.spd), def = Mathf.Clamp(value.def, 0, max.def), mdf = Mathf.Clamp(value.mdf, 0, max.mdf) }; return(fight); }
public static FightProperties operator *(FightProperties lhs, int rhs) { FightProperties fight = new FightProperties { hp = lhs.hp * rhs, str = lhs.str * rhs, mag = lhs.mag * rhs, skl = lhs.skl * rhs, spd = lhs.spd * rhs, def = lhs.def * rhs, mdf = lhs.mdf * rhs, }; return(fight); }
public static FightProperties operator +(FightProperties lhs, int rhs) { FightProperties fight = new FightProperties { hp = lhs.hp + rhs, str = lhs.str + rhs, mag = lhs.mag + rhs, skl = lhs.skl + rhs, spd = lhs.spd + rhs, def = lhs.def + rhs, mdf = lhs.mdf + rhs, }; return(fight); }
public static FightProperties operator /(FightProperties lhs, int rhs) { if (rhs == 0) { return(lhs); } FightProperties fight = new FightProperties { hp = lhs.hp / rhs, str = lhs.str / rhs, mag = lhs.mag / rhs, skl = lhs.skl / rhs, spd = lhs.spd / rhs, def = lhs.def / rhs, mdf = lhs.mdf / rhs, }; return(fight); }