public bool Add(IDerivedValue value) { if (this.DerivedValues.ContainsKey(value.Name)) { return(false); } this.DerivedValues.Add(value.Name, value); return(true); }
protected virtual void SetUpUi() { if (this.Player is null) { return; } this.SetExperienceRemaining(); var derivedValues = this.Player.DerivedValues.Values.ToList(); var statistics = this.Player.Statistics.Values.ToList(); var skills = this.Player.Skills.Values.ToList(); var abilities = this.CurrentJob.Abilities.Where(pair => this.Player.Abilities.Contains(pair.Key) == false) .Select(pair => new Tuple <IAbility, int>(pair.Key, pair.Value)) .ToList(); bool addedChildren = false; if (this.DerivedValueList.GetChildCount() < derivedValues.Count) { for (int i = this.DerivedValueList.GetChildCount(); i < derivedValues.Count; i++) { var instance = this.ValueItemPrefab.Instance(); this.DerivedValueList.AddChild(instance); } addedChildren = true; } if (this.StatisticList.GetChildCount() < statistics.Count) { for (int i = this.StatisticList.GetChildCount(); i < statistics.Count; i++) { var instance = this.ValueItemPrefab.Instance(); this.StatisticList.AddChild(instance); } addedChildren = true; } if (this.SkillList.GetChildCount() < skills.Count) { for (int i = this.SkillList.GetChildCount(); i < skills.Count; i++) { var instance = this.ValueItemPrefab.Instance(); this.SkillList.AddChild(instance); } addedChildren = true; } if (this.AbilityList.GetChildCount() < abilities.Count) { for (int i = this.AbilityList.GetChildCount(); i < abilities.Count; i++) { var instance = this.AbilityItemPrefab.Instance() as ConstrainedManagedTextButton; instance.ElementName = "AccentBackground"; instance.RectMinSize = new Vector2(0, 24); instance.ToggleMode = true; this.AbilityList.AddChild(instance); } addedChildren = true; } for (int i = derivedValues.Count; i < this.DerivedValueList.GetChildCount(); i++) { this.DerivedValueList.GetChild <Control>(i).Visible = false; } for (int i = skills.Count; i < this.SkillList.GetChildCount(); i++) { this.SkillList.GetChild <Control>(i).Visible = false; } for (int i = statistics.Count; i < this.StatisticList.GetChildCount(); i++) { this.StatisticList.GetChild <Control>(i).Visible = false; } for (int i = abilities.Count; i < this.AbilityList.GetChildCount(); i++) { this.AbilityList.GetChild <Control>(i).Visible = false; } if (abilities.Count == 0) { if (this.AbilityList.GetChildCount() == 0) { var instance = this.AbilityItemPrefab.Instance() as ConstrainedManagedTextButton; instance.ElementName = "AccentBackground"; instance.RectMinSize = new Vector2(0, 24); this.AbilityList.AddChild(instance); } var item = this.AbilityList.GetChild(0) as ConstrainedManagedTextButton; item.Name = "No Abilities Available"; item.Text = item.Name; } for (int i = 0; i < derivedValues.Count; i++) { var child = this.DerivedValueList.GetChild(i) as IntValueItem; IDerivedValue derivedValue = derivedValues[i]; child.ValueName = derivedValue.Name; child.Value = derivedValue.Maximum; child.Minimum = derivedValue.Maximum; child.Maximum = child.Minimum + 50; child.UseRestriction = true; child.IncreaseCost = 10; child.DecreaseCost = -10; if (child.IsConnected("ValueChanged", this, nameof(this.OnDerivedValueChange))) { child.Disconnect("ValueChanged", this, nameof(this.OnDerivedValueChange)); } child.Connect("ValueChanged", this, nameof(this.OnDerivedValueChange)); } for (int i = 0; i < statistics.Count; i++) { var child = this.StatisticList.GetChild(i) as IntValueItem; IEntityStatistic statistic = statistics[i]; child.ValueName = statistic.Name; child.Value = statistic.Value; child.Minimum = statistic.Value; child.Maximum = 10; child.UseRestriction = true; child.Tooltip = new List <string>(statistic.Tooltip) { "Cost: " + child.IncreaseCost }; if (child.IsConnected("ValueChanged", this, nameof(this.OnStatisticChange))) { child.Disconnect("ValueChanged", this, nameof(this.OnStatisticChange)); } child.Connect("ValueChanged", this, nameof(this.OnStatisticChange)); } for (int i = 0; i < skills.Count; i++) { var child = this.SkillList.GetChild(i) as IntValueItem; IEntitySkill skill = skills[i]; child.ValueName = skill.Name; child.Value = skill.Value; child.Minimum = skill.Value; child.Maximum = 10; child.UseRestriction = true; child.Tooltip = new List <string>(skill.Tooltip) { "Cost: " + child.IncreaseCost }; if (child.IsConnected("ValueChanged", this, nameof(this.OnSkillChange))) { child.Disconnect("ValueChanged", this, nameof(this.OnSkillChange)); } child.Connect("ValueChanged", this, nameof(this.OnSkillChange)); } for (int i = 0; i < abilities.Count; i++) { var child = this.AbilityList.GetChild(i) as ConstrainedManagedTextButton; IAbility ability = abilities[i].Item1; child.Name = ability.Name; child.Text = ability.Name; child.IncreaseCost = abilities[i].Item2; child.DecreaseCost = -abilities[i].Item2; child.UseRestriction = true; child.Visible = true; child.Tooltip = new List <string> { ability.Description, "Cost: " + child.IncreaseCost }; if (child.IsConnected("ValuePress", this, nameof(this.OnAbilityChange))) { child.Disconnect("ValuePress", this, nameof(this.OnAbilityChange)); } child.Connect("ValuePress", this, nameof(this.OnAbilityChange)); } if (addedChildren) { this.GUIManager.SetupManagedComponents(this); } this.SetChildPoints(); this.OpenPageOne(); }
protected virtual void SetUpUi() { if (this.Player is null) { return; } var derivedValues = this.Player.DerivedValues.Values.ToList(); var statistics = this.Player.Statistics.Values.ToList(); var skills = this.Player.Skills.Values.ToList(); var abilities = this.Player.Abilities; var data = this.Player.GetData( new string[] { "gender", "biosex", "sexuality", "romance" }) .ToList(); bool addedChildren = false; if (this.DerivedValueList.GetChildCount() < derivedValues.Count) { for (int i = this.DerivedValueList.GetChildCount(); i < derivedValues.Count; i++) { var instance = this.ValueItemPrefab.Instance() as StaticValueItem; instance.TitleCase = true; this.DerivedValueList.AddChild(instance); } addedChildren = true; } if (this.StatisticList.GetChildCount() < statistics.Count) { for (int i = this.StatisticList.GetChildCount(); i < statistics.Count; i++) { var instance = this.ValueItemPrefab.Instance() as StaticValueItem; instance.TitleCase = true; this.StatisticList.AddChild(instance); } addedChildren = true; } if (this.SkillList.GetChildCount() < skills.Count) { for (int i = this.SkillList.GetChildCount(); i < skills.Count; i++) { var instance = this.ValueItemPrefab.Instance() as StaticValueItem; instance.TitleCase = true; this.SkillList.AddChild(instance); } addedChildren = true; } if (this.AbilityList.GetChildCount() < abilities.Count) { for (int i = this.AbilityList.GetChildCount(); i < abilities.Count; i++) { var instance = this.AbilityItemPrefab.Instance() as ManagedLabel; instance.ElementName = "AccentBackground"; instance.RectMinSize = new Vector2(0, 24); instance.TitleCase = true; this.AbilityList.AddChild(instance); } addedChildren = true; } if (this.MiscStatisticList.GetChildCount() < data.Count) { for (int i = this.MiscStatisticList.GetChildCount(); i < data.Count; i++) { var instance = this.AbilityItemPrefab.Instance() as ManagedLabel; instance.ElementName = "AccentBackground"; instance.RectMinSize = new Vector2(0, 24); instance.TitleCase = true; this.MiscStatisticList.AddChild(instance); } } for (int i = 0; i < derivedValues.Count; i++) { var child = this.DerivedValueList.GetChild(i) as StaticValueItem; IDerivedValue derivedValue = derivedValues[i]; child.ValueName = derivedValue.Name; child.Value = derivedValue.Value + "/" + derivedValue.Maximum; child.Tooltip = derivedValue.Tooltip; } for (int i = 0; i < statistics.Count; i++) { var child = this.StatisticList.GetChild(i) as StaticValueItem; IEntityStatistic statistic = statistics[i]; child.ValueName = statistic.Name; child.Value = statistic.Value.ToString(); child.Tooltip = statistic.Tooltip; } for (int i = 0; i < skills.Count; i++) { var child = this.SkillList.GetChild(i) as StaticValueItem; IEntitySkill skill = skills[i]; child.ValueName = skill.Name; child.Value = skill.Value.ToString(); child.Tooltip = skill.Tooltip; } for (int i = 0; i < abilities.Count; i++) { var child = this.AbilityList.GetChild(i) as ManagedLabel; IAbility ability = abilities[i]; child.Name = ability.Name; child.Text = ability.Name; child.Tooltip = new List <string> { ability.Description }; } for (int i = 0; i < data.Count; i++) { var child = this.MiscStatisticList.GetChild(i) as ManagedLabel; child.Name = data[i].Item1; child.Text = data[i].CombineToString(); } if (addedChildren) { this.GUIManager.SetupManagedComponents(this); } this.OpenPageOne(); }