public static int getAttack(List <PropsInfo> sort, int index) { Debug.LogError(string.Format("getAttack, Index: {0}", 1)); Props iItem = sort[index].Item; Debug.LogError(string.Format("getAttack, iItem: {0}", iItem)); int attack = 0; if (iItem.PropsEffect != null) { for (int i = 0; i < iItem.PropsEffect.Count; i++) { PropsEffect propsEffect = iItem.PropsEffect[i]; Debug.LogError(string.Format("getAttack, propsEffect: {0}", propsEffect)); if (propsEffect is PropsBattleProperty) { PropsBattleProperty propsBattleProperty = propsEffect as PropsBattleProperty; Debug.LogError(string.Format("getAttack, propsBattleProperty: {0}", propsBattleProperty)); if (propsBattleProperty.Property == CharacterProperty.Attack || propsBattleProperty.Property == CharacterProperty.Defense) { Debug.LogError(string.Format("getAttack, propsBattleProperty.Property: {0}", propsBattleProperty.Property)); attack = propsBattleProperty.Value; break; } } } } Debug.LogError(string.Format("getAttack, attack: {0}", attack)); return(attack); }
public static Props CreateUniquePropsByValue(string sourceId, int value) { Props props = Game.Data.Get <Props>(sourceId) ?? Randomizer.GetOneFromData <Props>(sourceId); if (props == null) { return(null); } Props props2 = props.Clone <Props>(); if (props2.PropsEffect == null) { props2.PropsEffect = new List <PropsEffect>(); } if (props2.BuffList == null) { props2.BuffList = new List <string>(); } if (props2.PropsEffectDescription == null) { props2.PropsEffectDescription = ""; } List <CharacterProperty> list = ((CharacterProperty[])Enum.GetValues(typeof(CharacterProperty))).ToList(); list.Remove(CharacterProperty.Affiliation); list.Remove(CharacterProperty.Contribution); list.Remove(CharacterProperty.HP); list.Remove(CharacterProperty.MP); int num = value; List <string> list2 = new List <string>(); while (num > 0 && list.Count > 0) { CharacterProperty characterProperty = list.Random(); int num2; int num3; if (characterProperty < CharacterProperty.Attack) { num2 = UnityEngine.Random.Range(0, num + value / 2); num3 = num2 * 3 / 20 * 20; num2 = num3 / 3; } else if (characterProperty < CharacterProperty.Hit) { num2 = UnityEngine.Random.Range(-value / 2, num + value); num3 = num2 / 5 * 5; num2 = num3; } else if (characterProperty < CharacterProperty.Move) { num2 = UnityEngine.Random.Range(-value / 2, num + value); num3 = num2 / 5; num2 = num3 * 5; } else { num2 = UnityEngine.Random.Range(0, num + value / 2); num3 = (num2 + 40) / 100; num2 = Math.Max(0, num3 * 100 - 40); } if (num3 != 0) { list.Remove(characterProperty); PropsBattleProperty propsBattleProperty = new PropsBattleProperty { Type = PropsEffectType.BattleProperty, Property = characterProperty, isForever = false, Value = num3 }; props2.PropsEffect.Add(propsBattleProperty); list2.Add(string.Format("{0}{1}{2}", Game.Data.Get <StringTable>("Property_" + Enum.GetName(typeof(CharacterProperty), characterProperty)).Text, (num3 > 0) ? "+" : "", num3)); num -= num2; } } Props props3 = props2; props3.PropsEffectDescription = string.Concat(new object[] { props3.PropsEffectDescription, "\n附加:", string.Join(",", list2) }); ModExtensionSaveData.AddUniqueItem(props2); return(props2); }