public virtual void Save(BinaryHelper helper) { PropertyInfo[] propInfo = GetType().GetProperties(); foreach (PropertyInfo info in propInfo) { if (info.PropertyType == typeof(string)) { helper.Write(info.GetValue(this, null) as string); } else if (info.PropertyType == typeof(int)) { helper.Write((int)info.GetValue(this, null)); } else if (info.PropertyType == typeof(float)) { helper.Write((float)info.GetValue(this, null)); } else if (info.PropertyType == typeof(bool)) { helper.Write((bool)info.GetValue(this, null)); } else if (info.PropertyType == typeof(short)) { helper.Write((short)info.GetValue(this, null)); } else if (info.PropertyType == typeof(List <int>)) { helper.Write(ConvertorTool.ListToString(info.GetValue(this, null) as List <int>)); } else if (info.PropertyType == typeof(List <float>)) { helper.Write(ConvertorTool.ListToString(info.GetValue(this, null) as List <float>)); } else if (info.PropertyType == typeof(List <string>)) { helper.Write(ConvertorTool.ListToString(info.GetValue(this, null) as List <string>)); } else { Debug.Log("不支持的类型:" + info.PropertyType.ToString() + " " + info.Name); } } }
public void Save(BinaryHelper helper) { helper.Write(ID); helper.Write(StrName); helper.Write(ModelId); helper.Write(ModelScale); helper.Write(WeaponID); helper.Write(RaceType); helper.Write(IsPush); helper.Write(AIType); helper.Write(Type); helper.Write(BossAIXmlName); helper.Write(BossAIXmlSubName); helper.Write(InterSubType); helper.Write(NpcSay); helper.Write(Level); helper.Write(HPMax); helper.Write(HPCount); helper.Write(PhyAttack); helper.Write(MagAttack); helper.Write(PhyDefend); helper.Write(MagDefend); helper.Write(HitRate); helper.Write(Avoid); helper.Write(CritRate); helper.Write(CritParam); helper.Write(Resist); helper.Write(WoundParam); helper.Write(AnitInterfereRate); helper.Write(AnitInterruptRate); helper.Write(AnitRepelRate); helper.Write(AnitLauncherRate); helper.Write(RotateSpeed); helper.Write(SwitchRotateSpeed); helper.Write(MoveSpeed); helper.Write(AnimationSpeed); helper.Write(AttackRange); helper.Write(CallNpcRange); helper.Write(AlertRange); helper.Write(CancelAlertRange); helper.Write(AlertPeriod); helper.Write(LargeRate); helper.Write(SmallRate); helper.Write(VisionRange); helper.Write(MaxChaseRange); helper.Write(RetreatDistance); helper.Write(RetreatSpeed); helper.Write(RetreatTime); helper.Write(StaminaMax); helper.Write(StaminaRestoreValue); helper.Write(StaminaRestorePeriod); helper.Write(StaminaEvent); helper.Write(StaminaSkillID); helper.Write(StaminaReset); helper.Write(ConvertorTool.ListToString(GiftBuffIDList)); helper.Write(DropID); helper.Write(ConvertorTool.ListToString(SkillList)); helper.Write(ConvertorTool.ListToString(PassiveSkillList)); helper.Write(functionNum); if (NpcFuncArgs != null) { functionNum = NpcFuncArgs.Count; } if (functionNum > 0) { foreach (NpcFuncArg val in NpcFuncArgs) { val.Save(helper); } } }