public void AddDel(AFIObject.ClassEventHandler handler) { if (!mhtHandleDelList.ContainsKey(handler)) { mhtHandleDelList.Add(handler, handler.ToString()); mHandleDel += handler; } }
public override void RegisterClassCallBack(string strClassName, AFIObject.ClassEventHandler handler) { if (mhtClassHandleDel.ContainsKey(strClassName)) { ClassHandleDel xHandleDel = (ClassHandleDel)mhtClassHandleDel[strClassName]; xHandleDel.AddDel(handler); } else { ClassHandleDel xHandleDel = new ClassHandleDel(); xHandleDel.AddDel(handler); mhtClassHandleDel[strClassName] = xHandleDel; } }
public override bool DestroyObject(AFIDENTID self) { if (mhtObject.ContainsKey(self)) { AFIObject xGameObject = (AFIObject)mhtObject[self]; string strClassName = xGameObject.ClassName(); ClassHandleDel xHandleDel = (ClassHandleDel)mhtClassHandleDel[strClassName]; if (null != xHandleDel && null != xHandleDel.GetHandler()) { AFIObject.ClassEventHandler xHandlerList = xHandleDel.GetHandler(); xHandlerList(self, xGameObject.ContainerID(), xGameObject.GroupID(), AFIObject.CLASS_EVENT_TYPE.OBJECT_DESTROY, xGameObject.ClassName(), xGameObject.ConfigIndex()); } mhtObject.Remove(self); //AFCLog.Instance.Log(AFCLog.LOG_LEVEL.DEBUG, "Destroy object: " + self.ToString() + " ClassName: " + strClassName + " SceneID: " + xGameObject.ContainerID() + " GroupID: " + xGameObject.GroupID()); return(true); } return(false); }
public abstract void RegisterClassCallBack(string strClassName, AFIObject.ClassEventHandler handler);
public override AFIObject CreateObject(AFIDENTID self, int nContainerID, int nGroupID, string strClassName, string strConfigIndex, AFIDataList arg) { if (!mhtObject.ContainsKey(self)) { AFIObject xNewObject = new AFCObject(self, nContainerID, nGroupID, strClassName, strConfigIndex); mhtObject.Add(self, xNewObject); AFCDataList varConfigID = new AFCDataList(); varConfigID.AddString(strConfigIndex); xNewObject.GetPropertyManager().AddProperty("ConfigID", varConfigID); AFCDataList varConfigClass = new AFCDataList(); varConfigClass.AddString(strClassName); xNewObject.GetPropertyManager().AddProperty("ClassName", varConfigClass); if (arg.Count() % 2 == 0) { for (int i = 0; i < arg.Count() - 1; i += 2) { string strPropertyName = arg.StringVal(i); AFIDataList.VARIANT_TYPE eType = arg.GetType(i + 1); switch (eType) { case AFIDataList.VARIANT_TYPE.VTYPE_INT: { AFIDataList xDataList = new AFCDataList(); xDataList.AddInt64(arg.Int64Val(i + 1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; case AFIDataList.VARIANT_TYPE.VTYPE_FLOAT: { AFIDataList xDataList = new AFCDataList(); xDataList.AddFloat(arg.FloatVal(i + 1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; case AFIDataList.VARIANT_TYPE.VTYPE_DOUBLE: { AFIDataList xDataList = new AFCDataList(); xDataList.AddDouble(arg.DoubleVal(i + 1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; case AFIDataList.VARIANT_TYPE.VTYPE_STRING: { AFIDataList xDataList = new AFCDataList(); xDataList.AddString(arg.StringVal(i + 1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; case AFIDataList.VARIANT_TYPE.VTYPE_OBJECT: { AFIDataList xDataList = new AFCDataList(); xDataList.AddObject(arg.ObjectVal(i + 1)); xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList); } break; default: break; } } } InitProperty(self, strClassName); InitRecord(self, strClassName); if (mhtClassHandleDel.ContainsKey(strClassName)) { ClassHandleDel xHandleDel = (ClassHandleDel)mhtClassHandleDel[strClassName]; if (null != xHandleDel && null != xHandleDel.GetHandler()) { AFIObject.ClassEventHandler xHandlerList = xHandleDel.GetHandler(); xHandlerList(self, nContainerID, nGroupID, AFIObject.CLASS_EVENT_TYPE.OBJECT_CREATE, strClassName, strConfigIndex); xHandlerList(self, nContainerID, nGroupID, AFIObject.CLASS_EVENT_TYPE.OBJECT_LOADDATA, strClassName, strConfigIndex); xHandlerList(self, nContainerID, nGroupID, AFIObject.CLASS_EVENT_TYPE.OBJECT_CREATE_FINISH, strClassName, strConfigIndex); } } //AFCLog.Instance.Log(AFCLog.LOG_LEVEL.DEBUG, "Create object: " + self.ToString() + " ClassName: " + strClassName + " SceneID: " + nContainerID + " GroupID: " + nGroupID); return(xNewObject); } return(null); }