示例#1
0
    private void Update()
    {
        info.text = "Ticks " + GameData.Instance.gameTime + " speed " + GameData.Instance.gameSpeed;

        for (int i = 0; i < GameData.Instance.kingdoms.Count; ++i)
        {
            int a = i;

            if (kingdomInfos.Count <= i)
            {
                UIKingdomInfo newKingdomInfo = GameObject.Instantiate(kingdomInfoTemplate);
                newKingdomInfo.gameObject.SetActive(true);
                newKingdomInfo.attackingInfoBody.gameObject.SetActive(false);
                newKingdomInfo.transform.parent = kingdomInfoParent;
                newKingdomInfo.kingdomInfoBody.onClick.AddListener(delegate { MoveCamera(a); });
                kingdomInfos.Add(newKingdomInfo);
            }

            Kingdom       kingdom     = GameData.Instance.kingdoms [i];
            UIKingdomInfo kingdomInfo = kingdomInfos [i];
            kingdomInfo.kingdomInfo.text    = "Kingdom " + i;
            kingdomInfo.food.text           = kingdom.food.ToString();
            kingdomInfo.wood.text           = kingdom.wood.ToString();
            kingdomInfo.stone.text          = kingdom.stone.ToString();
            kingdomInfo.iron.text           = kingdom.iron.ToString();
            kingdomInfo.gold.text           = kingdom.gold.ToString();
            kingdomInfo.foodGatherers.text  = (kingdom.foodGatherers + kingdom.farmers).ToString();
            kingdomInfo.woodGatherers.text  = kingdom.lumberjacks.ToString();
            kingdomInfo.stoneGatherers.text = kingdom.stoneMiners.ToString();
            kingdomInfo.ironGatherers.text  = kingdom.ironMiners.ToString();
            kingdomInfo.goldGatherers.text  = kingdom.goldMiners.ToString();
            kingdomInfo.peasants.text       = kingdom.population + "/" + kingdom.populationCap;
            kingdomInfo.warriors.text       = kingdom.warriors.ToString();
            kingdomInfo.archers.text        = kingdom.archers.ToString();

            if (kingdom.attacking != -1)
            {
                if (kingdomInfo.attackingKingdom != kingdom.attacking)
                {
                    kingdomInfo.attackingInfoBody.gameObject.SetActive(true);
                    kingdomInfo.attackingInfoBody.onClick.RemoveAllListeners();
                    kingdomInfo.attackingInfoBody.onClick.AddListener(delegate { MoveCameraToAttackGroup(a); });
                }

                kingdomInfo.attackingKingdomInfo.text = "Attacking Kingdom " + kingdom.attacking;
                int warriors = kingdom.unitsToAttackWith.FindAll(m => m.unitType == UnitTypes.Warrior).Count;
                kingdomInfo.attackingWarriors.text = warriors.ToString();
                kingdomInfo.attackingArchers.text  = (kingdom.unitsToAttackWith.Count - warriors).ToString();
                kingdomInfo.attackingKingdom       = kingdom.attacking;
            }
            else if (kingdomInfo.attackingKingdom != kingdom.attacking)
            {
                kingdomInfo.attackingInfoBody.gameObject.SetActive(false);
                kingdomInfo.attackingKingdom = -1;
            }
        }
    }
示例#2
0
    public static UIQuestBox Create(int top = 320)
    {
        if (singleton == null)
        {
            Transform  parent = FindBottomParent();
            GameObject go     = Instantiate(MtAssetBundles.Load("prefab/ui/quest/" + PrefabPath)) as GameObject;

            singleton = Create <UIQuestBox>(go, parent);
            singleton.InitializeOnce();
        }

        singleton.transform.SetParent(UIKingdomInfo.Get().uiQuestBoxParentTrs);

        RectTransform rect = singleton.GetComponent <RectTransform>();

        rect.anchoredPosition = Vector2.zero;//new Vector2(10, top);
        singleton.transform.SetAsFirstSibling();

        //singleton.transform.SetParent(FindHeaderParent());

        //singleton.questList = AccountInfo.instance.questList;

        return(singleton);
    }
示例#3
0
    public void OnResponseLearnNationAttribute(MtPacket_LearnNationAttribute_Response typed_pk)
    {
        //클라이언트에서 조건 확인후 Request하기때문에 (-1, 0)값은 오면 안됨.
        if (typed_pk.Result == -1) //다른 연구 진행중
        {
            return;
        }
        else if (typed_pk.Result == -2)
        {
            return; //선행특성조건 불만족
        }
        else if (typed_pk.Result == -3)
        {
            return;                    //Max레벨
        }
        else if (typed_pk.Result == 0) //자원부족
        {
            return;
        }
        else
        {
            researchButton.GetComponentInChildren <Text>().text = MWText.instance.GetText(MWText.EText.E_948);
            researchButton.GetComponent <Image>().color         = new Color(0.75f, 0.75f, 0.75f);
            researchButton.interactable = false;

            //시작성공했으면 AccountInfo 값변경
            AccountInfo.instance.RefreshAttribute(typed_pk.MyNationAttribute);
            researchInProgressAttribute = AccountInfo.instance.GetResearchInProgressAttribute();

            if (researchInProgressAttribute != null)
            {
                if (curSelectedAttributeInfo.AttributeType == researchInProgressAttribute.AttributeType)
                {
                    TimeSpan ts = researchInProgressAttribute.LearningEndTime - DateTime.Now;
                    progressBarTimeText.text = ConverTimeToString((int)ts.TotalSeconds);
                }
            }

            AccountInfo.instance.gold  -= typed_pk.CostGold;
            AccountInfo.instance.stone -= typed_pk.CostStone;
            AccountInfo.instance.wood  -= typed_pk.CostWood;
            AccountInfo.instance.gem   -= typed_pk.CostGem;

            UIKingdomInfo.Get().ResetAccountData();

            if (researchInProgressAttribute != null)
            {
                OnClickSlot(researchInProgressAttribute.AttributeType);
            }

            PlayerPrefs.SetInt("LastResearchTab", (int)curSelectedAttributeInfo.AttributeUseType);

            if (bAdvisorDoIt)
            {
                ZoneTile tile = ZoneTerrain.Get().zoneTiles.GetMyTile(MtTileTypes.BuildingMageTower);

                if (tile != null)
                {
                    string msg = string.Format(MWText.instance.GetText(MWText.EText.E_2174), curSelectedAttributeInfo.AttributeName + " " + UIUtility.GetLevelString(curSelectedAttributeInfo.CurLevel));

                    UIAdvisorTalkPop.Create(tile.transform, msg);
                }
            }

            AudioPlayer.Get().PlaySituationSound(SituationSoundType.ResearchAttribute);

            Close();
        }
    }