예제 #1
0
    public void UpDateGold(uint gold)
    {
        if (CurrentSlot <= 0)
        {
            return;
        }
        if (!myEnhance.ContainsKey(CurrentSlot))
        {
            return;
        }
        int level = myEnhance[CurrentSlot];

        if (!enhanceDataDic[CurrentSlot].ContainsKey(level + 1))
        {
            return;
        }
        if (StrenthenUIViewManager.Instance == null)
        {
            return;
        }
        BodyEnhanceData afterEnhanceData = enhanceDataDic[CurrentSlot][level + 1];
        string          goldStr          = "" + afterEnhanceData.gold;

        if (gold < afterEnhanceData.gold)
        {
            goldStr = "[FF0000]" + goldStr + "[-]";
            StrenthenUIViewManager.Instance.SetCostText(false);
        }
        Debug.Log("haha");
        StrenthenUIViewManager.Instance.SetStrenthenNeedGold(goldStr);
        StrenthenUIViewManager.Instance.SetCurrentGold(gold + "");
    }
예제 #2
0
    private bool CanEnhance(int slot)
    {
        int level = myEnhance[slot];

        if (!enhanceDataDic[slot].ContainsKey(level + 1))
        {
            Debug.Log("level max");
            return(false);
        }
        BodyEnhanceData enhanceData = enhanceDataDic[slot][level + 1];

        if (MogoWorld.thePlayer.level < enhanceData.characterLevel)
        {
            Debug.Log("level isnot enough ");
            return(false);
        }
        if (MogoWorld.thePlayer.gold < enhanceData.gold)
        {
            Debug.Log("gold isnot enough ");
            return(false);
        }

        if (enhanceData.material != null)
        {
            foreach (KeyValuePair <int, int> pair in enhanceData.material)
            {
                ItemMaterialData material = ItemMaterialData.dataMap[pair.Key];
                int materialNum           = InventoryManager.Instance.GetMaterialNum(pair.Key);
                if (materialNum < pair.Value)
                {
                    materialNum = InventoryManager.Instance.GetMaterialAllNum(pair.Key);
                    if (materialNum >= pair.Value)
                    {
                        continue;
                    }
                    else
                    {
                        Debug.Log("材料不够!");
                        return(false);
                    }
                }
            }
        }


        return(true);
    }
