Ejemplo n.º 1
0
 /// <summary>
 /// 清空全部数据
 /// </summary>
 public void ClearAllData()
 {
     //金币
     SaveCoin(0);
     //武器等级
     WeaponType[] weaponTypes = WeaponInfo.GetAllWeapons();
     foreach (WeaponType weaponType in weaponTypes)
     {
         SaveWeaponLevel(weaponType, 0);
     }
     //已穿戴
     SaveEquipWeapon(null);
 }
Ejemplo n.º 2
0
    /// <summary>
    /// 刷新当前Equip信息
    /// </summary>
    private void UpdateEquipList(bool resetPos)
    {
        //获取原型并隐藏
        equipItem.gameObject.SetActive(false);
        //更新列表
        for (int i = 0; i < equipScrollP.childCount; i++)
        {
            Destroy(equipScrollP.GetChild(i).gameObject);
        }

        switch (equipUIType)
        {
        case EquipUIType.Weapon:

            WeaponType[] types = WeaponInfo.GetAllWeapons();
            int          count = types.Length;

            equipScrollP.GetComponent <RectTransform>().sizeDelta = new Vector2(0, Mathf.Max(900, 200 * count));
            if (resetPos)
            {
                equipScrollP.GetComponent <RectTransform>().anchoredPosition = Vector2.zero;
            }

            for (int i = 0; i < count; i++)
            {
                GameObject go    = Instantiate <GameObject>(equipItem.gameObject);
                Transform  trans = go.transform;
                go.SetActive(true);
                go.name = i.ToString();
                trans.SetParent(equipScrollP);
                trans.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, -200 * i);
                trans.GetComponent <RectTransform>().sizeDelta        = new Vector2(0, 200);
                trans.GetComponent <RectTransform>().localScale       = Vector3.one;

                WeaponType tempType  = types[i];
                int        tempLevel = DataManager.Instance.LoadWeaponLevel(tempType);

                BaseWeaponInfo baseWeaponInfo = WeaponInfo.Instance.LoadBaseWeaponData(tempType, tempLevel);
                bool           isMaxLevel     = tempLevel >= WeaponInfo.MAX_WEAPON_LEVEL;
                bool           isEquip        = DataManager.Instance.LoadEquipWeapon().Contains(tempType);

                trans.Find("I").GetComponent <Image>().sprite          = ResourcesLoadManager.LoadWeaponResources <GameObject>(baseWeaponInfo.weaponResName).GetComponent <SpriteRenderer>().sprite;
                trans.Find("Cost_T").GetComponent <Text>().text        = string.Format("节点消耗:{0}", baseWeaponInfo.weaponPointsCost);
                trans.Find("Attribute_0_T").GetComponent <Text>().text = string.Format("武器威力:{0}", baseWeaponInfo.shootPower + tempLevel * baseWeaponInfo.shootPowerUpPerLevel);
                trans.Find("Attribute_1_T").GetComponent <Text>().text = string.Format("武器射速:{0}", baseWeaponInfo.shootSpeed + tempLevel * baseWeaponInfo.shootSpeedUpPerLevel);

                Button upgradeB = trans.Find("Upgrade_B").GetComponent <Button>();
                Button equipB   = trans.Find("Equip_B").GetComponent <Button>();

                upgradeB.interactable = !isMaxLevel;
                upgradeB.transform.Find("Value_T").GetComponent <Text>().text = isMaxLevel ? "Max" : string.Format("升级:{0}", baseWeaponInfo.weaponUpgradeCost + tempLevel * baseWeaponInfo.weaponUpgradeCostUp);
                equipB.transform.Find("Value_T").GetComponent <Text>().text   = isEquip ? "卸载" : "装备";

                //注册按钮方法
                upgradeB.onClick.AddListener(() => { DoUpgradeModule(tempType); });
                equipB.onClick.AddListener(() => { DoEquipOrUnequipModule(tempType); });
            }

            break;


        case EquipUIType.Other:

            //TODO
            break;
        }
    }