Example #1
0
    public void Init()
    {
        m_LabelEquipName.text = m_Equip.GetName();

        m_SpriteEquipIcon.spriteName = m_Equip.Info.IconID;

        m_LabelEquipEnchant.text        = string.Format("+{0}", m_Equip.EnchantLevel);
        m_LabelEquipEnchantChanged.text = string.Format("+{0}", m_Equip.EnchantLevel + 1);

        StatInfo stat_info  = new StatInfo();
        StatInfo stat_info2 = new StatInfo();

        EquipInfoManager.Instance.AddStats(m_Equip.Info, m_Equip.EnchantLevel, stat_info);
        EquipInfoManager.Instance.AddStats(m_Equip.Info, m_Equip.EnchantLevel + 1, stat_info2);

        eStatType stat_type = stat_info.GetStatType(0, m_Equip.Info.CategoryInfo.AttackType);

        if ((int)stat_type < 100)
        {
            m_LabelEquipValue1.text        = Localization.Get(string.Format("StatType_{0}", stat_type));
            m_LabelEquipValue1Current.text = string.Format("+{0}", stat_info.GetValue(stat_type));
            m_LabelEquipValue1Changed.text = string.Format("+{0}", stat_info2.GetValue(stat_type));
        }

        stat_type = stat_info.GetStatType(1, m_Equip.Info.CategoryInfo.AttackType);
        if ((int)stat_type < 100)
        {
            m_LabelEquipValue2.text        = Localization.Get(string.Format("StatType_{0}", stat_type));
            m_LabelEquipValue2Current.text = string.Format("+{0}", stat_info.GetValue(stat_type));
            m_LabelEquipValue2Changed.text = string.Format("+{0}", stat_info2.GetValue(stat_type));
            m_Texts[2].SetActive(true);
        }
        else
        {
            m_Texts[2].SetActive(false);
        }

        m_LabelEquipEnchantPrice.text = Localization.Format("GoodsFormat", m_Equip.EnchantCost);
    }
Example #2
0
    StatInfo LoadStatPresetInfo(XmlNode node)
    {
        StatInfo info = new StatInfo();

        foreach (XmlAttribute attr in node.Attributes)
        {
            eStatType stat_type = StatInfo.GetStatType(attr.Name);
            int       value     = int.Parse(attr.Value);
            info.SetValue(stat_type, value);
        }

        return(info);
    }
Example #3
0
    static public StatInfo GetStatInfo(XmlNode stat_node, eAttackType AttackType)
    {
        StatInfo info = new StatInfo();

        foreach (XmlAttribute attr in stat_node.Attributes)
        {
            eStatType stat_type = StatInfo.GetStatType(attr.Name);
            int       value     = int.Parse(attr.Value);

            switch (stat_type)
            {
            case eStatType.Attack:
                info.SetValue(eStatType.PhysicAttack, value);
                info.SetValue(eStatType.MagicAttack, value);
                info.SetValue(eStatType.Heal, value);
                break;

            case eStatType.Defense:
                switch (AttackType)
                {
                case eAttackType.physic:
                    info.SetValue(eStatType.PhysicDefense, value);
                    info.SetValue(eStatType.MagicDefense, (int)(value * StatInfo.DefenseTypeRatio));
                    break;

                case eAttackType.magic:
                    info.SetValue(eStatType.PhysicDefense, (int)(value * StatInfo.DefenseTypeRatio));
                    info.SetValue(eStatType.MagicDefense, value);
                    break;

                case eAttackType.heal:
                    info.SetValue(eStatType.PhysicDefense, (int)(value * StatInfo.DefenseTypeRatio));
                    info.SetValue(eStatType.MagicDefense, (int)(value * StatInfo.DefenseTypeRatio));
                    break;
                }
                break;

            default:
                info.SetValue(stat_type, value);
                break;
            }
        }
        return(info);
    }
