示例#1
0
    public void UpdateUI()
    {
        GunInfo info     = IOHelper.GetGunInfoById((int)type);
        int     level    = WeaponDB.Instance.GetWeaponLvById((int)type);
        int     tmpLevel = Mathf.Max(1, level);

        Debug.Log("tmpLevel " + tmpLevel + " (int)wt " + (int)type);
        GunUpgradeInfo upgradeInfo     = IOHelper.GetGunUpgradeInfoByIdAndLevel((int)type, tmpLevel);
        GunUpgradeInfo nextUpgradeInfo = IOHelper.GetGunUpgradeInfoByIdAndLevel((int)type, level + 1);
        GunUpgradeInfo maxInfo         = IOHelper.GetGunUpgradeInfoByIdAndLevel((int)type, info.maxlv);


        if (level < info.maxlv)
        {
            lv.SetActive(true);
            maxLv.SetActive(false);
            labelCurrentLevel.text = tmpLevel.ToString();
        }
        else
        {
            lv.SetActive(false);
            maxLv.SetActive(true);
        }
        labelCurrentAttack.text   = upgradeInfo.atk.ToString();
        labelCurrentCapacity.text = upgradeInfo.capacity.ToString();
        labelSpeed.text           = info.speed.ToString();

        progressAttack.value   = (float)upgradeInfo.atk / (float)maxInfo.atk;
        progressCapacity.value = (float)upgradeInfo.capacity / (float)maxInfo.capacity;
    }
示例#2
0
    public void OnUpgrade()
    {
        GunInfo info = IOHelper.GetGunInfoById((int)currentWeaponType);

        int level = WeaponDB.Instance.GetWeaponLvById((int)currentWeaponType);

        if (level >= info.maxlv)
        {
            return;
        }

        GunUpgradeInfo nextUpgradeInfo = IOHelper.GetGunUpgradeInfoByIdAndLevel((int)currentWeaponType, level + 1);

        if (nextUpgradeInfo.type == 1 && nextUpgradeInfo.cost <= GameData.Instance.currentGold)
        {
            SettingManager.Instance.WeaponUpgrade += 1;
            GameData.Instance.AddGold(-nextUpgradeInfo.cost);
            WeaponDB.Instance.UpdateWeapon((int)currentWeaponType, level + 1);
            SettingManager.Instance.MaxWeaponLevel = Mathf.Max(level + 1, SettingManager.Instance.MaxWeaponLevel);
            UpdateUI(currentWeaponType);
            MTAUpgradePoint();
            GameObject effect = (GameObject)Instantiate(upgradeEffectPrefab);
            effect.transform.parent        = GameObject.FindGameObjectWithTag("3DWeapon").transform;
            effect.transform.localPosition = new Vector3(0, -1.5f, 0);
            StartCoroutine(FireTrigger());
        }
        else if (nextUpgradeInfo.type == 2 && nextUpgradeInfo.cost <= GameData.Instance.currentDiamond)
        {
            SettingManager.Instance.MaxWeaponLevel = Mathf.Max(level + 1, SettingManager.Instance.MaxWeaponLevel);
            SettingManager.Instance.WeaponUpgrade += 1;
            GameData.Instance.AddDiamond(-nextUpgradeInfo.cost);
            WeaponDB.Instance.UpdateWeapon((int)currentWeaponType, level + 1);
            UpdateUI(currentWeaponType);
            MTAUpgradePoint();
            GameObject effect = (GameObject)Instantiate(upgradeEffectPrefab);
            effect.transform.parent        = GameObject.FindGameObjectWithTag("3DWeapon").transform;
            effect.transform.localPosition = new Vector3(0, -1.5f, 0);
            StartCoroutine(FireTrigger());
        }
        else
        {
            if (nextUpgradeInfo.type == 1)
            {
                NotEnoughGoldDialog.Popup();
            }
            else if (nextUpgradeInfo.type == 2)
            {
                NotEnoughDiamondDialog.Popup();
            }
            Debug.LogWarning("resource is not enough!");
        }
    }
