public virtual void Load(BinaryHelper helper) { PropertyInfo[] propInfo = GetType().GetProperties(); foreach (PropertyInfo info in propInfo) { if (info.PropertyType == typeof(string)) { info.SetValue(this, helper.ReadString(), null); } else if (info.PropertyType == typeof(int)) { info.SetValue(this, helper.ReadInt(), null); } else if (info.PropertyType == typeof(float)) { info.SetValue(this, helper.ReadFloat(), null); } else if (info.PropertyType == typeof(bool)) { info.SetValue(this, helper.ReadBool(), null); } else if (info.PropertyType == typeof(short)) { info.SetValue(this, (short)helper.ReadInt(), null); } else if (info.PropertyType == typeof(List <int>)) { info.SetValue(this, ConvertorTool.StringToList_Int(helper.ReadString()), null); } else if (info.PropertyType == typeof(List <float>)) { info.SetValue(this, ConvertorTool.StringToList_Float(helper.ReadString()), null); } else if (info.PropertyType == typeof(List <string>)) { info.SetValue(this, ConvertorTool.StringToList_String(helper.ReadString()), null); } else { Debug.Log("不支持的类型:" + info.PropertyType.ToString() + " " + info.Name); } } }
public void Load(BinaryHelper helper) { ID = helper.ReadInt(); StrName = helper.ReadString(); ModelId = helper.ReadInt(); ModelScale = helper.ReadFloat(); WeaponID = helper.ReadInt(); RaceType = helper.ReadInt(); IsPush = helper.ReadBool(); AIType = helper.ReadInt(); Type = helper.ReadInt(); BossAIXmlName = helper.ReadString(); BossAIXmlSubName = helper.ReadString(); InterSubType = helper.ReadInt(); NpcSay = helper.ReadInt(); Level = helper.ReadInt(); HPMax = helper.ReadFloat(); HPCount = helper.ReadInt(); PhyAttack = helper.ReadFloat(); MagAttack = helper.ReadFloat(); PhyDefend = helper.ReadFloat(); MagDefend = helper.ReadFloat(); HitRate = helper.ReadFloat(); Avoid = helper.ReadFloat(); CritRate = helper.ReadFloat(); CritParam = helper.ReadFloat(); Resist = helper.ReadFloat(); WoundParam = helper.ReadFloat(); AnitInterfereRate = helper.ReadFloat(); AnitInterruptRate = helper.ReadFloat(); AnitRepelRate = helper.ReadFloat(); AnitLauncherRate = helper.ReadFloat(); RotateSpeed = helper.ReadFloat(); SwitchRotateSpeed = helper.ReadFloat(); MoveSpeed = helper.ReadFloat(); AnimationSpeed = helper.ReadFloat(); AttackRange = helper.ReadFloat(); CallNpcRange = helper.ReadFloat(); AlertRange = helper.ReadFloat(); CancelAlertRange = helper.ReadFloat(); AlertPeriod = helper.ReadFloat(); LargeRate = helper.ReadFloat(); SmallRate = helper.ReadFloat(); VisionRange = helper.ReadFloat(); MaxChaseRange = helper.ReadFloat(); RetreatDistance = helper.ReadFloat(); RetreatSpeed = helper.ReadFloat(); RetreatTime = helper.ReadFloat(); StaminaMax = helper.ReadInt(); StaminaRestoreValue = helper.ReadFloat(); StaminaRestorePeriod = helper.ReadFloat(); StaminaEvent = helper.ReadInt(); StaminaSkillID = helper.ReadInt(); StaminaReset = helper.ReadFloat(); GiftBuffIDList = ConvertorTool.StringToList_Float(helper.ReadString()); DropID = helper.ReadInt(); SkillList = ConvertorTool.StringToList_Int(helper.ReadString()); PassiveSkillList = ConvertorTool.StringToList_Int(helper.ReadString()); functionNum = helper.ReadInt(); // NpcFuncArgs 的数量 if (functionNum > 0) { NpcFuncArgs = new List <NpcFuncArg>(); for (int i = 0; i < functionNum; ++i) { NpcFuncArg val = new NpcFuncArg(); val.Load(helper); NpcFuncArgs.Add(val); } } }
public static bool SetValue <T>(PropertyInfo info, T obj, ICell cell) { if (info.PropertyType == typeof(string)) { if ((cell != null) && (cell.CellType == CellType.STRING)) { info.SetValue(obj, cell.StringCellValue, null); } else { info.SetValue(obj, "", null); } } else if (info.PropertyType == typeof(int)) { if ((cell != null) && (cell.CellType == CellType.NUMERIC)) { info.SetValue(obj, (int)cell.NumericCellValue, null); } else { info.SetValue(obj, 0, null); } } else if (info.PropertyType == typeof(float)) { if ((cell != null) && (cell.CellType == CellType.NUMERIC)) { info.SetValue(obj, (float)cell.NumericCellValue, null); } else { info.SetValue(obj, 0.0f, null); } } else if (info.PropertyType == typeof(bool)) { if ((cell != null) && (cell.CellType == CellType.NUMERIC)) { info.SetValue(obj, cell.NumericCellValue != 0, null); } else { info.SetValue(obj, false, null); } } else if (info.PropertyType == typeof(short)) { if ((cell != null) && (cell.CellType == CellType.NUMERIC)) { info.SetValue(obj, (short)cell.NumericCellValue, null); } else { info.SetValue(obj, 0, null); } } else if (info.PropertyType == typeof(List <int>)) { string s = ""; if (cell != null && cell.CellType == CellType.STRING) { s = cell.StringCellValue; } info.SetValue(obj, ConvertorTool.StringToList_Int(s), null); } else if (info.PropertyType == typeof(List <float>)) { string s = ""; if (cell != null && cell.CellType == CellType.STRING) { s = cell.StringCellValue; } info.SetValue(obj, ConvertorTool.StringToList_Float(s), null); } else if (info.PropertyType == typeof(List <string>)) { string s = ""; if (cell != null && cell.CellType == CellType.STRING) { s = cell.StringCellValue; } info.SetValue(obj, ConvertorTool.StringToList_String(s), null); } else { Debug.LogError("不支持的类型:" + info.PropertyType.ToString() + " " + info.Name); return(false); } return(true); }
public static T GenericObj <T>(IRow row) where T : new() { int index = 0; T obj = new T(); PropertyInfo[] propInfo = typeof(T).GetProperties(); foreach (PropertyInfo info in propInfo) { ICell cell = row.GetCell(index++); if (info.PropertyType == typeof(string)) { if (cell != null && cell.CellType == CellType.STRING) { info.SetValue(obj, cell.StringCellValue, null); } } else if (info.PropertyType == typeof(int)) { if (cell != null && cell.CellType == CellType.NUMERIC) { info.SetValue(obj, (int)cell.NumericCellValue, null); } } else if (info.PropertyType == typeof(float)) { if (cell != null && cell.CellType == CellType.NUMERIC) { info.SetValue(obj, (float)cell.NumericCellValue, null); } } else if (info.PropertyType == typeof(bool)) { if (cell != null && cell.CellType == CellType.NUMERIC) { info.SetValue(obj, cell.NumericCellValue != 0, null); } } else if (info.PropertyType == typeof(short)) { if (cell != null && cell.CellType == CellType.NUMERIC) { info.SetValue(obj, (short)cell.NumericCellValue, null); } } else if (info.PropertyType == typeof(List <int>)) { string s = ""; if (cell != null && cell.CellType == CellType.STRING) { s = cell.StringCellValue; } info.SetValue(obj, ConvertorTool.StringToList_Int(s), null); } else if (info.PropertyType == typeof(List <float>)) { string s = ""; if (cell != null && cell.CellType == CellType.STRING) { s = cell.StringCellValue; } info.SetValue(obj, ConvertorTool.StringToList_Float(s), null); } else if (info.PropertyType == typeof(List <string>)) { string s = ""; if (cell != null && cell.CellType == CellType.STRING) { s = cell.StringCellValue; } info.SetValue(obj, ConvertorTool.StringToList_String(s), null); } else { Debug.LogError("不支持的类型:" + info.PropertyType.ToString() + " " + info.Name); } } return(obj); }
public IEnumerator LoadDropItem(DropItemPerformanceType item) { yield return(new WaitForSeconds(0.2f)); GameResPackage.AsyncLoadPackageData loadData = new GameResPackage.AsyncLoadPackageData(); IEnumerator e = null; EventItemInfo eventInfo = GameTable.eventItemAsset.LookUp(item.m_intParam); DropItemPerformanceType.Type type = item.m_type; if (eventInfo != null) { type = (DropItemPerformanceType.Type)eventInfo.dropType; } switch (type) { // 卡牌 case DropItemPerformanceType.Type.enCard: { DropItemPerformanceCard cardItem = (DropItemPerformanceCard)item; foreach (int cardId in cardItem.m_cardList) { e = NewDropItem(loadData, item, cardId); while (true) { e.MoveNext(); if (loadData.m_isFinish) { break; } yield return(e.Current); } Debug.Log("....cardId:" + cardId); yield return(new WaitForSeconds(0.1f)); } // 卡牌的增长数目 Reward.Singleton.m_cardDesNum = Reward.Singleton.m_cardNum + cardItem.m_cardList.Count; break; } // 金钱 case DropItemPerformanceType.Type.enGold: { // 如果有钱则掉落金币 效果 if (item.m_intParam > 0) { int min = 15; int max = 30; WorldParamInfo worldInfo = GameTable.WorldParamTableAsset.Lookup((int)ENWorldParamIndex.enDropGoldMinMax); if (null != worldInfo) { List <int> cardList = ConvertorTool.StringToList_Int(worldInfo.StringTypeValue); if (null != cardList && cardList.Count >= 2) { min = cardList[0]; max = cardList[1]; } } // 金币增长的数目 int randomGold = UnityEngine.Random.Range(100, 1000); Reward.Singleton.m_goldDesNum = Reward.Singleton.m_goldNum + randomGold; int dropNum = UnityEngine.Random.Range(min, max); for (int i = 0; i < dropNum; i++) { e = NewDropItem(loadData, item); while (true) { e.MoveNext(); if (loadData.m_isFinish) { break; } yield return(e.Current); } yield return(new WaitForSeconds(0.01f)); } } break; } // 钥匙 case DropItemPerformanceType.Type.enKey: { e = NewDropItem(loadData, item, item.m_intParam); while (true) { e.MoveNext(); if (loadData.m_isFinish) { break; } yield return(e.Current); } break; } } }