示例#1
0
    public void LvUpWeapon(WeaponDataItem weaponItem)
    {
        if (weaponItem.IsWeaponMaxLevel())
        {
            return;
        }

        if (weaponItem.Level == 0)
        {
            return;
        }

        if (PlayerDataPack.Instance.DecMoney(PlayerDataPack.MoneyGold, weaponItem.GetLvUPCost()))
        {
            ++weaponItem.Level;
            SaveClass(true);
        }

        Hashtable hash = new Hashtable();

        hash.Add("WeaponItem", weaponItem);
        GameCore.Instance.EventController.PushEvent(EVENT_TYPE.EVENT_LOGIC_UPGRADE_WEAPON, this, hash);
    }
示例#2
0
    public void RefreshWeaponItem(WeaponDataItem weaponItem)
    {
        //_Name.text = StrDictionary.GetFormatStr(weaponItem.WeaponRecord.NameDict);
        ResourceManager.Instance.SetImage(_Icon, weaponItem.WeaponRecord.Icon);
        _SkillName.text = StrDictionary.GetFormatStr(weaponItem.WeaponRecord.SkillName);
        var curAttr = weaponItem.GetCurLevelAttrs();

        _Atk.text = ((int)curAttr.x).ToString();
        _HP.text  = ((int)curAttr.y).ToString();
        _NextAttrs.SetActive(false);

        if (UIChangeWeapon.GetShowTag() == 0)
        {
            _BtnLvUp.gameObject.SetActive(false);
            _MaxLevelTip.SetActive(false);

            if (weaponItem.Level > 0)
            {
                _BtnBuy.gameObject.SetActive(false);

                if (weaponItem.ItemDataID == WeaponDataPack.Instance._SelectedWeapon)
                {
                    _BtnEquip.gameObject.SetActive(false);
                    _BtnEquiped.gameObject.SetActive(true);
                }
                else
                {
                    _BtnEquip.gameObject.SetActive(true);
                    _BtnEquiped.gameObject.SetActive(false);
                }

                _Level.text = "Lv." + (weaponItem.Level - 1).ToString();
            }
            else
            {
                _BtnEquip.gameObject.SetActive(false);
                _BtnBuy.gameObject.SetActive(true);
                _BuyPrice.ShowCurrency(PlayerDataPack.MoneyGold, weaponItem.WeaponRecord.Price);

                _Level.text = "";
            }
        }
        else
        {
            _BtnEquip.gameObject.SetActive(false);
            _BtnBuy.gameObject.SetActive(false);
            _BtnEquiped.gameObject.SetActive(false);

            _Level.text = "Lv." + (weaponItem.Level - 1) + "/" + weaponItem.WeaponRecord.MaxLevel;

            if (weaponItem.Level == 0)
            {
                _BtnEquip.gameObject.SetActive(false);
                _BtnBuy.gameObject.SetActive(true);
                _Level.text = "Lv.0";
                _BuyPrice.ShowCurrency(PlayerDataPack.MoneyGold, weaponItem.WeaponRecord.Price);
            }
            else if (!weaponItem.IsWeaponMaxLevel())
            {
                _BtnLvUp.gameObject.SetActive(true);
                _MaxLevelTip.SetActive(false);

                _NextAttrs.SetActive(true);
                var nextAttr = weaponItem.GetNextLevelAttrs();
                _NextLvAtk.text = "+" + ((int)nextAttr.x - curAttr.x).ToString();
                _NextLvHP.text  = "+" + ((int)nextAttr.y - curAttr.y).ToString();

                if (weaponItem.IsGetWeapon())
                {
                    _LvUpPrice.gameObject.SetActive(true);
                    _LvUpPrice.ShowCurrency(PlayerDataPack.MoneyGold, weaponItem.GetLvUPCost());
                }
                else
                {
                    _LvUpPrice.gameObject.SetActive(false);
                }
            }
            else
            {
                _BtnLvUp.gameObject.SetActive(false);
                _MaxLevelTip.SetActive(true);
            }
        }
    }