コード例 #1
0
ファイル: UICommand.cs プロジェクト: Tracydrr/Tracydrr
        public CommandButton(GameObject _go, Sprite _symbol, string _text, PayType _payType, int _buyPrice, UnityAction _call)
        {
            go         = _go;
            Background = go.GetComponent <Image>();
            Title      = go.transform.Find("Title").GetComponent <Text>();
            Icon       = go.transform.Find("Icon").GetComponent <Image>();
            Price      = go.transform.Find("Price").GetComponent <Text>();
            PriceIcon  = go.transform.Find("PriceIcon").GetComponent <Image>();
            Symbol     = _symbol;
            Title.text = _text;
            call       = _call;
            Disabled   = false;
            Locked     = false;

            payType  = _payType;
            BuyPrice = _buyPrice;

            Icon.overrideSprite = Symbol;

            Price.text = (BuyPrice == 0) ? "" : BuyPrice.ToString("#,##0");
            PriceIcon.overrideSprite = TBDatabase.GetPayTypeIcon(_payType);
            PriceIcon.gameObject.SetActive((BuyPrice == 0) ? false : true);
            //PriceIcon.gameObject.SetActive (false);

            State(false);
        }
コード例 #2
0
 // set price icon and value
 public void PriceInfoApply(Image _PriceIcon, Text _Price)
 {
     if (BuildGoldPrice != 0)
     {
         _PriceIcon.sprite = TBDatabase.GetPayTypeIcon(PayType.Gold);
         _Price.text       = BuildGoldPrice.ToString("#,##0");
     }
     else if (BuildElixirPrice != 0)
     {
         _PriceIcon.sprite = TBDatabase.GetPayTypeIcon(PayType.Elixir);
         _Price.text       = BuildElixirPrice.ToString("#,##0");
     }
     else if (BuildGemPrice != 0)
     {
         _PriceIcon.sprite = TBDatabase.GetPayTypeIcon(PayType.Gem);
         _Price.text       = BuildGemPrice.ToString("#,##0");
     }
     else
     {
     }
 }
コード例 #3
0
        public void OnButtonInstant()
        {
            if (!TownLevelOk)
            {
                // upgrade not available
                return;
            }

            // checkuser has enough gem count
            if (SceneTown.Gem.Target() < GemCount)
            {
                // you need more gem
                UIDialogMessage.Show("More Gem Required", "Ok", "Error", TBDatabase.GetPayTypeIcon(PayType.Gem));

                return;
            }

            // decrease gem count and upgrade immediately
            SceneTown.Gem.ChangeDelta(-GemCount);
            building.UpgradeEnd();
            SceneTown.instance.BuildingSelect(null);

            _Hide();
        }
コード例 #4
0
        // fill building upgrading info in building upgrade ask dialog
        public void UIFillProgressWithNext(ProgressInfo progress, BDInfo type)
        {
            if (type == BDInfo.CapacityGold)
            {
                progress.imageIcon.sprite       = TBDatabase.GetPayTypeIcon(PayType.Gold);
                progress.textInfo.text          = "Capacity : " + def.Capacity[(int)PayType.Gold].ToString("#,##0") + "+" + (defNext.Capacity[(int)PayType.Gold] - def.Capacity[(int)PayType.Gold]).ToString("#,##0");
                progress.imageMiddle.fillAmount = (defNext == null) ? 0.0f : (float)defNext.Capacity[(int)PayType.Gold] / (float)defLast.Capacity[(int)PayType.Gold];
                progress.imageFront.fillAmount  = (float)def.Capacity[(int)PayType.Gold] / (float)defLast.Capacity[(int)PayType.Gold];
            }
            else if (type == BDInfo.CapacityElixir)
            {
                progress.imageIcon.sprite       = TBDatabase.GetPayTypeIcon(PayType.Elixir);
                progress.textInfo.text          = "Capacity : " + def.Capacity[(int)PayType.Elixir].ToString("#,##0") + "+" + (defNext.Capacity[(int)PayType.Elixir] - def.Capacity[(int)PayType.Elixir]).ToString("#,##0");
                progress.imageMiddle.fillAmount = (defNext == null) ? 0.0f : (float)defNext.Capacity[(int)PayType.Elixir] / (float)defLast.Capacity[(int)PayType.Elixir];
                progress.imageFront.fillAmount  = (float)def.Capacity[(int)PayType.Elixir] / (float)defLast.Capacity[(int)PayType.Elixir];
            }
            else if (type == BDInfo.Capacity)
            {
                progress.imageIcon.sprite       = TBDatabase.GetPayTypeIcon(def.eProductionType);
                progress.textInfo.text          = "Capacity : " + def.Capacity[(int)def.eProductionType].ToString("#,##0") + "+" + (defNext.Capacity[(int)defNext.eProductionType] - def.Capacity[(int)def.eProductionType]).ToString("#,##0");
                progress.imageMiddle.fillAmount = (defNext == null) ? 0.0f : (float)defNext.Capacity[(int)defNext.eProductionType] / (float)defLast.Capacity[(int)defLast.eProductionType];
                progress.imageFront.fillAmount  = (float)def.Capacity[(int)def.eProductionType] / (float)defLast.Capacity[(int)defLast.eProductionType];
            }
            else if (type == BDInfo.ProductionRate)
            {
                progress.imageIcon.sprite       = TBDatabase.GetPayTypeIcon(def.eProductionType);
                progress.textInfo.text          = "ProductionRate : " + ((int)(def.ProductionRate * 3600.0f)).ToString("#,##0") + "+" + ((int)((defNext.ProductionRate - def.ProductionRate) * 3600.0f)).ToString("#,##0") + " per Hour";
                progress.imageMiddle.fillAmount = (defNext == null) ? 0.0f : defNext.ProductionRate / defLast.ProductionRate;
                progress.imageFront.fillAmount  = def.ProductionRate / defLast.ProductionRate;
            }
            else if (type == BDInfo.HitPoint)
            {
                progress.imageIcon.sprite       = Resources.Load <Sprite>("Icons/Heart");
                progress.textInfo.text          = "HitPoints : " + def.HitPoint.ToString("#,##0") + "+" + (defNext.HitPoint - def.HitPoint).ToString("#,##0");
                progress.imageMiddle.fillAmount = (defNext == null) ? 0.0f : (float)defNext.HitPoint / (float)defLast.HitPoint;
                progress.imageFront.fillAmount  = (float)def.HitPoint / (float)defLast.HitPoint;
            }
            else if (type == BDInfo.StorageCapacity)
            {
                PayType payType = PayType.None;
                for (int i = 0; i < (int)PayType.Max; ++i)
                {
                    if (def.Capacity[i] != 0)
                    {
                        payType = (PayType)i;
                        break;
                    }
                }
                if (payType == PayType.None)
                {
                    return;
                }

                progress.imageIcon.sprite       = TBDatabase.GetPayTypeIcon(payType);
                progress.textInfo.text          = "Storage Capacity : " + def.Capacity[(int)payType].ToString("#,##0") + "+" + (defNext.Capacity[(int)payType] - def.Capacity[(int)payType]).ToString("#,##0");
                progress.imageMiddle.fillAmount = defNext.Capacity[(int)payType] / (float)defLast.Capacity[(int)payType];
                progress.imageFront.fillAmount  = def.Capacity[(int)payType] / (float)defLast.Capacity[(int)payType];
            }
            else
            {
            }
        }