예제 #3
0
    /// <summary>
    /// 武器slot=10,对应位置为0
    /// 更新ui
    /// </summary>
    /// <param name="bBodyEnhanceSuccess">是否是强化成功而刷新界面</param>
    public void RefreshUI(bool bBodyEnhanceSuccess = false)
    {
        //Debug.Log("bodyEnhanceManager RefreshUI:" + CurrentSlot);

        //add by winJ
        if (StrenthenUIViewManager.Instance == null)
        {
            return;
        }

        // 强化成功刷新界面,播放强化成功动画准备
        if (bBodyEnhanceSuccess)
        {
            StrenthenUIViewManager.Instance.PreparePlaySuccessAnimation();
        }
        UpdateSlotToIndexDic();

        if (CurrentSlot == -1)
        {
            CurrentSlot = 10;
        }

        StrenthenUIViewManager.Instance.SetCurrentGold(MogoWorld.thePlayer.gold + "");
        Debug.Log("currentSlot:" + CurrentSlot);
        int level = myEnhance[CurrentSlot];

        Debug.Log("level:" + level);
        BodyEnhanceData baseEnhanceData = enhanceDataDic[CurrentSlot][level];

        //刷新左边栏信息
        for (int i = 0; i < BodyName.names.Length; i++)
        {
            int             slot                = m_indexToSlotList[i];
            int             levelTemp           = myEnhance[slot];
            BodyEnhanceData baseEnhanceDataTemp = enhanceDataDic[slot][levelTemp];
            StrenthenUIViewManager.Instance.SetEquipmentName(i, BodyName.names[slot - 1]);
            int  actualSlot = (slot == 10 ? 11 : slot);
            bool hasEquip   = false;
            if (actualSlot == 9)
            {
                if (InventoryManager.Instance.EquipOnDic.ContainsKey(9) ||
                    InventoryManager.Instance.EquipOnDic.ContainsKey(10))
                {
                    hasEquip = true;
                }
            }
            else if (InventoryManager.Instance.EquipOnDic.ContainsKey(actualSlot))
            {
                hasEquip = true;
            }
            StrenthenUIViewManager.Instance.SetEquipmentIcon(i, BodyIcon.icons[slot - 1], hasEquip ? 0 : 10);
            StrenthenUIViewManager.Instance.SetEquipmentTextImg(i, BodyTextIcon.icons[slot - 1]);

            // 设置星级
            if (myEnhance.ContainsKey(slot))
            {
                StrenthenUIViewManager.Instance.SetEquipmentIconStarLevel(i, baseEnhanceDataTemp.star);
            }
        }

        int id = baseEnhanceData.propertyEffectId;
        PropertyEffectData     basePropertyData = PropertyEffectData.dataMap[id];
        StrenthenUIViewManager view             = StrenthenUIViewManager.Instance;

        view.SetEquipmentAfterAttribute("");
        view.SetEquipmentAfterLevel0Reward("");
        view.SetEquipmentAfterLevel1Reward("");
        view.SetEquipmentAfterLevel2Reward("");
        view.SetEquipmentImage(BodyIcon.icons[CurrentSlot - 1]);

        BodyEnhanceData    afterEnhanceData  = null;
        PropertyEffectData afterPropertyData = null;

        if (enhanceDataDic[CurrentSlot].ContainsKey(level + 1))
        {
            afterEnhanceData  = enhanceDataDic[CurrentSlot][level + 1];
            afterPropertyData = PropertyEffectData.dataMap[afterEnhanceData.propertyEffectId];

            int    nextStarLevel = level + (LEVEL_PER_STAR - level % LEVEL_PER_STAR);
            string temp          = "";
            if (enhanceDataDic[CurrentSlot].ContainsKey(nextStarLevel))
            {
                temp = LanguageData.dataMap[173].Format(enhanceDataDic[CurrentSlot][nextStarLevel].enhanceRate / 100);
            }

            view.SetEquipmentAfterAttribute(temp);
            view.SetEquipmentAfterLevel0Reward("+" + afterPropertyData.hpBase);
            view.SetEquipmentAfterLevel1Reward("+" + afterPropertyData.attackBase);
            view.SetEquipmentAfterLevel2Reward("+" + afterPropertyData.defenseBase);

            string gold = "" + afterEnhanceData.gold;
            bool   hasEnoughGoldAndMat = true;
            if (myself.gold < afterEnhanceData.gold)
            {
                gold = "[FF0000]" + gold + "[-]";
                hasEnoughGoldAndMat = false;
            }

            view.SetNeedLevel(afterEnhanceData.characterLevel);
            view.SetStrenthenNeedGold(gold);

            string     material     = "";
            bool       hasEnoughMat = true;
            List <int> reqMatIdList = new List <int>();
            reqMatIdList.Clear();

            view.ShowStrenthenNeedMaterial2(false);
            if (afterEnhanceData.material == null || afterEnhanceData.material.Count <= 0)
            {
                view.SetStrenthenNeedMaterial1("0");
            }
            else
            {
                int materialNum = 0;
                //这里暂时默认只需要一种材料,以后可以扩展
                int count = 0;
                foreach (KeyValuePair <int, int> pair in afterEnhanceData.material)
                {
                    materialNum = myself.inventoryManager.GetMaterialNum(pair.Key);
                    material    = "" + pair.Value;
                    if (materialNum < pair.Value)
                    {
                        material            = "[FF0000]" + material + "[-]";
                        hasEnoughGoldAndMat = false;
                        hasEnoughMat        = false;
                        reqMatIdList.Add(pair.Key);
                    }
                    if (count == 0)
                    {
                        view.SetStrenthenNeedMaterialIcon1(pair.Key);
                        view.SetStrenthenNeedMaterial1(material + "/" + materialNum);
                    }
                    else
                    {
                        view.SetStrenthenNeedMaterialIcon2(pair.Key);
                        view.SetStrenthenNeedMaterial2(material + "/" + materialNum);
                    }
                    count++;
                }

                if (count >= 2)
                {
                    view.ShowStrenthenNeedMaterial2(true);
                }
            }

            if (!hasEnoughGoldAndMat)
            {
                view.SetCostText(false);
            }
            else
            {
                view.SetCostText(true);
            }

            view.ShowMaterialTip(!hasEnoughMat);

            if (reqMatIdList.Count == 1)
            {
                view.ShowMaterialObtainTip(false, true, reqMatIdList[0], 0);
            }
            else if (reqMatIdList.Count > 1)
            {
                view.ShowMaterialObtainTip(false, true, reqMatIdList[0], reqMatIdList[1]);
            }
        }

        view.SetEquipmentStarLevel(baseEnhanceData.star, baseEnhanceData.progress);

        view.SetBaseEquipType(EquipSlotName.names[CurrentSlot - 1]);
        view.SetEquipmentBaseAttribute(LanguageData.dataMap[167].Format(baseEnhanceData.enhanceRate / 100 + "%"));

        view.SetEquipmentLevel(baseEnhanceData.progress);
        view.SetEquipmentExp(baseEnhanceData.progress);

        view.SetEquipmentBaseLevel0Reward(LanguageData.GetContent(48004), string.Concat("+ ", basePropertyData.hpBase));
        view.SetEquipmentBaseLevel1Reward(LanguageData.GetContent(48005), string.Concat("+ ", basePropertyData.attackBase));
        view.SetEquipmentBaseLevel2Reward(LanguageData.GetContent(48006), string.Concat("+ ", basePropertyData.defenseBase));

        //switch (myself.vocation)
        //{
        //    case Vocation.Archer:
        //    case Vocation.Mage:
        //        view.SetEquipmentBaseLevel3Reward(LanguageData.dataMap[173].Format(basePropertyData.atkA));
        //        if (hasNextLevel)
        //            view.SetEquipmentAfterLevel3Reward(LanguageData.dataMap[173].Format(afterPropertyData.atkA));
        //        break;
        //    case Vocation.Assassin:
        //    case Vocation.Warrior:
        //        view.SetEquipmentBaseLevel3Reward(LanguageData.dataMap[172].Format(basePropertyData.atkA));
        //        if (hasNextLevel)
        //            view.SetEquipmentAfterLevel3Reward(LanguageData.dataMap[172].Format(afterPropertyData.atkA));
        //        break;
        //}

        StrenthenUIViewManager.Instance.SetCurrentDownGrid(m_slotToIndexDic[CurrentSlot]);

        // 强化成功刷新界面,播放强化成功动画
        if (bBodyEnhanceSuccess)
        {
            StrenthenUIViewManager.Instance.PlaySuccessAnimation(baseEnhanceData.progress / 10);
        }
    }
