void PropertyEventHandler(NFGUID self, string strProperty, NFDataList.TData oldVar, NFDataList.TData newVar) { NFIProperty xProperty = mkernelModule.FindProperty(self, propertyName); NFDataList.TData data = xProperty.GetData(); switch (type) { case ViewType.ITEM_CNFID_ICON: { Image xImage = gameObject.GetComponent <Image> (); if (xImage != null) { string strIconName = mElementModule.QueryPropertyString(data.ToString(), NFrame.Item.Icon); string strIconFileName = mElementModule.QueryPropertyString(data.ToString(), NFrame.Item.SpriteFile); Sprite xSprite = null; //NFTexturePacker.Instance.GetSprit(strIconFileName, strIconName); if (xSprite != null) { xImage.overrideSprite = xSprite; if (xImage.sprite == null) { xImage.enabled = false; } else { xImage.enabled = true; } } } } break; case ViewType.HERO_GUID_ICON: { Image xImage = gameObject.GetComponent <Image> (); if (xImage != null) { NFIRecord xRecord = mkernelModule.FindRecord(self, NFrame.Player.PlayerHero.ThisName); int nRow = xRecord.FindObject((int)NFrame.Player.PlayerHero.GUID, data.ObjectVal()); if (nRow >= 0) { string strCnfID = xRecord.QueryString(nRow, (int)NFrame.Player.PlayerHero.ConfigID); string strIconName = mElementModule.QueryPropertyString(strCnfID, NFrame.Item.Icon); string strIconFileName = mElementModule.QueryPropertyString(strCnfID, NFrame.Item.SpriteFile); Sprite xSprite = null; //NFTexturePacker.Instance.GetSprit (strIconFileName, strIconName); if (xSprite != null) { xImage.overrideSprite = xSprite; if (xImage.sprite == null) { xImage.enabled = false; } else { xImage.enabled = true; } } } else { xImage.enabled = false; } } } break; case ViewType.NPC_CNFID_ICON: { Image xImage = gameObject.GetComponent <Image> (); if (xImage != null) { string strCnfID = data.StringVal(); string strIconName = mElementModule.QueryPropertyString(strCnfID, NFrame.NPC.Icon); string strIconFileName = mElementModule.QueryPropertyString(strCnfID, NFrame.NPC.SpriteFile); Sprite xSprite = null; //NFTexturePacker.Instance.GetSprit (strIconFileName, strIconName); if (xSprite != null) { xImage.overrideSprite = xSprite; if (xImage.sprite == null) { xImage.enabled = false; } else { xImage.enabled = true; } } } } break; case ViewType.SKILL_CNFID_ICON: { Image xImage = gameObject.GetComponent <Image> (); if (xImage != null) { string strIconName = mElementModule.QueryPropertyString(propertyName, NFrame.Skill.Icon); string strIconFileName = mElementModule.QueryPropertyString(propertyName, NFrame.Skill.SpriteFile); Sprite xSprite = null; //NFTexturePacker.Instance.GetSprit (strIconFileName, strIconName); if (xSprite != null) { xImage.overrideSprite = xSprite; if (xImage.sprite == null) { xImage.enabled = false; } else { xImage.enabled = true; } } } } break; default: { Text xText = gameObject.GetComponent <Text> (); if (xText != null) { xText.text = data.ToString(); if (xText.text == "0" || xText.text.Length <= 0) { //xText.enabled = false; } } } break; } }
void RecordEventHandler(NFGUID self, string strRecordName, NFIRecord.ERecordOptype eType, int nRow, int nCol, NFDataList.TData oldVar, NFDataList.TData newVar) { if (ColValueCondition) { if (eType == NFIRecord.ERecordOptype.Add) { if (ColConditionNum >= 0 && ColConditionContent.Length > 0) { NFIRecord xRecord = mkernelModule.FindRecord(self, recordName); if (xRecord != null) { if (xRecord.GetCols() > ColConditionNum) { switch (xRecord.GetColType(ColConditionNum)) { case NFDataList.VARIANT_TYPE.VTYPE_INT: { long value = xRecord.QueryInt(nRow, ColConditionNum); if (value.ToString() != ColConditionContent) { //remove return; } } break; case NFDataList.VARIANT_TYPE.VTYPE_STRING: { string value = xRecord.QueryString(nRow, ColConditionNum); if (value != ColConditionContent) { //remove return; } } break; default: break; } } } } } else if (eType == NFIRecord.ERecordOptype.Update) { if (nCol == ColConditionNum) { if (ColConditionNum >= 0 && ColConditionContent.Length > 0) { NFIRecord xRecord = mkernelModule.FindRecord(self, recordName); if (xRecord != null) { if (xRecord.GetCols() > ColConditionNum) { switch (xRecord.GetColType(ColConditionNum)) { case NFDataList.VARIANT_TYPE.VTYPE_INT: { long value = newVar.IntVal(); if (value.ToString() != ColConditionContent) { //remove DestroyObject(nRow); return; } } break; case NFDataList.VARIANT_TYPE.VTYPE_STRING: { string value = newVar.StringVal(); if (value != ColConditionContent) { //remove DestroyObject(nRow); return; } } break; default: break; } } } } } } } if (ColPropertyCondition) { if (ColConditionNum >= 0 && ColConditionPropertyName.Length > 0 && ColConditionPropertyValue.Length > 0) { NFIRecord xRecord = mkernelModule.FindRecord(self, recordName); if (xRecord != null) { if (xRecord.GetCols() > ColConditionNum) { switch (xRecord.GetColType(ColConditionNum)) { case NFDataList.VARIANT_TYPE.VTYPE_INT: { long value = xRecord.QueryInt(nRow, ColConditionNum); NFIElement xElement = mElementModule.GetElement(value.ToString()); if (xElement == null) { Debug.LogError("Col:" + ColConditionNum.ToString() + " Value:" + value.ToString()); return; } NFIProperty xProperty = xElement.GetPropertyManager().GetProperty(ColConditionPropertyName); if (xProperty == null) { Debug.LogError("Col:" + ColConditionNum.ToString() + " Value:" + value.ToString() + " Property:" + ColConditionPropertyName); return; } if (xProperty.GetData() != null) { switch (xProperty.GetData().GetType()) { case NFDataList.VARIANT_TYPE.VTYPE_INT: { if (xProperty.QueryInt().ToString() != ColConditionPropertyValue) { return; } } break; case NFDataList.VARIANT_TYPE.VTYPE_STRING: { if (xProperty.QueryString() != ColConditionPropertyValue) { return; } } break; } } } break; case NFDataList.VARIANT_TYPE.VTYPE_STRING: { string value = xRecord.QueryString(nRow, ColConditionNum); NFIElement xElement = mElementModule.GetElement(value); if (xElement == null) { Debug.LogError("Col:" + ColConditionNum.ToString() + " Value:" + value); return; } NFIProperty xProperty = xElement.GetPropertyManager().GetProperty(ColConditionPropertyName); if (xProperty == null) { Debug.LogError("Col:" + ColConditionNum.ToString() + " Value:" + value + " Property:" + ColConditionPropertyName); return; } if (xProperty.GetData() != null) { switch (xProperty.GetData().GetType()) { case NFDataList.VARIANT_TYPE.VTYPE_INT: { if (xProperty.QueryInt().ToString() != ColConditionPropertyValue) { return; } } break; case NFDataList.VARIANT_TYPE.VTYPE_STRING: { if (xProperty.QueryString() != ColConditionPropertyValue) { return; } } break; } } } break; default: break; } } } } } switch (eType) { case NFIRecord.ERecordOptype.Add: { NFRecordRowData rowData = new NFRecordRowData(); rowData.row = nRow; rowData.recordName = strRecordName; rowData.id = self; _data.Add(rowData); NFRoot.Instance().StartCoroutine(CreateObject(self, rowViewItem, rowData)); } break; case NFIRecord.ERecordOptype.Del: { int nIndex = -1; for (int i = 0; i < _data.Count; ++i) { NFRecordRowData rowData = _data[i]; if (rowData.row == nRow) { nIndex = i; break; } } if (nIndex >= 0) { _data.RemoveAt(nIndex); } NFRecordRowView[] rowViews = this.GetComponentsInChildren <NFRecordRowView>(); for (int i = 0; i < rowViews.Length; ++i) { NFRecordRowData rowData = rowViews[i].GetData(); if (rowData != null && rowData.row == nRow) { GameObject.Destroy(rowViews[i].gameObject); break; } } } break; case NFIRecord.ERecordOptype.Update: { if (ColValueCondition) { if (nCol == ColConditionNum) { int nIndex = -1; for (int i = 0; i < _data.Count; ++i) { NFRecordRowData rowData = _data[i]; if (rowData.row == nRow) { nIndex = i; break; } } if (nIndex < 0) { //add a new one NFRecordRowData rowData = new NFRecordRowData(); rowData.row = nRow; rowData.recordName = strRecordName; rowData.id = self; _data.Add(rowData); NFRoot.Instance().StartCoroutine(CreateObject(self, rowViewItem, rowData)); } } } { NFRecordRowView[] rowViews = this.GetComponentsInChildren <NFRecordRowView>(); for (int i = 0; i < rowViews.Length; ++i) { NFRecordRowData rowData = rowViews[i].GetData(); if (rowData != null && rowData.row == nRow) { rowViews[i].SetData(self, recordName, this, rowData); break; } } } } break; case NFIRecord.ERecordOptype.Create: break; case NFIRecord.ERecordOptype.Cleared: _data.Clear(); break; default: break; } }