Beispiel #1
0
    public void LoadItemConfig( )
    {
        CXmlContainer xml      = new CXmlContainer();
        List <string> herolist = new List <string> ();

        if (xml.LoadXML("data/item_proto", "id", herolist))
        {
            for (int i = 0; i < herolist.Count; i++)
            {
                tagItemProto item = new tagItemProto();
                item.dwTypeID     = xml.GetDword("id", herolist[i]);
                item.eType        = (EItemType)xml.GetDword("type", herolist[i]);
                item.byLevel      = xml.GetInt("level", herolist[i], 1);
                item.byQuality    = (byte)xml.GetInt("quality", herolist[i], 0);
                item.nBasePrice   = xml.GetInt("Price", herolist[i], 1);
                item.nMaxUseTimes = xml.GetInt("MaxUseTime", herolist[i], 1);
                item.nMaxLapNum   = xml.GetInt("MaxLap", herolist[i], 1);


                item.eSpecFunc     = (EItemSpecFunc)xml.GetInt("SpecFunction", herolist[i], 0);
                item.nSpecFuncVal1 = xml.GetInt("SpecValue1", herolist[i], 0);
                item.nSpecFuncVal2 = xml.GetInt("SpecValue2", herolist[i], 0);


                item.strIcon = xml.GetString("icon", herolist[i], "");
                item.strName = xml.GetString("name", herolist[i], "");
                item.strdesc = xml.GetString("desc", herolist[i], "");
                m_mapItem.Add(item.dwTypeID, item);
            }
        }
    }
Beispiel #2
0
    void ShowRewardItem(GameObject item, uint dwTypeID, int nNum)
    {
        if (ItemCreator.MIsEquipment(dwTypeID))
        {
            tagEquipProto pEquipProto = null;
            CProtoManager.inst.m_mapEquip.TryGetValue(dwTypeID, out pEquipProto);
            if (pEquipProto != null)
            {
                Transform pIcon = item.transform.Find("Icon");
                if (pIcon != null)
                {
                    UIAtlas tu = Resources.Load("GameIcon", typeof(UIAtlas)) as UIAtlas;
                    UnityEngine.GameObject ctrl = pIcon.gameObject;
                    ctrl.GetComponent <UISprite>().atlas      = tu;
                    ctrl.GetComponent <UISprite>().spriteName = pEquipProto.strIcon;
                }

                Transform pNum = item.transform.Find("num");
                if (pNum != null)
                {
                    UnityEngine.GameObject ctrl = pNum.gameObject;
                    ctrl.GetComponent <UILabel>().text = nNum.ToString();
                }
            }
        }
        else
        {
            tagItemProto pProto = null;
            CProtoManager.inst.m_mapItem.TryGetValue(dwTypeID, out pProto);
            if (pProto != null)
            {
                Transform pIcon = item.transform.Find("Icon");
                if (pIcon != null)
                {
                    UIAtlas tu = Resources.Load("GameIcon", typeof(UIAtlas)) as UIAtlas;
                    UnityEngine.GameObject ctrl = pIcon.gameObject;
                    ctrl.GetComponent <UISprite>().atlas      = tu;
                    ctrl.GetComponent <UISprite>().spriteName = pProto.strIcon;
                }

                Transform pNum = item.transform.Find("num");
                if (pNum != null)
                {
                    UnityEngine.GameObject ctrl = pNum.gameObject;
                    ctrl.GetComponent <UILabel>().text = nNum.ToString();
                }
            }
        }
    }
Beispiel #3
0
    //----------------------------------------------------------------------
    int CalSpaceUsed(uint dwTypeID, Int16 nNum)
    {
        tagItemProto pProto = null;

        if (ItemCreator.MIsEquipment(dwTypeID))
        {
            tagEquipProto pEquipProto = null;
            CProtoManager.inst.m_mapEquip.TryGetValue(dwTypeID, out pEquipProto);
            pProto = (tagItemProto)pEquipProto;
        }
        else
        {
            CProtoManager.inst.m_mapItem.TryGetValue(dwTypeID, out pProto);
        }

        if (pProto == null)
        {
            return(-1);
        }

        int nUseSpace = 0;

        if (nNum < pProto.nMaxLapNum)
        {
            nUseSpace = 1;
        }
        else
        {
            if (pProto.nMaxLapNum <= 0)
            {
                pProto.nMaxLapNum = 1;
            }
            nUseSpace = (1 == pProto.nMaxLapNum ? nNum : (nNum - 1) / pProto.nMaxLapNum);
        }

        return(nUseSpace);
    }