예제 #4
0
    private bool CheckEnhanceCondition()
    {
        if (m_isEnhancing)
        {
            return(false);
        }
        int level = myEnhance[CurrentSlot];

        if (!enhanceDataDic[CurrentSlot].ContainsKey(level + 1))
        {
            Debug.Log("等级已满!");
            OnBodyEnhaUpgResp(ERR_BODY_LEVEL_ALREADY_MAX);
            return(false);
        }
        BodyEnhanceData enhanceData = enhanceDataDic[CurrentSlot][level + 1];

        if (MogoWorld.thePlayer.level < enhanceData.characterLevel)
        {
            Debug.Log("等级不够!");
            OnBodyEnhaUpgResp(ERR_BODY_ENHANCE_LEVEL);
            return(false);
        }
        if (MogoWorld.thePlayer.gold < enhanceData.gold)
        {
            Debug.Log("金币不够!");
            OnBodyEnhaUpgResp(ERR_BODY_ENHANCE_GOLD_NOT_ENOUGH);
            return(false);
        }


        if (enhanceData.material != null)
        {
            bool          hasEnoughMaterial        = true;
            bool          needToSpendOtherMaterial = false;
            string        msg = string.Empty;
            List <string> needMaterialNameList  = new List <string>();
            List <int>    needMaterialValueList = new List <int>();
            List <string> costMaterialNameList  = new List <string>();
            List <int>    costMaterialValueList = new List <int>();

            foreach (KeyValuePair <int, int> pair in enhanceData.material)
            {
                ItemMaterialData material = ItemMaterialData.dataMap[pair.Key];
                int materialNum           = InventoryManager.Instance.GetMaterialNum(pair.Key);
                if (materialNum < pair.Value)
                {
                    needToSpendOtherMaterial = true;
                    materialNum = InventoryManager.Instance.GetMaterialAllNum(pair.Key);
                    if (materialNum >= pair.Value)
                    {
                        List <KeyValuePair <int, int> > list = InventoryManager.Instance.GetMaterialList(pair.Key, pair.Value);
                        needMaterialNameList.Add(material.Name);
                        needMaterialValueList.Add(pair.Value);
                        //msg += "\n" + LanguageData.dataMap[458].Format(material.Name, pair.Value);
                        for (int i = 0; i < list.Count; i++)
                        {
                            ItemMaterialData tempMaterial = ItemMaterialData.dataMap[list[i].Key];

                            costMaterialNameList.Add(tempMaterial.Name);
                            costMaterialValueList.Add(list[i].Value);
                            //msg += "\n" + LanguageData.dataMap[459].Format(tempMaterial.Name, list[i].Value);
                        }
                    }
                    else
                    {
                        hasEnoughMaterial = false;
                        Debug.Log("材料不够!");
                        OnBodyEnhaUpgResp(ERR_BODY_ENHANCE_MATERIAL_NOT_ENOUGH, pair.Value, material.Name);
                        return(false);
                    }
                }
                else
                {
                    continue;
                }
            }

            if (hasEnoughMaterial && needToSpendOtherMaterial)
            {
                msg = LanguageData.dataMap[458].content;
                for (int i = 0; i < needMaterialNameList.Count; i++)
                {
                    msg += LanguageData.dataMap[460].Format(needMaterialNameList[i], needMaterialValueList[i]) + ",";
                }
                msg += LanguageData.GetContent(459) + "\n";
                for (int i = 0; i < costMaterialNameList.Count; i++)
                {
                    msg += LanguageData.dataMap[460].Format(costMaterialNameList[i], costMaterialValueList[i]) + ",\n";
                }


                MogoGlobleUIManager.Instance.Confirm(msg, (rst) =>
                {
                    if (rst)
                    {
                        m_isEnhancing = true;
                        m_timerId     = TimerHeap.AddTimer(2000, 0, () => { m_isEnhancing = false; });
                        myself.RpcCall("BodyEnhaUpgReq", (byte)CurrentSlot);
                        MogoGlobleUIManager.Instance.ConfirmHide();
                    }
                    else
                    {
                        MogoGlobleUIManager.Instance.ConfirmHide();
                    }
                });
                return(false);
            }
        }


        return(true);
    }