Example #1
0
    public void Refresh()
    {
        if (UIWindow.IsLoaded())
        {
            UIWindow.AddCloseAction(Refresh);
            return;
        }

        if (LobbyScene.Get().GetBattleStage().IsLoaded())
        {
            LobbyScene.Get().GetBattleStage().AddUnloadAction(Refresh);
            return;
        }

        if (Prologue.IsLoaded())
        {
            UIWindow.AddCloseAction(Refresh);
        }

        DestroyChildren(gridParent);
        RefreshVisibleQuest();

        List <MtQuest> questList = new List <MtQuest>(visibleQuestDic.Values);

        questList.Sort(new QuestIDXComparer());

        bool hasMainQuest = false;

        List <QuestProgressText> progressTextList = new List <QuestProgressText>();

        if (questList.Count > 0)
        {
            foreach (MtQuest quest in questList)
            {
                QuestProgressText questProgressText = QuestProgressText.Create(gridParent, this, quest);

                progressTextList.Add(questProgressText);

                if (pointingReserved.Contains(quest.IDX) && !UITutorial.IsLoaded() && questProgressText.gameObject.activeSelf)
                {
                    if (UIQuestConversation.IsLoaded() || UIPointingFinger.IsLoaded() || UIWindow.IsLoaded() || Prologue.IsLoaded() || UIBuildResult.IsLoaded())
                    {
                        StartCoroutine(CheckRoutin(quest, questProgressText));
                    }
                    else
                    {
                        questProgressText.StartPointingOnMission();
                        pointingReserved.Remove(quest.IDX);
                    }
                }
                else
                {
                    pointingReserved.Remove(quest.IDX);
                }

                foreach (MtQuestMission mission in quest.Missions)
                {
                    if (!mission.IsAccomplished())
                    {
                        MissionProgressText.Create(questProgressText.transform, quest, mission);
                        break;
                    }
                }

                if (quest.QuestType == MtQuestTypes.MainStory)
                {
                    hasMainQuest = true;
                }
            }
        }

        if (!hasMainQuest && !UIQuestConversation.IsLoaded())
        {
            MtQuest quest = MtDataManager.GetQuestDataFromPreRequirementIDX(AccountInfo.instance.questStep);

            if (quest != null)
            {
                QuestProgressText questProgressText = QuestProgressText.Create(gridParent, this, quest, true);
                questProgressText.transform.SetAsFirstSibling();

                questList.Add(quest);
            }
        }

        zoomButton.SetActive(questList.Count > 0);

        if (questList.Count == 0)
        {
            ZoneTerrain.Get().zoneTiles.RefreshQuestMarks();
        }
        else
        {
            foreach (MtQuest quest in questList)
            {
                foreach (MtQuestMission missionInfo in quest.Missions)
                {
                    int x = 0, y = 0;

                    if (missionInfo.ActionType == MtMissionActionTypes.GotoLocationFromCastle)
                    {
                        x = missionInfo.TargetIndex1 + AccountInfo.instance.castlePositionX;
                        y = missionInfo.TargetIndex2 + AccountInfo.instance.castlePositionY;
                    }
                    else if (missionInfo.ActionType == MtMissionActionTypes.GotoLocationFromSherinStation)
                    {
                        x = MtStatic.SherinStationX;
                        y = MtStatic.SherinStationY;

                        MtTileInfo.GetPositionOnMyField(MtStatic.SherinStationX, MtStatic.SherinStationY, out x, out y, AccountInfo.instance.castlePositionX, AccountInfo.instance.castlePositionY);

                        x += missionInfo.TargetIndex1;
                        y += missionInfo.TargetIndex2;
                    }
                    else if (missionInfo.ActionType == MtMissionActionTypes.GotoLocationFromWooboldVillageStation)
                    {
                        x = MtStatic.WooboldVillageStationX;
                        y = MtStatic.WooboldVillageStationY;

                        MtTileInfo.GetPositionOnLavaField(MtStatic.WooboldVillageStationX, MtStatic.WooboldVillageStationY, out x, out y, AccountInfo.instance.castlePositionX, AccountInfo.instance.castlePositionY);

                        x += missionInfo.TargetIndex1;
                        y += missionInfo.TargetIndex2;
                    }
                    else if (missionInfo.ActionType == MtMissionActionTypes.GotoLocationFromOldCastleStation)
                    {
                        x = MtStatic.OldCastleStationX;
                        y = MtStatic.OldCastleStationY;

                        MtTileInfo.GetPositionOnMyField(MtStatic.OldCastleStationX, MtStatic.OldCastleStationY, out x, out y, AccountInfo.instance.castlePositionX, AccountInfo.instance.castlePositionY);

                        x += missionInfo.TargetIndex1;
                        y += missionInfo.TargetIndex2;
                    }
                    else if (missionInfo.ActionType == MtMissionActionTypes.GotoLocationFromLahindelStation)
                    {
                        x = MtStatic.LahindelStationX;
                        y = MtStatic.LahindelStationY;

                        MtTileInfo.GetPositionOnMyField(MtStatic.LahindelStationX, MtStatic.LahindelStationY, out x, out y, AccountInfo.instance.castlePositionX, AccountInfo.instance.castlePositionY);

                        x += missionInfo.TargetIndex1;
                        y += missionInfo.TargetIndex2;
                    }
                    else if (missionInfo.ActionType == MtMissionActionTypes.GotoLocationFromMarenStation)
                    {
                        x = MtStatic.MarenStationX;
                        y = MtStatic.MarenStationY;

                        MtTileInfo.GetPositionOnMyField(MtStatic.MarenStationX, MtStatic.MarenStationY, out x, out y, AccountInfo.instance.castlePositionX, AccountInfo.instance.castlePositionY);

                        x += missionInfo.TargetIndex1;
                        y += missionInfo.TargetIndex2;
                    }
                    else if (missionInfo.ActionType == MtMissionActionTypes.GotoLocationFromDotakCastle)
                    {
                        x = MtStatic.DotakCastleStationX;
                        y = MtStatic.DotakCastleStationY;

                        MtTileInfo.GetPositionOnLavaField(MtStatic.DotakCastleStationX, MtStatic.DotakCastleStationY, out x, out y, AccountInfo.instance.castlePositionX, AccountInfo.instance.castlePositionY);

                        x += missionInfo.TargetIndex1;
                        y += missionInfo.TargetIndex2;
                    }
                    else if (missionInfo.ActionType == MtMissionActionTypes.GotoLocationFromTitansGardenStation)
                    {
                        x = MtStatic.TitansGardenStationX;
                        y = MtStatic.TitansGardenStationY;

                        MtTileInfo.GetPositionOnLavaField(MtStatic.TitansGardenStationX, MtStatic.TitansGardenStationY, out x, out y, AccountInfo.instance.castlePositionX, AccountInfo.instance.castlePositionY);

                        x += missionInfo.TargetIndex1;
                        y += missionInfo.TargetIndex2;
                    }
                    else if (missionInfo.ActionType == MtMissionActionTypes.GotoLocationFromLastStageStation)
                    {
                        x = MtStatic.LastStageStationX;
                        y = MtStatic.LastStageStationY;

                        MtTileInfo.GetPositionOnLavaField(MtStatic.LastStageStationX, MtStatic.LastStageStationY, out x, out y, AccountInfo.instance.castlePositionX, AccountInfo.instance.castlePositionY);

                        x += missionInfo.TargetIndex1;
                        y += missionInfo.TargetIndex2;
                    }

                    if (x != 0 || y != 0)
                    {
                        ZoneTile tile = ZoneTerrain.Get().zoneTiles.GetTileByXY(x, y);
                        if (tile != null)
                        {
                            tile.Refresh3D();
                        }
                    }
                }
            }
        }

        if (questList.Count == 0)
        {
            backPanelImg.enabled = false;
        }
        else
        {
            backPanelImg.enabled = true;
        }

        RefreshHeight();
    }
Example #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);
    }