void CheckType(eStatType type) { if (TypeInfo == null || TypeInfo.HashCode != GetType().GetHashCode()) { TypeInfo = new StatTypeInfo(); } TypeInfo.CheckType(type); }
public void SetValue(StatInfo info, eStatType type, int value) { PropertyInfo field; if (Fields.TryGetValue(type, out field)) { field.SetValue(info, value, null); } }
public void CheckType(eStatType type) { PropertyInfo field; if (Fields.TryGetValue(type, out field) == false) { UnityEngine.Debug.LogErrorFormat("Invalid Stat Type : {0}", type); } }
public int GetValue(StatInfo info, eStatType type) { PropertyInfo field; if (Fields.TryGetValue(type, out field)) { return((int)field.GetValue(info, null)); } return(0); }
public void AddValue(StatInfo info, eStatType type, int add_value) { PropertyInfo field; if (Fields.TryGetValue(type, out field)) { int value = (int)field.GetValue(info, null); field.SetValue(info, Math.Max(0, value + add_value), null); } }
public StatInfo(XmlNode node) { CheckTypeInfo(); foreach (XmlAttribute attr in node.Attributes) { eStatType stat_type = GetStatType(attr.Name); CheckType(stat_type); TypeInfo.SetValue(this, stat_type, int.Parse(attr.Value)); } }
StatInfo LoadStatPresetInfo(XmlNode node) { StatInfo info = new StatInfo(); foreach (XmlAttribute attr in node.Attributes) { eStatType stat_type = StatInfo.GetStatType(attr.Name); int value = int.Parse(attr.Value); info.SetValue(stat_type, value); } return(info); }
public StatTypeInfo() { Type type = typeof(StatInfo); HashCode = type.GetHashCode(); PropertyInfo[] fields = type.GetProperties(BindingFlags.Public | BindingFlags.Instance); Fields = new Dictionary <eStatType, PropertyInfo>(); foreach (PropertyInfo info in fields) { eStatType stat_type = (eStatType)Enum.Parse(typeof(eStatType), info.Name); Fields.Add(stat_type, info); } }
static public bool IsPercentValue(eStatType stat_type) { switch (stat_type) { case eStatType.CriticalChance: case eStatType.CriticalPower: case eStatType.AttackSpeed: case eStatType.DecreaseDamagePercent: case eStatType.IncreaseDamagePercent: case eStatType.HitRate: case eStatType.EvadeRate: case eStatType.ManaInit: return(true); } return(false); }
static public StatInfo GetStatInfo(XmlNode stat_node, eAttackType AttackType) { StatInfo info = new StatInfo(); foreach (XmlAttribute attr in stat_node.Attributes) { eStatType stat_type = StatInfo.GetStatType(attr.Name); int value = int.Parse(attr.Value); switch (stat_type) { case eStatType.Attack: info.SetValue(eStatType.PhysicAttack, value); info.SetValue(eStatType.MagicAttack, value); info.SetValue(eStatType.Heal, value); break; case eStatType.Defense: switch (AttackType) { case eAttackType.physic: info.SetValue(eStatType.PhysicDefense, value); info.SetValue(eStatType.MagicDefense, (int)(value * StatInfo.DefenseTypeRatio)); break; case eAttackType.magic: info.SetValue(eStatType.PhysicDefense, (int)(value * StatInfo.DefenseTypeRatio)); info.SetValue(eStatType.MagicDefense, value); break; case eAttackType.heal: info.SetValue(eStatType.PhysicDefense, (int)(value * StatInfo.DefenseTypeRatio)); info.SetValue(eStatType.MagicDefense, (int)(value * StatInfo.DefenseTypeRatio)); break; } break; default: info.SetValue(stat_type, value); break; } } return(info); }
static public bool IsDefaultValue(SharedData.eAttackType attack_type, eStatType stat_type) { switch (stat_type) { case eStatType.PhysicAttack: return(attack_type == SharedData.eAttackType.physic); case eStatType.MagicAttack: return(attack_type == SharedData.eAttackType.magic); case eStatType.Heal: return(attack_type == SharedData.eAttackType.heal); case eStatType.MaxHP: case eStatType.PhysicDefense: case eStatType.MagicDefense: case eStatType.CriticalPower: return(true); } return(false); }
public void Init() { m_LabelEquipName.text = m_Equip.GetName(); m_SpriteEquipIcon.spriteName = m_Equip.Info.IconID; m_LabelEquipEnchant.text = string.Format("+{0}", m_Equip.EnchantLevel); m_LabelEquipEnchantChanged.text = string.Format("+{0}", m_Equip.EnchantLevel + 1); StatInfo stat_info = new StatInfo(); StatInfo stat_info2 = new StatInfo(); EquipInfoManager.Instance.AddStats(m_Equip.Info, m_Equip.EnchantLevel, stat_info); EquipInfoManager.Instance.AddStats(m_Equip.Info, m_Equip.EnchantLevel + 1, stat_info2); eStatType stat_type = stat_info.GetStatType(0, m_Equip.Info.CategoryInfo.AttackType); if ((int)stat_type < 100) { m_LabelEquipValue1.text = Localization.Get(string.Format("StatType_{0}", stat_type)); m_LabelEquipValue1Current.text = string.Format("+{0}", stat_info.GetValue(stat_type)); m_LabelEquipValue1Changed.text = string.Format("+{0}", stat_info2.GetValue(stat_type)); } stat_type = stat_info.GetStatType(1, m_Equip.Info.CategoryInfo.AttackType); if ((int)stat_type < 100) { m_LabelEquipValue2.text = Localization.Get(string.Format("StatType_{0}", stat_type)); m_LabelEquipValue2Current.text = string.Format("+{0}", stat_info.GetValue(stat_type)); m_LabelEquipValue2Changed.text = string.Format("+{0}", stat_info2.GetValue(stat_type)); m_Texts[2].SetActive(true); } else { m_Texts[2].SetActive(false); } m_LabelEquipEnchantPrice.text = Localization.Format("GoodsFormat", m_Equip.EnchantCost); }
public StatValue(eStatType type, int value) { this.Type = type; this.Value = value; }
public void AddValue(eStatType type, int add_value) { CheckType(type); TypeInfo.AddValue(this, type, add_value); }
public int GetValue(eStatType type) { CheckType(type); return(TypeInfo.GetValue(this, type)); }
public void SetValue(eStatType type, int value) { CheckType(type); TypeInfo.SetValue(this, type, value); }
public int GetValue(eStatType type) { return(Stat.GetValue(type)); }
public Action(XmlNode node, SkillInfo info, Action parent) { this.SkillInfo = info; //load attribute actionType = (eActionType)Enum.Parse(typeof(eActionType), node.Attributes["type"].Value); //Debug.LogFormat("{0}", node.Attributes["value"].Value); value = int.Parse(node.Attributes["value"].Value); XmlAttribute piercingAttr = node.Attributes["piercing"]; if (piercingAttr != null) { piercing = float.Parse(piercingAttr.Value); } if (parent != null) { switch (actionType) { case eActionType.shield: throw new System.Exception(string.Format("[{0}] shield action should not be subaction", info.ID)); } IsSubAction = true; duration = parent.duration; check_distance = parent.check_distance; skip_dead = parent.skip_dead; loop_target = parent.loop_target; action_value = parent.action_value; } else { if (IsPassive == false) { if (IsDirect == false) { duration = float.Parse(node.Attributes["duration"].Value); } XmlAttribute checkDistanceAttr = node.Attributes["check_distance"]; if (checkDistanceAttr != null) { check_distance = bool.Parse(checkDistanceAttr.Value); } XmlAttribute skipDeadAttr = node.Attributes["skip_dead"]; if (skipDeadAttr != null) { skip_dead = bool.Parse(skipDeadAttr.Value); } XmlAttribute loopTargetAttr = node.Attributes["loop_target"]; if (loopTargetAttr != null) { loop_target = bool.Parse(loopTargetAttr.Value); } } action_value = new ActionValue(node); } switch (actionType) { case eActionType.shield: { attack_types = new List <eAttackType>(); foreach (var attack_type in node.Attributes["attack_type"].Value.Split(',')) { if (string.IsNullOrEmpty(attack_type) == false) { attack_types.Add((eAttackType)Enum.Parse(typeof(eAttackType), attack_type)); } } } break; case eActionType.immune: { immune_types = new List <eImmuneType>(); foreach (var immune_type in node.Attributes["immune_type"].Value.Split(',')) { if (string.IsNullOrEmpty(immune_type) == false) { immune_types.Add((eImmuneType)Enum.Parse(typeof(eImmuneType), immune_type)); } } attack_types = new List <eAttackType>(); foreach (var attack_type in node.Attributes["attack_type"].Value.Split(',')) { if (string.IsNullOrEmpty(attack_type) == false) { attack_types.Add((eAttackType)Enum.Parse(typeof(eAttackType), attack_type)); } } } break; } if (IsBuff == true || IsPassive) { statType = (eStatType)Enum.Parse(typeof(eStatType), node.Attributes["stat"].Value); if (IsBuff) { XmlAttribute show_messageAttr = node.Attributes["show_message"]; if (show_messageAttr != null) { show_message = bool.Parse(show_messageAttr.Value); } } } //load child node if (IsLevelup) { XmlNode increasePerLevelNode = node.SelectSingleNode("IncreasePerLevel"); if (increasePerLevelNode != null) { increasePerLevel = int.Parse(increasePerLevelNode.Attributes["value"].Value); } } var sub_action_nodes = node.SelectNodes("SubAction"); foreach (XmlNode sub_action_node in sub_action_nodes) { SubActions.Add(new Action(sub_action_node, info, this)); } }
public void SetValue(eStatType type, int value); // RVA: 0x1239E1C Offset: 0x1239E1C
public FloatStat GetFloatStat(eStatType statType) { return(_floatStats.ContainsKey(statType) ? _floatStats[statType] : null); }
////////////////////////////////////////////////////////////////////////////////////// public void Init(Equip equip, System.Action <Equip> _OnEquipEnchantCallback, bool bPlayTween = false) { m_Equip = equip; OnEquipEnchantCallback = _OnEquipEnchantCallback; m_LabelEquipName.text = m_Equip.GetName(); if (m_Equip.Stuffs.Count > 0) { RewardItemPrefab.Clear(); m_Stuff = RewardItemPrefab.GetNewObject <RewardItem>(m_StuffIndicator.transform, Vector3.zero); m_Stuff.Init(m_Equip.Stuffs[0]); m_Stuff.OnClickItem = OnClickStuff; } StatInfo stat_info = new StatInfo(); StatInfo stat_info2 = new StatInfo(); EquipInfoManager.Instance.AddStats(m_Equip.Info, m_Equip.EnchantLevel, stat_info); EquipItemPrefab.Clear(); if (m_Equip.EnchantLevel < 5) { var item1 = EquipItemPrefab.GetNewObject <EquipItem>(m_EquipIndicator.transform, Vector3.zero); item1.Init(m_Equip); Equip equip_enchant = m_Equip.Clone(); equip_enchant.Enchant(); var item2 = EquipItemPrefab.GetNewObject <EquipItem>(m_EquipEnchantIndicator.transform, Vector3.zero); item2.Init(equip_enchant); m_LabelEquipEnchantGrade.text = Localization.Get("EquipEnchantGrade"); m_LabelEquipEnchant.text = string.Format("+{0}", m_Equip.EnchantLevel); m_LabelEquipEnchantChanged.text = string.Format("+{0}", m_Equip.EnchantLevel + 1); EquipInfoManager.Instance.AddStats(m_Equip.Info, m_Equip.EnchantLevel + 1, stat_info2); m_EquipReady.gameObject.SetActive(m_Equip.IsNotify); m_BtnEnchant.SetActive(true); m_BtnEnchant.GetComponent <BoxCollider2D>().enabled = true; m_BtnUpgrade.SetActive(false); m_MaxEnchant.SetActive(false); } else if (m_Equip.Info.Grade < 6) { var item1 = EquipItemPrefab.GetNewObject <EquipItem>(m_EquipIndicator.transform, Vector3.zero); item1.Init(m_Equip); var equip_info = EquipInfoManager.Instance.GetInfoByID(m_Equip.Info.NextEquipID); Equip equip_enchant = new Equip(equip_info); var item2 = EquipItemPrefab.GetNewObject <EquipItem>(m_EquipEnchantIndicator.transform, Vector3.zero); item2.Init(equip_enchant); m_LabelEquipEnchantGrade.text = Localization.Get("EquipGrade"); m_LabelEquipEnchant.text = string.Format("{0}", m_Equip.Info.Grade); m_LabelEquipEnchantChanged.text = string.Format("{0}", equip_info.Grade); EquipInfoManager.Instance.AddStats(equip_info, 0, stat_info2); m_EquipReady.gameObject.SetActive(m_Equip.IsNotify); m_BtnEnchant.SetActive(false); m_BtnUpgrade.SetActive(true); m_BtnUpgrade.GetComponent <BoxCollider2D>().enabled = true; m_MaxEnchant.SetActive(false); } else { var item1 = EquipItemPrefab.GetNewObject <EquipItem>(m_EquipIndicator.transform, Vector3.zero); item1.Init(m_Equip); m_LabelEquipEnchantGrade.text = Localization.Get("EquipEnchantGrade"); m_LabelEquipEnchant.text = string.Format("+{0}", m_Equip.EnchantLevel); m_LabelEquipEnchantChanged.text = ""; m_BtnEnchant.SetActive(false); m_BtnUpgrade.SetActive(false); m_MaxEnchant.SetActive(true); } eStatType stat_type = stat_info.GetStatType(0, m_Equip.Info.CategoryInfo.AttackType); if ((int)stat_type < 100) { m_LabelEquipValue1.text = Localization.Get(string.Format("StatType_{0}", stat_type)); m_LabelEquipValue1Current.text = string.Format("+{0}", stat_info.GetValue(stat_type)); if (m_MaxEnchant.activeSelf == true) { m_LabelEquipValue1Changed.text = ""; } else { m_LabelEquipValue1Changed.text = string.Format("+{0}", stat_info2.GetValue(stat_type)); } } stat_type = stat_info.GetStatType(1, m_Equip.Info.CategoryInfo.AttackType); if ((int)stat_type < 100) { m_LabelEquipValue2.text = Localization.Get(string.Format("StatType_{0}", stat_type)); m_LabelEquipValue2Current.text = string.Format("+{0}", stat_info.GetValue(stat_type)); if (m_MaxEnchant.activeSelf == true) { m_LabelEquipValue2Changed.text = ""; } else { m_LabelEquipValue2Changed.text = string.Format("+{0}", stat_info2.GetValue(stat_type)); } m_Texts[2].SetActive(true); } else { m_Texts[2].SetActive(false); } m_LabelEquipEnchantPrice.text = Localization.Format("GoodsFormat", m_Equip.EnchantCost); if (bPlayTween) { m_PlayTween.Play(true); } }