コード例 #5
0
        void Update()
        {
            // use BETime to revise times
            float deltaTime = BETime.deltaTime;

            // if building is in selected state, keep color animation
            if (!Landed && (goCenter != null))
            {
                float fColor  = Mathf.PingPong(Time.time * 1.5f, 1) * 0.5f + 0.5f;
                Color clrTemp = new Color(fColor, fColor, fColor, 1);
                BEUtil.SetObjectColor(goCenter, clrTemp);
                BEUtil.SetObjectColor(goXInc, clrTemp);
                BEUtil.SetObjectColor(goZInc, clrTemp);
            }

            // if building can produce resources
            if (Landed && !InUpgrade && (def != null) && (def.eProductionType != PayType.None))
            {
                Production += (float)def.ProductionRate * deltaTime;

                // check maximum capacity
                if ((int)Production >= def.Capacity[(int)def.eProductionType])
                {
                    Production = def.Capacity[(int)def.eProductionType];
                }

                // is minimum resources generated, then ser collectable flagand show dialog
                if (((int)Production >= 10) && !uiInfo.groupCollect.gameObject.activeInHierarchy)
                {
                    Collectable = true;
                    uiInfo.CollectIcon.sprite = TBDatabase.GetPayTypeIcon(def.eProductionType);
                    BETween.alpha(uiInfo.groupCollect.gameObject, 0.2f, 0.0f, 1.0f);
                    uiInfo.groupCollect.gameObject.SetActive(true);
                    uiInfo.groupInfo.gameObject.SetActive(false);
                }

                if (Collectable)
                {
                    // when production count is reach to max count, then change dialog color to red
                    uiInfo.CollectDialog.color = (Production == def.Capacity[(int)def.eProductionType]) ? Color.red : Color.white;
                }
            }

            // if in upgrade
            if (InUpgrade)
            {
                // if upgrading proceed
                if (!UpgradeCompleted)
                {
                    // decrease left time
                    UpgradeTimeLeft -= deltaTime;

                    // if upgrading done
                    if (UpgradeTimeLeft < 0.0f)
                    {
                        UpgradeTimeLeft  = 0.0f;
                        UpgradeCompleted = true;

                        // if building is selected, then update command dialog
                        if (UICommand.Visible && (SceneTown.buildingSelected == this))
                        {
                            UICommand.Show(this);
                        }
                    }
                }

                // update ui info
                uiInfo.TimeLeft.text       = UpgradeCompleted ? "Completed!" : BENumber.SecToString(Mathf.CeilToInt(UpgradeTimeLeft));
                uiInfo.Progress.fillAmount = (UpgradeTimeTotal - UpgradeTimeLeft) / UpgradeTimeTotal;
                uiInfo.groupProgress.alpha = 1;
                uiInfo.groupProgress.gameObject.SetActive(true);
            }

            UnitGenUpdate(deltaTime);
        }