void RandomCharacterStars() { stars = new AllStats(); FieldInfo[] fInfos = stars.GetType().GetFields(); FieldInfo fInfo = stars.GetType().GetFields()[UnityEngine.Random.Range(0, fInfos.Length)]; fInfo.SetValue(this.stars, (int)fInfo.GetValue(this.stars) + 1); Debug.Log($"{name} {fInfo.Name}"); }
void RandomCharacterStats() { stats = new AllStats(); FieldInfo[] fInfos = stats.GetType().GetFields(); for (int i = 0; i < fInfos.Length; i++) { FieldInfo fInfo = fInfos[i]; fInfo.SetValue(this.stats, (int)fInfo.GetValue(this.stats) + 1); } for (int i = 0; i < (50 - fInfos.Length); i++) { FieldInfo fInfo = stats.GetType().GetFields()[UnityEngine.Random.Range(0, fInfos.Length)]; fInfo.SetValue(this.stats, (int)fInfo.GetValue(this.stats) + 1); } }
public Character(string name) { id = GenerateID(); this.name = name; gender = Convert.ToBoolean(UnityEngine.Random.Range(0, 2)) ? GenderType.Male : GenderType.Female; stats = new AllStats(); FieldInfo[] fInfos = stats.GetType().GetFields(); for (int i = 0; i < fInfos.Length; i++) { FieldInfo fInfo = fInfos[i]; fInfo.SetValue(this.stats, (int)fInfo.GetValue(this.stats) + 1); } for (int i = 0; i < (50 - fInfos.Length); i++) { FieldInfo fInfo = stats.GetType().GetFields()[UnityEngine.Random.Range(0, fInfos.Length)]; fInfo.SetValue(this.stats, (int)fInfo.GetValue(this.stats) + 1); } currentHitPoint = MaxHitPoint; level = 1; RandomBirthMark(ref birthMarks); equipments = new List <Equipment>(); workStatus = WorkStatus.Idle; healthStatus = HealthStatus.Healthly; spritePath = "Sprites/Character/Character" + UnityEngine.Random.Range(1, 10).ToString(); effects = new List <Resource.Effect>(); }