Example #4
0
    //////////////////////////////////////////////////////////////////////////////////////
    public void Init(Equip equip, System.Action <Equip> _OnEquipEnchantCallback, bool bPlayTween = false)
    {
        m_Equip = equip;
        OnEquipEnchantCallback = _OnEquipEnchantCallback;
        m_LabelEquipName.text  = m_Equip.GetName();

        if (m_Equip.Stuffs.Count > 0)
        {
            RewardItemPrefab.Clear();
            m_Stuff = RewardItemPrefab.GetNewObject <RewardItem>(m_StuffIndicator.transform, Vector3.zero);
            m_Stuff.Init(m_Equip.Stuffs[0]);
            m_Stuff.OnClickItem = OnClickStuff;
        }


        StatInfo stat_info  = new StatInfo();
        StatInfo stat_info2 = new StatInfo();

        EquipInfoManager.Instance.AddStats(m_Equip.Info, m_Equip.EnchantLevel, stat_info);

        EquipItemPrefab.Clear();
        if (m_Equip.EnchantLevel < 5)
        {
            var item1 = EquipItemPrefab.GetNewObject <EquipItem>(m_EquipIndicator.transform, Vector3.zero);
            item1.Init(m_Equip);
            Equip equip_enchant = m_Equip.Clone();
            equip_enchant.Enchant();
            var item2 = EquipItemPrefab.GetNewObject <EquipItem>(m_EquipEnchantIndicator.transform, Vector3.zero);
            item2.Init(equip_enchant);

            m_LabelEquipEnchantGrade.text   = Localization.Get("EquipEnchantGrade");
            m_LabelEquipEnchant.text        = string.Format("+{0}", m_Equip.EnchantLevel);
            m_LabelEquipEnchantChanged.text = string.Format("+{0}", m_Equip.EnchantLevel + 1);
            EquipInfoManager.Instance.AddStats(m_Equip.Info, m_Equip.EnchantLevel + 1, stat_info2);
            m_EquipReady.gameObject.SetActive(m_Equip.IsNotify);

            m_BtnEnchant.SetActive(true);
            m_BtnEnchant.GetComponent <BoxCollider2D>().enabled = true;
            m_BtnUpgrade.SetActive(false);
            m_MaxEnchant.SetActive(false);
        }
        else if (m_Equip.Info.Grade < 6)
        {
            var item1 = EquipItemPrefab.GetNewObject <EquipItem>(m_EquipIndicator.transform, Vector3.zero);
            item1.Init(m_Equip);

            var   equip_info    = EquipInfoManager.Instance.GetInfoByID(m_Equip.Info.NextEquipID);
            Equip equip_enchant = new Equip(equip_info);
            var   item2         = EquipItemPrefab.GetNewObject <EquipItem>(m_EquipEnchantIndicator.transform, Vector3.zero);
            item2.Init(equip_enchant);

            m_LabelEquipEnchantGrade.text   = Localization.Get("EquipGrade");
            m_LabelEquipEnchant.text        = string.Format("{0}", m_Equip.Info.Grade);
            m_LabelEquipEnchantChanged.text = string.Format("{0}", equip_info.Grade);
            EquipInfoManager.Instance.AddStats(equip_info, 0, stat_info2);
            m_EquipReady.gameObject.SetActive(m_Equip.IsNotify);

            m_BtnEnchant.SetActive(false);
            m_BtnUpgrade.SetActive(true);
            m_BtnUpgrade.GetComponent <BoxCollider2D>().enabled = true;
            m_MaxEnchant.SetActive(false);
        }
        else
        {
            var item1 = EquipItemPrefab.GetNewObject <EquipItem>(m_EquipIndicator.transform, Vector3.zero);
            item1.Init(m_Equip);
            m_LabelEquipEnchantGrade.text   = Localization.Get("EquipEnchantGrade");
            m_LabelEquipEnchant.text        = string.Format("+{0}", m_Equip.EnchantLevel);
            m_LabelEquipEnchantChanged.text = "";

            m_BtnEnchant.SetActive(false);
            m_BtnUpgrade.SetActive(false);
            m_MaxEnchant.SetActive(true);
        }

        eStatType stat_type = stat_info.GetStatType(0, m_Equip.Info.CategoryInfo.AttackType);

        if ((int)stat_type < 100)
        {
            m_LabelEquipValue1.text        = Localization.Get(string.Format("StatType_{0}", stat_type));
            m_LabelEquipValue1Current.text = string.Format("+{0}", stat_info.GetValue(stat_type));
            if (m_MaxEnchant.activeSelf == true)
            {
                m_LabelEquipValue1Changed.text = "";
            }
            else
            {
                m_LabelEquipValue1Changed.text = string.Format("+{0}", stat_info2.GetValue(stat_type));
            }
        }

        stat_type = stat_info.GetStatType(1, m_Equip.Info.CategoryInfo.AttackType);
        if ((int)stat_type < 100)
        {
            m_LabelEquipValue2.text        = Localization.Get(string.Format("StatType_{0}", stat_type));
            m_LabelEquipValue2Current.text = string.Format("+{0}", stat_info.GetValue(stat_type));
            if (m_MaxEnchant.activeSelf == true)
            {
                m_LabelEquipValue2Changed.text = "";
            }
            else
            {
                m_LabelEquipValue2Changed.text = string.Format("+{0}", stat_info2.GetValue(stat_type));
            }
            m_Texts[2].SetActive(true);
        }
        else
        {
            m_Texts[2].SetActive(false);
        }

        m_LabelEquipEnchantPrice.text = Localization.Format("GoodsFormat", m_Equip.EnchantCost);

        if (bPlayTween)
        {
            m_PlayTween.Play(true);
        }
    }