Beispiel #1
0
    private void InitFittingsItemInfo()
    {
        WeaponModule wmodule = ModuleManager.Instance.FindModule <WeaponModule>();

        if (wmodule == null)
        {
            return;
        }

        PlayerDataModule module = ModuleManager.Instance.FindModule <PlayerDataModule>();

        if (module == null)
        {
            return;
        }
        FittingsTableItem fres = DataManager.FittingsTable[uiparam.itemid] as FittingsTableItem;

        if (fres == null)
        {
            GameDebug.LogError("资源ID为" + uiparam.itemid + "不存在表格fittings.txt中 ");
            return;
        }
        ConfigTableItem configitem = DataManager.ConfigTable[fres.grade] as ConfigTableItem;

        if (null == configitem)
        {
            return;
        }
        mFitName.text   = "[" + configitem.value + "]" + fres.name;
        mFitType.text   = "物品类型";
        mFitUseLv.text  = fres.itemtype;
        mFitDesc.text   = fres.itemdesc;
        mFitAbtain.text = fres.itemabtain;

        SetIcon(mFitPic, fres.bmp);
        SetIcon(mItemPic1, null);
        mItemLb.text = "";

        FittingsData fdata = module.GetFittingsData((uint)uiparam.packpos);

        if (fdata == null)
        {
            for (int i = 0; i < (int)FittingsType.MAX_PROPERTY; ++i)
            {
                mFitProNameList[i].text  = "";
                mFitproValueList[i].text = "";
            }
            mFitProNameList[0].text = "配件未洗练!";
            return;
        }

        for (int i = 0; i < (int)FittingsType.MAX_PROPERTY; ++i)
        {
            int  proid  = -1;
            int  value  = -1;
            bool forbid = false;
            if (!fdata.GetProValue((uint)i, ref proid, ref value, ref forbid))
            {
                continue;
            }

            string pname = RoleProperty.GetPropertyName(proid);
            if ("error".Equals(pname))
            {
                pname = "属性名称";
            }
            mFitProNameList[i].text = pname;

            int min = 0;
            int max = 1;
            if (!wmodule.GetFittMinMax(uiparam.itemid, proid, ref min, ref max))
            {
                mFitproValueList[i].text = "该条属性尚未洗炼!";
                continue;
            }

            mFitproValueList[i].text = value.ToString();

            /*int proindex = FittingsProperty.GetResId(proid);
             * string colorss = "000000";
             * Hashtable map = DataManager.FittcolorTable;
             * foreach (FittcolorTableItem fcres in map.Values)
             * {
             *  if (fcres.qualityid == fres.grade && value > System.Convert.ToInt32(fcres["max_" + proindex]))
             *      continue;
             *
             *  colorss = fcres.color;
             *  break;
             * }*/
        }
    }
Beispiel #2
0
    public void BapFittings(uint pos, int fiId, bool[] lockIndex)
    {
        PlayerDataModule module = ModuleManager.Instance.FindModule <PlayerDataModule>();

        if (module == null)
        {
            return;
        }

        FittingsData fdata = module.GetFittingsData(pos);

        if (fdata == null)
        {
            return;
        }

        int id = fdata.GetId();

        FittingsTableItem fres = DataManager.FittingsTable[id] as FittingsTableItem;

        if (fres == null)
        {
            return;
        }

        uint chance = module.GetFittChance();

        BapFittingsActionParam param = new BapFittingsActionParam();

        param.pos    = pos;
        param.itemId = (uint)fres.costid;

        if (chance <= 0)
        {
            int lnum = 0;
            for (int i = 0; i < (int)FittingsType.MAX_PROPERTY; ++i)
            {
                if (lockIndex[i])
                {
                    lnum++;
                }
            }
            uint cnum = 0;
            if (lnum == 0)
            {
                cnum = fres.num_0;
            }
            else if (lnum == 1)
            {
                cnum = fres.num_1;
            }
            else if (lnum == 2)
            {
                cnum = fres.num_2;
            }

            uint count = PlayerDataPool.Instance.MainData.mPack.GetNumByID(fres.costid);
            if (count < cnum)
            {
                string ons = ItemManager.Instance.getItemName(fres.costid);
                PopTipManager.Instance.AddNewTip(StringHelper.GetString("item_need").Replace("?", ons));
                return;
            }

            param.price = cnum;
        }
        else
        {
            param.price = 0;
        }

        int mCount = 0;

        for (int i = 0; i < (int)FittingsType.MAX_PROPERTY; ++i)
        {
            int proid = -1;
            if (lockIndex[mCount])
            {
                int  value  = -1;
                bool forbid = false;
                if (!fdata.GetProValue((uint)mCount, ref proid, ref value, ref forbid))
                {
                    continue;
                }
                param.set_mproperty(mCount, proid);
                param.set_mvalue(mCount, value);
                param.set_mlock(mCount, lockIndex[mCount]);
                param.set_start(mCount, (uint)0);
                param.set_end(mCount, (uint)1);
                mCount++;
                continue;
            }


            proid = fres.GetProId();
            if (proid == -1)
            {
                continue;
            }

            int ind   = FittingsProperty.GetResId(proid);
            int minid = 0;
            int maxid = 0;
            if (!fres.GetIntervalByID(ind, ref minid, ref maxid))
            {
                continue;
            }

            FittoddsTableItem odres = DataManager.FittoddsTable[maxid] as FittoddsTableItem;
            if (odres == null)
            {
                GameDebug.LogError("fittodds.txt填写错误 id = " + maxid);
                return;
            }

            uint roodds = (uint)UnityEngine.Random.Range(0, (int)odres.odds);

            for (int j = minid; j <= maxid; ++j)
            {
                FittoddsTableItem rares = DataManager.FittoddsTable[j] as FittoddsTableItem;
                if (rares == null)
                {
                    GameDebug.LogError("fittodds.txt填写错误 id = " + j);
                    return;
                }

                if (rares.odds > roodds)
                {
                    param.set_mproperty(mCount, proid);
                    param.set_mvalue(mCount, 1);
                    param.set_mlock(mCount, lockIndex[mCount]);
                    param.set_start(mCount, rares.start);
                    param.set_end(mCount, rares.end - rares.start == 0 ? 1 : rares.end - rares.start);
                    mCount++;
                    break;
                }
            }
        }
        Net.Instance.DoAction((int)Message.MESSAGE_ID.ID_MSG_WD_BAP_FITTINGS, param);
    }