public void useCharm() { if(attr == -1 || level == -1) { return; } string talbeString = "90" + level.ToString() + "0" + attr.ToString() + "001"; int needIdTable = int.Parse(talbeString); for( int i = 0; i < GAMEDEFINE.MAX_BAG_SIZE; i++ ) { CObject_Item objectItem = CDataPool.Instance.UserBag_GetItem(i); if( objectItem != null && ( objectItem is CObject_Item_Symbol ) )//如果是符印 { CObject_Item_Symbol charmItem = (CObject_Item_Symbol)objectItem; int idTable = charmItem.GetIdTable(); if( needIdTable == idTable ) { CGUseSymbol useSymbolMsg = new CGUseSymbol(); useSymbolMsg.BagIndex = (byte)objectItem.PosIndex; NetManager.GetNetManager().SendPacket(useSymbolMsg); //吃一个就返回 return ; } } } }
public CObject_Item NewItem(uint idTable) { CObject_Item newItem = null; if (IsWhiteEquip(idTable)) { //搜索纪录 _DBC_ITEM_EQUIP_BASE pEquip = EquipDBC.Search_Index_EQU((int)idTable); if (pEquip == null) { return(null); } newItem = new CObject_Item_Equip(CreateID()); ((CObject_Item_Equip)newItem).AsWhiteEquip(ref pEquip); //物品规则 itemRule(pEquip, newItem); } else if (IsGreenEquip(idTable)) { //搜索纪录 _DBC_ITEM_EQUIP_BASE pEquip = EquipDBC.Search_Index_EQU((int)idTable); if (pEquip == null) { return(null); } newItem = new CObject_Item_Equip(CreateID()); ((CObject_Item_Equip)newItem).AsGreenEquip(ref pEquip); //物品规则 itemRule(pEquip, newItem); } else if (IsBlueEquip(idTable)) { //搜索纪录 _DBC_ITEM_EQUIP_BASE pEquip = EquipDBC.Search_Index_EQU((int)idTable); if (pEquip == null) { return(null); } newItem = new CObject_Item_Equip(CreateID()); ((CObject_Item_Equip)newItem).AsBlueEquip(ref pEquip); //物品规则 itemRule(pEquip, newItem); } else if (IsPurpleEquip(idTable)) { //搜索纪录 _DBC_ITEM_EQUIP_BASE pEquip = EquipDBC.Search_Index_EQU((int)idTable); if (pEquip == null) { return(null); } newItem = new CObject_Item_Equip(CreateID()); ((CObject_Item_Equip)newItem).AsPurpleEquip(ref pEquip); //物品规则 itemRule(pEquip, newItem); } else if (IsMedicItem(idTable)) { COMMON_DBC <_DBC_ITEM_MEDIC> allMedic = CDataBaseSystem.Instance.GetDataBase <_DBC_ITEM_MEDIC>((int)DataBaseStruct.DBC_ITEM_MEDIC); if (allMedic != null) { _DBC_ITEM_MEDIC pMedic = allMedic.Search_Index_EQU((int)idTable); newItem = new CObject_Item_Medicine(CreateID()); ((CObject_Item_Medicine)newItem).AsMedicine(pMedic); itemRule(pMedic, newItem); } else { throw new Exception("_DBC_ITEM_MEDIC database not found"); } } else if (IsGemItem((int)idTable)) { //搜索纪录 _DBC_ITEM_GEM pGem = GemDBC.Search_Index_EQU((int)idTable); if (pGem == null) { return(null); } newItem = new CObject_Item_Gem(CreateID()); ((CObject_Item_Gem)newItem).AsGem(pGem); //物品规则 itemRule(pGem, newItem); } else if (isSymbolItem(idTable)) //是符印 { _DBC_ITEM_SYMBOL pSymbol = SymbolDBC.Search_Index_EQU((int)idTable); if (pSymbol == null) { return(null); } newItem = new CObject_Item_Symbol(CreateID()); ((CObject_Item_Symbol)newItem).AsSymbol(pSymbol); //物品规则 itemRule(pSymbol, newItem); } else if (isTalismanItem(idTable)) //是法宝 { _DBC_ITEM_TALISMAN dbItem = CDataBaseSystem.Instance.GetDataBase <_DBC_ITEM_TALISMAN>((int)DataBaseStruct.DBC_ITEM_TALISMAN).Search_Index_EQU((int)idTable); if (dbItem == null) { return(null); } newItem = new CTalisman_Item(CreateID()); CTalisman_Item curItem = newItem as CTalisman_Item; curItem.Define = dbItem; //物品规则 itemRule(dbItem, newItem); } if (newItem == null) { LogManager.LogError("物品编号填写错误!,ID:" + idTable); } else { newItem.m_idTable = (int)idTable; allItems[newItem.GetID()] = newItem; } return(newItem); }