private void BuildSkills(int nActorSkillID) { var rSymbolObjs = GPCSkillConfig.Instance.GetActorSkill(nActorSkillID); this.Skills = new List <GPCSkill>(); if (rSymbolObjs == null) { return; } for (int i = 0; i < rSymbolObjs.Count; i++) { List <GamePlayComponent> rComps = new List <GamePlayComponent>(); for (int j = 0; j < rSymbolObjs[i].Bodies.Count; j++) { var rCompType = HotfixReflectAssists.GetType("Game.Knight." + rSymbolObjs[i].Bodies[j].Identifer.Value); var rComp = HotfixReflectAssists.Construct( rCompType, this, rSymbolObjs[i].Bodies[j].ToArgs()) as GamePlayComponent; rComps.Add(rComp); } GPCSkill rGPCSkill = new GPCSkill(this, rSymbolObjs[i].Head.ToArgs(), rComps); this.Skills.Add(rGPCSkill); } for (int i = 0; i < this.Skills.Count; i++) { this.Skills[i].Initialize(); } }
public virtual void Initialize() { Type rType = this.GetType(); if (rType == null) { return; } //TODO: ........这里移植过来反射出来的Field的顺序有问题....和以前的不一样 var rBindingFlags = BindingFlags.GetField | BindingFlags.SetField | BindingFlags.Public | BindingFlags.Instance; var rFiledInfos = rType.GetFields(rBindingFlags); int i = 0; for (i = 0; i < rFiledInfos.Length - 2; i++) { var rFiledType = rFiledInfos[i + 2].FieldType; var rValue = HotfixReflectAssists.TypeConvert(rFiledType, mArgs[i]); rFiledInfos[i + 2].SetValue(this, rValue); } if (rFiledInfos.Length >= 2) { var rValue0 = HotfixReflectAssists.TypeConvert(rFiledInfos[0].FieldType, mArgs[i++]); rFiledInfos[0].SetValue(this, rValue0); var rValue1 = HotfixReflectAssists.TypeConvert(rFiledInfos[1].FieldType, mArgs[i++]); rFiledInfos[1].SetValue(this, rValue1); } this.mIsStartTriggered = false; this.mIsEndTriggered = false; }
public object DeserializeFrom(Type type, byte[] bytes) { var rObj = HotfixReflectAssists.Construct(type) as HotfixSerializerBinary; using (var ms = new MemoryStream(bytes)) { using (var br = new BinaryReader(ms)) { rObj.Deserialize(br); } } return(rObj); }
public T DeserializeFrom <T>(byte[] bytes, int index, int count) where T : HotfixSerializerBinary { var rObj = HotfixReflectAssists.Construct(typeof(T)) as T; using (var ms = new MemoryStream(bytes, index, count)) { using (var br = new BinaryReader(ms)) { rObj.Deserialize(br); } } return(rObj as T); }
/// <summary> /// 初始化View controller /// </summary> protected virtual void InitializeViewController() { this.mViewController = HotfixReflectAssists.Construct(Type.GetType(this.ViewMB.HotfixName)) as ViewController; if (this.mViewController == null) { Debug.LogErrorFormat("Create View controller <color=blue>{0}</color> failed..", this.ViewMB.HotfixName); } else { this.mViewController.SetHotfix(this.ViewMB.HotfixName, this.GUID); this.mViewController.Initialize(this.ViewMB.Objects); } }