Exemplo n.º 1
0
    void Update()
    {
        if (!CommonObjectScript.isGuide)
        {
            #region create customer
            #region bonus customer
            if (isAddCustomer)
            {
                isAddCustomer = false;
                for (int i = 0; i < 15; i++)
                {
                    if (bonusCustomer > 0)
                    {
                        if (CreateCustomer())
                        {
                            bonusCustomer--;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            else if (bonusCustomer > 0)
            {
                countTimeBonusCus += Time.deltaTime;
                if (countTimeBonusCus >= CommonObjectScript.maxTimeOfMission / (bonusCustomer + 1))
                {
                    if (CreateCustomer())
                    {
                        bonusCustomer--;
                        countTimeBonusCus = 0;
                    }
                }
            }
            #endregion
            #region create normal customer
            countTime += Time.deltaTime;
            valpercent = (CommonObjectScript.maxTimeOfMission + common.countTimeOneDay / 24f) / maxTimeOfMission;
            if ((valpercent > 0.8f && countTime >= (4.8f * maxTimeOfMission / (0.15f * maxCustomer))) ||
                (valpercent > 0.6f && valpercent <= 0.8f && countTime >= (4.8f * maxTimeOfMission / (0.2f * maxCustomer))) ||
                (valpercent > 0.4f && valpercent <= 0.6f && countTime >= (4.8f * maxTimeOfMission / (0.3f * maxCustomer))) ||
                (valpercent > 0.05f && valpercent <= 0.4f && countTime >= (24 * 0.35F * maxTimeOfMission / (0.35f * maxCustomer))))
            {
                if (!CreateCustomer())
                {
                    bonusCustomer++;
                }
                countTime = 0;
            }
            #endregion
            #endregion
            #region training
            if (countTimeTraining > 0)
            {
                countTimeTraining -= Time.deltaTime;
                if (countTimeTraining <= 0)
                {
                    Upgrade();
                }
            }
            #endregion
            #region Auto service
            for (int i = 0; i < 3; i++)           //foreach one row
            {
                if (staffDatas[i].typeStaff != 0) //if have staff
                {
                    #region complete fixing
                    if (staffDatas[i].statement.StartsWith("fix_"))
                    {
                        staffDatas[i].countTimeHealing -= Time.deltaTime;
                        if (staffDatas[i].countTimeHealing < 0)
                        {
                            staffDatas[i].countTimeHealing = 3f;
                            staffDatas[i].statement        = "stand";
                            changeStaffs[i] = true;
                            if (textStaff == null)
                            {
                                textStaff = new WarningTextView();
                            }
                            textStaff.RemoveWarning(3);
                        }
                    }
                    #endregion
                    if (cusDatas[i, 0].indexProduct != -1)                                                        //if have customer
                    {
                        if (staffDatas[i].statement.Equals("sell") || staffDatas[i].statement.Equals("training")) //servicing
                        {
                            staffDatas[i].curtimeService += Time.deltaTime;
                            #region complete service
                            if (staffDatas[i].curtimeService >= staffDatas[i].timeService)
                            {
                                staffDatas[i].curtimeService = 0;
                                CommonObjectScript.arrayProducts[cusDatas[i, 0].indexProduct]--;

                                //add to target sell all product
                                MissionData.shopDataMission.listProducts[productDatas[cusDatas[i, 0].indexProduct].index].currentNumber++;
                                MissionData.shopDataMission.currentNumber++;
                                getAchievement(cusDatas[i, 0].indexProduct);

                                //reward star and coin
                                if (isUsingItemWeather && checkBonusFromWeatherItem())
                                {
                                    isCompleteService(i, cusDatas[i, 0].star, priceCakes[cusDatas[i, 0].indexProduct], true);
                                    MissionData.shopDataMission.currentLevel++;  // tăng ::
                                    DialogAchievement.AddDataAchievement(15, 1); // tặng quà khách
                                }
                                else
                                {
                                    isCompleteService(i, cusDatas[i, 0].star, priceCakes[cusDatas[i, 0].indexProduct]);
                                }

                                //check healthy of staff
                                staffDatas[i].countToCheck++;
                                if (staffDatas[i].countToCheck > 3)
                                {
                                    staffDatas[i].countToCheck = 0;
                                }
                                tempState = getStatementAvailable(i);
                                if (!tempState.Equals(staffDatas[i].statement))
                                {
                                    staffDatas[i].statement = tempState;
                                    changeStaffs[i]         = true;
                                    if (VariableSystem.language == null || VariableSystem.language.Equals("Vietnamese"))
                                    {
                                        textStaff = new WarningTextView("Nhân viên gặp vấn đề", 3);
                                    }
                                    else
                                    {
                                        textStaff = new WarningTextView("Staff have problem", 3);
                                    }
                                }
                                else
                                {
                                    #region staff rest when finish service
                                    if (staffDatas[i].statement.Equals("sell"))
                                    {
                                        staffDatas[i].statement = "stand";
                                        changeStaffs[i]         = true;
                                    }
                                    else if (staffDatas[i].statement.Equals("training"))
                                    {
                                        staffDatas[i].statement = "training_stand";
                                        changeStaffs[i]         = true;
                                    }
                                    #endregion
                                }
                            }
                            #endregion
                        }
                        else if (isAvailableService(i) && CommonObjectScript.arrayProducts[cusDatas[i, 0].indexProduct] > 0)//if can service
                        {
                            #region service
                            if (staffDatas[i].statement.Equals("stand"))
                            {
                                staffDatas[i].statement = "sell";
                                changeStaffs[i]         = true;
                            }
                            else if (staffDatas[i].statement.Equals("training_stand"))
                            {
                                staffDatas[i].statement = "training";
                                changeStaffs[i]         = true;
                            }
                            #endregion
                        }
                        #region customer waiting
                        cusDatas[i, 0].timeWait -= Time.deltaTime;
                        if (cusDatas[i, 0].timeWait < 0)
                        {
                            cusDatas[i, 0] = new Customer();
                            isCompleteService(i, 0, 0);//hết kiên nhẫn
                            staffDatas[i].curtimeService = 0;
                        }
                        #endregion
                    }
                }
            }
            #endregion
        }
        else if (VariableSystem.mission == 2)
        {
            if (numberOfStaff == 1 && cusDatas[0, 0].indexProduct == -1)
            {
                CreateCustomer(0);
            }
        }
        if (Application.loadedLevelName.Equals("Mission"))
        {
            bonusCustomer = 0;
            maxCustomer   = 0;
            isAddCustomer = false;
            GameObject.Destroy(this.gameObject);
        }
        else if (isNeedWarning && !Application.loadedLevelName.Equals("Store"))
        {
            common.WarningVisible(CommonObjectScript.Button.Shop);
            isNeedWarning = false;
        }
    }
Exemplo n.º 2
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            AudioControl.DPlaySound("Click 1");
            if (dialogSetting.gameObject.GetComponent <DialogSetting>().Show ||
                dialogMessage.gameObject.GetComponent <DialogMessage>().Show || dialogSelectFriend.gameObject.GetComponent <DialogSelectFriend>().Show ||
                dialogLogin.GetComponent <DialogLogin>().Show || dialogAchievement.GetComponent <DialogAchievement>().Show || dialogRefill.GetComponent <DialogRefill>().Show ||
                dialogInapp.GetComponent <DialogInapp>().Show || dialogInfo.GetComponent <DialogInfo>().Show || CommonObjectScript.isViewPoppup ||
                dialogDailyGift.GetComponent <DialogDailyGift>().Show || dialogSpecialGift.GetComponent <DialogSpecialGift>().Show || dialogEvent.GetComponent <DialogEventFriend>().Show)
            {
                dialogSpecialGift.GetComponent <DialogSpecialGift>().HideDialog();
                dialogSetting.gameObject.GetComponent <DialogSetting>().HideDialogSetting();
                dialogMessage.gameObject.GetComponent <DialogMessage>().HideDialog();
                dialogSelectFriend.gameObject.GetComponent <DialogSelectFriend>().CloseButton();
                dialogAchievement.GetComponent <DialogAchievement>().HideDialog();
                HideLoginDialog();
                dialogRefill.GetComponent <DialogRefill>().HideDialog();
                dialogInapp.GetComponent <DialogInapp>().HideDialog();
                dialogInfo.GetComponent <DialogInfo>().HideDialog();
                dialogDailyGift.GetComponent <DialogDailyGift>().HideDialog();
                dialogEvent.GetComponent <DialogEventFriend>().HideDialog();
            }
            else if (dialogMission.gameObject.GetComponent <DialogMission>().Show)
            {
                Transform dialogShop = transform.FindChild("Dialog").FindChild("DialogShop");
                if (dialogShop.GetComponent <DialogShop>().Show)
                {
                    dialogShop.GetComponent <DialogShop>().HideDialog();
                }
                else
                {
                    dialogMission.gameObject.GetComponent <DialogMission>().HideDialogMission();
                }
            }
            else
            {
                //Application.LoadLevel("Menu");
                LoadingScene.ShowLoadingScene("Menu", true);
            }
        }
        if (Input.GetKeyDown(KeyCode.Space))
        {
            //MissionData.targetCommon.current += 10;
        }
        if (Input.GetKeyDown(KeyCode.F))
        {
            dialogDailyGift.GetComponent <DialogDailyGift>().ShowDialog();
        }

        //Thoi gian nhan tim
        if (VariableSystem.heart >= 5)
        {
            VariableSystem.heart = 5;
            lbTimeLife.text      = "FULL";
        }
        else
        {
            // Debug.Log("-------------" + timeaddheart + " AudioControl.time_add_heart " + AudioControl.time_add_heart + " DString.GetTimeNow() " + DString.GetTimeNow());
            int totalTime = (int)(DString.GetTimeNow() - AudioControl.time_add_heart);

            if (totalTime > 0)
            {
                //Debug.Log("----------------Thoi gian tu luc thieu tim---------------" + totalTime);
                int tim_cong_them_thua_thoi_gian = (int)(totalTime / AudioControl.max_time_receive_heat);
                int heart_add = tim_cong_them_thua_thoi_gian + 1;
                if (heart_add > 5 - VariableSystem.heart)
                {
                    heart_add = 5 - VariableSystem.heart;
                }
                Debug.Log("---------------------CONG TIM----------------------" + heart_add);
                //VariableSystem.heart += heart_add;
                AudioControl.AddHeart(heart_add);

                //Tru bu thoi gian va hien thi
                int thoi_gian_con_du   = (int)totalTime % AudioControl.max_time_receive_heat;//So du chua du 10phut de nhan them tim. so du nay > 0 va < 600
                int thoi_gian_hien_thi = AudioControl.max_time_receive_heat - thoi_gian_con_du;
                lbTimeLife.text = DString.ConvertSecondsToMinute(thoi_gian_hien_thi);

                //Luu lai thoi gian cong tim tiep
                if (VariableSystem.heart < 5)
                {
                    Debug.Log("---------------------Luu thoi gian cong tim tiep----------------------");
                    AudioControl.time_add_heart = (DString.GetTimeNow() + AudioControl.max_time_receive_heat);
                    PlayerPrefs.SetString(AudioControl.key_time_add_heart, "" + AudioControl.time_add_heart);
                }
            }
            else
            {
                int thoi_gian_hien_thi = Math.Abs(totalTime);
                lbTimeLife.text = DString.ConvertSecondsToMinute(thoi_gian_hien_thi);
            }
        }
        if (VariableSystem.heart < 0)
        {
            VariableSystem.heart = 0;
        }
        lbLife.text    = "" + VariableSystem.heart;
        lbDiamond.text = "" + VariableSystem.diamond;

        if (FB.IsInitialized)
        {
            if (FB.IsLoggedIn)
            {
                time_count_message += Time.deltaTime;
                if (time_count_message > 30)
                {
                    time_count_message = 0;
                    CountMessage();
                    Debug.Log("Count Message");
                }
            }
            if (!showLogin)
            {
                showLogin = true;
                if (FB.IsLoggedIn)
                {
                    HideLoginDialog();
                    CountMessage();
                    loginButton.gameObject.SetActive(false);
                    transform.FindChild("Button").FindChild("ButtonShowMessage").gameObject.SetActive(true);
                    //     transform.FindChild("Button").FindChild("ButtonInviteFriend").gameObject.SetActive(true);
                    //     transform.FindChild("Button").FindChild("ButtonHelpFriend").gameObject.SetActive(true);
                }
                else
                {
                    loginButton.gameObject.SetActive(true);
                    if (!dialogLoading.gameObject.activeInHierarchy)
                    {
                        if (countShowDialogLogin > 5 && !showDialogTryAgain)
                        {
                            ShowLoginDialog();
                        }
                    }
                }
            }
        }

        //Show try again
        if (showDialogTryAgain)
        {
            Debug.Log("SHOW TRY AGAIN");
            showDialogTryAgain = false;
            Transform dialogTask = GameObject.Find("DialogTask").transform;
            dialogTask.GetComponent <DialogTask>().RemoveAllItem();
            Debug.Log("READ LEVEL TRY AGAIN" + VariableSystem.mission);
            MissionData.READ_XML(VariableSystem.mission);
            dialogMission.GetComponent <DialogMission>().ShowDialogMision(VariableSystem.mission);
            //--------------------ACHIEVEMENT 3-------------------------
            DialogAchievement.AddDataAchievement(3, 1);
        }
    }
Exemplo n.º 3
0
    void EndEvenAnimation()
    {
        CommonObjectScript.isViewPoppup = false;
        if (!isCloseClick)
        {
            if (commonObject.transform.FindChild("Btn_Result").gameObject.activeInHierarchy)
            {
                panelCofirmApply.gameObject.SetActive(true);
                panelCofirmApply.GetComponent <Animator>().Play("Visible");
            }
            else
            {
                // print("tiennnnnnnnnnnnnnnnnnnn  " + TownScenesController.ListMaketResearchItem[idButtonItem].costCoin);
                //if (!isApply)
                {
                    if (idButton == 2)
                    {
                        commonObject.GetComponent <CommonObjectScript>().ResultButtonVisible();
                        commonObject.GetComponent <CommonObjectScript>().typeReasearch = 1;

                        //Application.LoadLevel("VilageResearch");
                        VilageResearchController.ResetVilage();
                        LoadingScene.ShowLoadingScene("VilageResearch", true);
                        DialogAchievement.AddDataAchievement(12, 1);
                    }
                    else if (idButton == 3)
                    {
                        maketPopup.gameObject.SetActive(true);
                    }
                    else
                    {
                        if (CommonObjectScript.dollar >= TownScenesController.ListMaketResearchItem[idButtonItem].costCoin && VariableSystem.diamond >= TownScenesController.ListMaketResearchItem[idButtonItem].costDiamond)
                        {
                            TownScenesController.townsBusy[3] = true;
                            if (idButtonItem > 4)
                            {
                                CreateTimer(TownScenesController.ListMaketResearchItem[idButtonItem].time);
                                DialogAchievement.AddDataAchievement(13, 1);
                            }
                            else
                            {
                                CreateTimer(0);
                                DialogAchievement.AddDataAchievement(14, 1);
                            }
                            AddCommonObject(-TownScenesController.ListMaketResearchItem[idButtonItem].costCoin, -TownScenesController.ListMaketResearchItem[idButtonItem].costDiamond);
                            VilageResearchController.ResetVilage();
                        }
                        else
                        {
                            if (TownScenesController.ListMaketResearchItem[idButtonItem].costCoin != 0)
                            {
                                GameObject.Find("CommonObject").GetComponent <CommonObjectScript>().ChangeDolar(TownScenesController.ListMaketResearchItem[idButtonItem].costCoin - CommonObjectScript.dollar);
                            }
                            else
                            {
                                DialogInapp.ShowInapp();
                            }
                        }
                        CreatTownScenesController.isDenyContinue = false;
                    }
                    //isApply = true;
                }
                this.gameObject.SetActive(false);
            }
        }
        else
        {
            this.gameObject.SetActive(false);
            CreatTownScenesController.isDenyContinue = false;
        }
    }