Exemple #1
0
    void Update()
    {
        if (isChangedDollar)
        {
            labelsInCommon[2].text = DString.ConvertToMoneyString(dollar.ToString());
            isChangedDollar        = false;
        }
        if (VariableSystem.isNeedUpdateValueDiamond)
        {
            labelsInCommon[3].text = DString.ConvertToMoneyString(VariableSystem.diamond.ToString());
            VariableSystem.isNeedUpdateValueDiamond = false;
        }

        if (isLeavedFarm && !Application.loadedLevelName.Equals("Farm"))//restore position of commonObject
        {
            transform.localPosition = Vector3.zero;
            isLeavedFarm            = false;
            if (FarmCenterScript.isNeedWarning)
            {
                WarningVisible(CommonObjectScript.Button.Farm);
            }
        }

        //auto time
        if (!(isOpennew || isGuide || maxTimeOfMission <= 0))
        {
            countTimeOneDay    += Time.deltaTime;
            clockBar.fillAmount = 1 - countTimeOneDay / 24;
            if (countTimeOneDay >= 24)
            {
                Nextday();
                weatherDay             = getNextDay();
                iconWeather.spriteName = weatherDay;
                countTimeOneDay        = 0;
                if (weatherDay.Equals("nang") || weatherDay.Equals("mua") || weatherDay.Equals("tuyet"))
                {
                    IconWeatherController.setScale(true);
                }
                else
                {
                    IconWeatherController.setScale(false);
                }
            }
            if (maxTimeOfMission == 1 && countTimeOneDay >= 14 && !isPlayHetGio)
            {
                audioControl.PlaySound("Het gio");
                isPlayHetGio = true;
            }
        }

        #region auto effect storage, coin, star
        if (storageActiveTime > 0)
        {
            storageActiveTime--;
            if (btnStorage.width > 118)
            {
                btnStorage.width  -= 2;
                btnStorage.height -= 2;
            }
        }
        if (starActiveTime > 0)
        {
            starActiveTime--;
            if (starIcon.width > 62)
            {
                starIcon.width  -= 1;
                starIcon.height -= 1;
            }
        }
        if (coinActiveTime > 0)
        {
            coinActiveTime--;
            if (coinIcon.width > 62)
            {
                coinIcon.width  -= 1;
                coinIcon.height -= 1;
            }
        }
        #endregion

        // Back Button
        BackButton();
    }
Exemple #2
0
    void Start()
    {
        #region lấy các liên kết
        dialogTask     = GameObject.Find("DialogTask").GetComponent <DialogTask>();
        newItemPrefabs = (GameObject)Resources.Load("Common/PanelNewItem");
        btnStorage     = transform.FindChild("Btn_Storage").GetComponent <UITexture>();
        starIcon       = transform.FindChild("FrameObject").FindChild("Fr_star").FindChild("icon_star").GetComponent <UITexture>();
        coinIcon       = transform.FindChild("FrameObject").FindChild("Fr_dollar").FindChild("icon_dollar").GetComponent <UITexture>();
        labelsInCommon = transform.FindChild("FrameObject").GetComponentsInChildren <UILabel>();
        clockBar       = transform.FindChild("FrameObject").FindChild("Fr_days").FindChild("thanh_clock").GetComponent <UITexture>();
        starBar        = transform.FindChild("FrameObject").FindChild("Fr_star").FindChild("thanh_star").GetComponent <UITexture>();
        iconWeather    = transform.FindChild("FrameObject").FindChild("Fr_weather").FindChild("icon_weather").GetComponent <UISprite>();
        print(weatherDay);
        iconWeather.spriteName = weatherDay;
        if (weatherDay.Equals("nang") || weatherDay.Equals("mua") || weatherDay.Equals("tuyet"))
        {
            IconWeatherController.setScale(true);
        }
        else
        {
            IconWeatherController.setScale(false);
        }
        spriteProducts  = Resources.LoadAll("Factory/Button/Images/Product");
        spriteMaterials = Resources.LoadAll("Factory/Button/Images/Material");
        #endregion

        #region timeSystem,star
        idDay = 1;
        if (isGuide && VariableSystem.mission == 7)
        {
            idDay = 7;
            //LotteryController.countSpin = 0;
        }
        maxTimeOfMission = MissionData.targetCommon.maxTime;
        if (MissionPowerUp.MoreTime)
        {
            if (maxTimeOfMission % 2 == 0)
            {
                maxTimeOfMission *= 1.5f;
            }
            else
            {
                maxTimeOfMission = maxTimeOfMission * 1.5f + 0.5f;
            }
        }
        targetStar             = MissionData.targetCommon.targetCustomerRate;
        labelsInCommon[0].text = getNameDay(idDay);

        if (VariableSystem.language.Equals("Vietnamese"))
        {
            labelsInCommon[1].text = "Còn lại " + maxTimeOfMission.ToString() + " ngày!";
        }
        else
        {
            labelsInCommon[1].text = (maxTimeOfMission == 1 ? "1 Day " : maxTimeOfMission.ToString() + " Days ") + "to go!";
        }
        currentStar        = 0;
        starBar.fillAmount = 0;
        #endregion

        #region moneySystem,diamond,new items
        dollar = MissionData.targetCommon.startMoney;
        if (MissionData.itemsInNew.Count > 0)
        {
            CallNewItem();
        }
        labelsInCommon[2].text = DString.ConvertToMoneyString(dollar.ToString());
        labelsInCommon[3].text = DString.ConvertToMoneyString(VariableSystem.diamond.ToString());
        #endregion
        CheckItemPowerUp();
        audioControl.PlayMusicInstance("Nhac nen " + (UnityEngine.Random.Range(0, 1250) % 2 + 1).ToString(), true, true, 0.23f);
        if (targetStar == 0)
        {
            targetStar = getMaxCustomer((int)maxTimeOfMission) * 4;
        }
        isPlayHetGio = false;

        //for (int i = 5; i < 36; i++)  getMaxCustomer(i);
    }