Пример #1
0
 public void OnClickJustNowButton()
 {
     if (shortageTypes.Count > 0)
     {
         UIShortageResources.Create(shortageTypes.ToArray(), shortageValue.ToArray(), delegate { RefreshCost(goldCost, stoneCost, woodCost); }, false);
     }
     else if (AccountInfo.instance.gem < MtStatic.GetJustNowCompleteGemCost(curSelectedAttributeInfo.LearningDuration))
     {
         UIToastMessage.Create(MWText.instance.GetText(MWText.EText.E_2281));
     }
     else
     {
         if (AccountInfo.instance.gold >= goldCost && AccountInfo.instance.stone >= stoneCost && AccountInfo.instance.wood >= woodCost)
         {
             LobbyScene.Get().RequestLearnNationAttribute(curSelectedAttributeInfo.AttributeType, true, OnResponseLearnNationAttribute);
         }
         else
         {
             UIToastMessage.Create(MWText.instance.GetText(MWText.EText.E_2175));
         }
     }
 }
Пример #2
0
    public void OnClickSlot(MtNationAttributeTypes type)
    {
        MtNationAttribute attributeInfo     = null;
        MtNationAttribute nextAttributeInfo = null;

        int nextLevelCostGold             = 0;
        int nextLevelCostStone            = 0;
        int nextLevelCostWood             = 0;
        int nextLevelLearningDurationTime = 0;

        int requiredMageTowerLevel = 0;

        bool researchAvailableFlag = true;

        //습득한 특성이면
        if (AccountInfo.instance.HasAttribute(type))
        {
            //0레벨 예외처리
            int curLevel = AccountInfo.instance.GetMyNationAttributeLevel(type);

            attributeInfo = MtDataManager.GetAttributeData(type, AccountInfo.instance.GetMyNationAttributeLevel(type) == 0 ? 1 : AccountInfo.instance.GetMyNationAttributeLevel(type));

            //MaxLevel이 아닐시
            if (attributeInfo.CurLevel < attributeInfo.MaxLevel)
            {
                nextAttributeInfo = MtDataManager.GetAttributeData(type, curLevel + 1);

                levelInfoPanel.gameObject.SetActive(true);
                maxLevelLabel.gameObject.SetActive(false);
                curSelectedAttributeCurLevelText.text  = curLevel.ToString();
                curSelectedAttributeNextLevelText.text = nextAttributeInfo.CurLevel.ToString();


                addValueTextPanel.gameObject.SetActive(true);
                maxValueLabel.gameObject.SetActive(false);
                curSelectedAttributeCurValueText.text = (curLevel == 0 ? 0 : attributeInfo.AffectValue).ToString() + GetSignFromAttributeType(attributeInfo.AttributeType);
                curSelectedAttributeCurValueText.GetComponent <RectTransform>().sizeDelta = new Vector2(curSelectedAttributeCurValueText.preferredWidth, curSelectedAttributeCurValueText.preferredHeight);
                curSelectedAttributeNextValueText.text = nextAttributeInfo.AffectValue.ToString() + GetSignFromAttributeType(attributeInfo.AttributeType);
                curSelectedAttributeNextValueText.GetComponent <RectTransform>().sizeDelta = new Vector2(curSelectedAttributeNextValueText.preferredWidth, curSelectedAttributeNextLevelText.preferredHeight);

                nextLevelCostGold             = nextAttributeInfo.Cost_Gold;
                nextLevelCostStone            = nextAttributeInfo.Cost_Stone;
                nextLevelCostWood             = nextAttributeInfo.Cost_Wood;
                nextLevelLearningDurationTime = nextAttributeInfo.LearningDuration;


                requiredMageTowerLevel = nextAttributeInfo.RequiredMageTowerLevel;
            }
            else
            {
                levelInfoPanel.gameObject.SetActive(false);
                maxLevelLabel.gameObject.SetActive(true);

                addValueTextPanel.gameObject.SetActive(false);
                maxValueLabel.gameObject.SetActive(true);

                string str = attributeInfo.AffectValue.ToString() + GetSignFromAttributeType(attributeInfo.AttributeType);
                maxValueLabel.text = string.Format("(<color=#57FF4F> +{0}</color> )", str);


                researchAvailableFlag = false;
            }

            curSelectedAttributeNameText.text        = attributeInfo.AttributeName;
            curSelectedAttributeDescriptionText.text = attributeInfo.AttributeDescription;
        }
        //습득하지 않은경우
        else
        {
            attributeInfo = MtDataManager.GetAttributeData(type, 1);

            levelInfoPanel.gameObject.SetActive(true);
            maxLevelLabel.gameObject.SetActive(false);

            curSelectedAttributeCurLevelText.text  = "0";
            curSelectedAttributeNextLevelText.text = attributeInfo.CurLevel.ToString();

            maxValueLabel.gameObject.SetActive(true);
            addValueTextPanel.gameObject.SetActive(false);
            string str = attributeInfo.AffectValue.ToString() + GetSignFromAttributeType(attributeInfo.AttributeType);
            maxValueLabel.text = string.Format("(<color=#57FF4F> +{0}</color> )", str);

            curSelectedAttributeNameText.text        = attributeInfo.AttributeName;
            curSelectedAttributeDescriptionText.text = attributeInfo.AttributeDescription;

            nextLevelCostGold             = attributeInfo.Cost_Gold;
            nextLevelCostStone            = attributeInfo.Cost_Stone;
            nextLevelCostWood             = attributeInfo.Cost_Wood;
            nextLevelLearningDurationTime = attributeInfo.LearningDuration;

            requiredMageTowerLevel = attributeInfo.RequiredMageTowerLevel;
        }

        curSelectedAttributeInfo      = attributeInfo;
        detailViewButton.interactable = true;

        MtTileInfo mageTowerTileInfo = ZoneTilesSet.GetMyTileInfo(MtTileTypes.BuildingMageTower);

        if (mageTowerTileInfo != null)
        {
            nextLevelLearningDurationTime -= (int)Math.Floor((float)nextLevelLearningDurationTime * (MtStatic.GetResearchAttributeSpeedBonus(mageTowerTileInfo.TileLevel) / 100.0f));
        }

        float att_value = AccountInfo.instance.GetNationAttributeValue(MtNationAttributeTypes.Magic);

        if (att_value > 0)
        {
            nextLevelLearningDurationTime -= (int)Math.Floor((float)nextLevelLearningDurationTime * (att_value / 100.0f));
        }

        att_value = AccountInfo.instance.GetNationAttributeValue(MtNationAttributeTypes.Enchanting);
        if (att_value > 0)
        {
            nextLevelLearningDurationTime -= (int)Math.Floor((float)nextLevelLearningDurationTime * (att_value / 100.0f));
        }

        MtWorldAffect aff = AccountInfo.instance.GetAffect(MtWorldAffectTypes.UnitResearchUp);

        if (aff != null)
        {
            nextLevelLearningDurationTime -= (int)Math.Floor((float)nextLevelLearningDurationTime * ((float)aff.AffectValue / 100.0f));
        }

        //소요시간 텍스트
        learnDurationTimeText.text = ConverTimeToString(nextLevelLearningDurationTime);
        costGemText.text           = string.Format("{0:n0}", MtStatic.GetJustNowCompleteGemCost(nextLevelLearningDurationTime));

        goldCost  = nextLevelCostGold;
        stoneCost = nextLevelCostStone;
        woodCost  = nextLevelCostWood;

        #region 자원조건확인
        //자원충족여부
        RefreshCost(nextLevelCostGold, nextLevelCostStone, nextLevelCostWood);
        #endregion

        #region 마법사의탑 조건확인
        //마법사의탑 레벨확인
        if (requiredMageTowerLevel > 0)
        {
            requredMageTowerLevel.SetActive(true);
        }
        else
        {
            requredMageTowerLevel.SetActive(false);
        }

        MtBuilding data = MtDataManager.GetBuildingData(MtTileTypes.BuildingMageTower, 1);

        requredMageTowerLevelText.text = string.Format(data.BuildingName + " Lv{0}", requiredMageTowerLevel.ToString());

        if (requiredMageTowerLevel > mageTowerTileInfo.TileLevel)
        {
            requredMageTowerLevelText.color = new Color(230.0f / 255.0f, 69.0f / 255.0f, 69.0f / 255.0f);
            researchAvailableFlag           = false;
        }
        else
        {
            requredMageTowerLevelText.color = new Color(255.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f);
        }
        #endregion

        #region  행스킬 조건확인

        int[] prevAttributeIDXs = { attributeInfo.PrevAttributeIDX1, attributeInfo.PrevAttributeIDX2, attributeInfo.PrevAttributeIDX3, attributeInfo.PrevAttributeIDX4 };

        foreach (int idx in prevAttributeIDXs)
        {
            if (idx == 0)
            {
                continue;
            }

            MtNationAttribute attribute = MtDataManager.GetAttributeData(idx);

            if (AccountInfo.instance.HasAttribute(attribute.AttributeType))
            {
                if (attribute.CurLevel > AccountInfo.instance.GetMyNationAttributeLevel(attribute.AttributeType))
                {
                    researchAvailableFlag = false;
                }
            }
            else
            {
                researchAvailableFlag = false;
            }
        }

        #endregion

        if (researchInProgressAttribute != null)
        {
            researchAvailableFlag = false;
            if (researchInProgressAttribute.AttributeType == curSelectedAttributeInfo.AttributeType)
            {
                researchButton.GetComponentInChildren <Text>().text = MWText.instance.GetText(MWText.EText.E_948);
                researchProgressPanel.gameObject.SetActive(true);
                researchCostPanel.gameObject.SetActive(false);
                researchButton.gameObject.SetActive(false);
                justNowButton.gameObject.SetActive(false);
                accelationButton.gameObject.SetActive(true);
            }
            else
            {
                researchProgressPanel.gameObject.SetActive(false);
                researchCostPanel.gameObject.SetActive(true);
                researchButton.gameObject.SetActive(true);
                justNowButton.gameObject.SetActive(true);
                accelationButton.gameObject.SetActive(false);
            }
        }
        else
        {
            researchProgressPanel.gameObject.SetActive(false);
            researchCostPanel.gameObject.SetActive(true);
            researchButton.gameObject.SetActive(true);
            justNowButton.gameObject.SetActive(true);
            accelationButton.gameObject.SetActive(false);
        }

        if (researchAvailableFlag)
        {
            researchButton.interactable = true;
            researchButton.GetComponent <Image>().color = new Color(255.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f);
            learnDurationTimeText.color = new Color(234f / 255.0f, 234f / 255.0f, 234f / 255.0f);

            justNowButton.interactable = true;
            justNowButton.GetComponent <Image>().color = new Color(1f, 1f, 1f);
            costGemText.color = new Color(234f / 255.0f, 234f / 255.0f, 234f / 255.0f);
        }
        else
        {
            researchButton.interactable = false;
            researchButton.GetComponent <Image>().color = new Color(0.75f, 0.75f, 0.75f);
            learnDurationTimeText.color = new Color(234f / 255.0f, 234f / 255.0f, 234f / 255.0f, 0.5f);

            justNowButton.interactable = false;
            justNowButton.GetComponent <Image>().color = new Color(0.75f, 0.75f, 0.75f);
            costGemText.color = new Color(234f / 255.0f, 234f / 255.0f, 234f / 255.0f, 0.5f);
        }

        attributeInfoWindow.SetActive(true);
        currentResearchPanel.SetActive(false);
        levelSlider.maxValue = attributeInfo.MaxLevel;

        levelSlider.value     = AccountInfo.instance.GetMyNationAttributeLevel(attributeInfo.AttributeType);
        levelSliderText.text  = string.Format("{0}/{1}", (int)levelSlider.value, attributeInfo.MaxLevel);
        attributeImage.sprite = UIUtility.LoadResearchAttributeImage(attributeInfo.AttributeType);
    }