コード例 #1
0
    public void BuyWeapon(int id)
    {
        PlayerDataModule module = ModuleManager.Instance.FindModule <PlayerDataModule>();

        if (module == null)
        {
            return;
        }

        PrestigeTableItem preres = DataManager.PrestigeTable[id] as PrestigeTableItem;

        if (preres == null)
        {
            return;
        }

        uint pre = module.GetProceeds(ProceedsType.Money_Prestige);

        if (pre < preres.value)
        {
            PopTipManager.Instance.AddNewTip(StringHelper.GetString("presit_shortage"));
            return;
        }

        if (!DataManager.WeaponTable.ContainsKey(id))
        {
            GameDebug.LogError("无效的武器id:" + id.ToString());
            return;
        }

        WeaponTableItem res = DataManager.WeaponTable[id] as WeaponTableItem;

        uint gamei = module.GetProceeds(ProceedsType.Money_Game);

        if (gamei < (uint)res.gameprice)
        {
            PopTipManager.Instance.AddNewTip(StringHelper.GetString("money_game_shortage"));
            return;
        }

        //模拟服务器创建道具
        //module.CreateItemUnreal(id, PackageType.Pack_Weapon);
        BuyWeaponActionParam param = new BuyWeaponActionParam();

        param.WeaponResId = id;
        Net.Instance.DoAction((int)Message.MESSAGE_ID.ID_MSG_WD_BUY_WEAPON, param);
    }
コード例 #2
0
    //界面打开
    protected override void OnOpen(object param = null)
    {
        EventDelegate.Add(mReturnBtn.onClick, OnReturnBtnClicked);

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

        if (module.GetQualifyingBestRank() == uint.MaxValue)
        {
            mNoBestRankText.text  = StringHelper.GetString("arena_outofrank");
            mNoBestRankText.alpha = 1.0f;
            mBestRankText.alpha   = 0.0f;
        }
        else
        {
            mBestRankText.text    = (module.GetQualifyingBestRank() + 1).ToString();
            mBestRankText.alpha   = 1.0f;
            mNoBestRankText.alpha = 0.0f;
        }

        mAwardText0.text = "X0";
        mAwardText1.text = "X0";

        QualifyingAwardTableItem res = mModule.GetCurAwardRes();

        if (res != null)
        {
            MoneyItemTableItem prestige = ItemManager.GetItemRes((int)res.mAwardPrestige) as MoneyItemTableItem;
            if (prestige != null && prestige.value > 0)
            {
                mAwardText1.text = "X" + prestige.value.ToString();
            }

            MoneyItemTableItem gold = ItemManager.GetItemRes((int)res.mAwardGold) as MoneyItemTableItem;
            if (gold != null && gold.value > 0)
            {
                mAwardText0.text = "X" + gold.value.ToString();
            }
        }

        uint money_prestige           = module.GetProceeds(ProceedsType.Money_Prestige);
        PrestigeTableItem mNextWeapon = new PrestigeTableItem();

        mNextWeapon.value = uint.MaxValue;

        IDictionaryEnumerator itr = DataManager.PrestigeTable.GetEnumerator();

        while (itr.MoveNext())
        {
            PrestigeTableItem item = itr.Value as PrestigeTableItem;

            if (item.value > money_prestige && item.value <= mNextWeapon.value)
            {
                if (item.value == mNextWeapon.value && item.sortid.CompareTo(mNextWeapon.sortid) > 0)
                {
                    continue;
                }
                mNextWeapon = item;
            }
        }

        if (mNextWeapon.value == uint.MaxValue)
        {
            mReputationText.text = StringHelper.GetString("qualifying_reputation2");
            mWeaponPanel.SetActive(false);
        }
        else
        {
            mReputationText.text = string.Format(StringHelper.GetString("qualifying_reputation"), mNextWeapon.value - money_prestige);
            mWeaponPanel.SetActive(true);
        }

        if (!DataManager.WeaponTable.ContainsKey(mNextWeapon.weaponid))
        {
            return;
        }

        WeaponTableItem weapon = DataManager.WeaponTable[mNextWeapon.weaponid] as WeaponTableItem;

        if (null == weapon)
        {
            return;
        }

        mWeaponNameText.text = weapon.name;
        UIAtlasHelper.SetSpriteImage(mWeaponPic, weapon.picname);
        mScrollBar.value = 0.0f;
    }