示例#3
0
    void InitWeapons()
    {
        foreach (Weapon weapon in Weapons)
        {
            int     level    = WeaponDB.Instance.GetWeaponLvById((int)weapon.ID);
            GunInfo info     = IOHelper.GetGunInfoById((int)weapon.ID);
            int     tmpLevel = Mathf.Max(1, level);
            if (weapon.ID == WeaponType.bangqiugun)
            {
                tmpLevel = Mathf.Max(AvatarDB.Instance.GetAvatarLvById(SettingManager.Instance.CurrentAvatarId), 1);
            }
            else if (weapon.ID == WeaponType.gun_jiatelin)
            {
                tmpLevel = SettingManager.Instance.MaxAvatarLevel;
            }

            GunUpgradeInfo upgradeInfo = IOHelper.GetGunUpgradeInfoByIdAndLevel((int)weapon.ID, tmpLevel);
//			Debug.Log("weapon.ID " + (int)weapon.ID);
            weapon.range       = info.range;
            weapon.atk         = upgradeInfo.atk * (1f + transform.GetComponentInParent <HeroController>().attackAddtional);
            weapon.capacity    = weapon.currentCapacity = Mathf.FloorToInt(upgradeInfo.capacity * (1f + transform.GetComponentInParent <HeroController>().capacityUpPercent) * GameData.Instance.bulletCapacity);
            weapon.hitDistance = upgradeInfo.Probability;
        }
    }
示例#4
0
    void UpdateUI(WeaponType wt)
    {
        GunInfo info     = IOHelper.GetGunInfoById((int)wt);
        int     level    = WeaponDB.Instance.GetWeaponLvById((int)wt);
        int     tmpLevel = Mathf.Max(1, level);

        Debug.Log("tmpLevel " + tmpLevel + " (int)wt " + (int)wt);
        GunUpgradeInfo upgradeInfo     = IOHelper.GetGunUpgradeInfoByIdAndLevel((int)wt, tmpLevel);
        GunUpgradeInfo nextUpgradeInfo = IOHelper.GetGunUpgradeInfoByIdAndLevel((int)wt, tmpLevel + 1);
        GunUpgradeInfo maxInfo         = IOHelper.GetGunUpgradeInfoByIdAndLevel((int)wt, info.maxlv);

        if (level == 0 && upgradeInfo.cost != 0)
        {
            btnActive.SetActive(true);
            labelActive.text        = upgradeInfo.cost.ToString();
            spriteActive.spriteName = upgradeInfo.type == 1 ? "jinbi" : "zuanshi";
            btnUpgrade.SetActive(false);
        }
        else
        {
            btnActive.SetActive(false);
            btnUpgrade.SetActive(true);
            if (nextUpgradeInfo != null)
            {
                labelUpgrade.text = nextUpgradeInfo.cost.ToString();
            }
            else
            {
                labelUpgrade.text = "max";
            }
            if (nextUpgradeInfo != null)
            {
                spriteUpgrade.spriteName = nextUpgradeInfo.type == 1 ? "jinbi" : "zuanshi";
            }
        }

        WeaponItem[] items = moveArea.GetComponentsInChildren <WeaponItem>();
        foreach (WeaponItem item in items)
        {
            if (item.type == wt)
            {
                item.UpdateUI();
                break;
            }
        }

//		if (level < info.maxlv)
//		{
//			lv.SetActive(true);
//			maxLv.SetActive(false);
//			labelCurrentLevel.text = tmpLevel.ToString();
//		}
//		else
//		{
//			lv.SetActive(false);
//			maxLv.SetActive(true);
//		}
//		labelCurrentAttack.text = upgradeInfo.atk.ToString();
//		labelCurrentCapacity.text = upgradeInfo.capacity.ToString();
//
//		progressAttack.value = (float)upgradeInfo.atk / (float)maxInfo.atk;
//		progressCapacity.value = (float)upgradeInfo.capacity / (float)maxInfo.capacity;
    }