Ejemplo n.º 1
0
 void SetStatusMachine()
 {
     if (!isFail)
     {
         if (IDProductQueue != null)
         {
             if (IDProductQueue.Count > 0)
             {
                 if (animator != null)
                 {
                     animator.Play("may" + (levelMachine) + "_working");
                 }
                 if (Application.loadedLevelName.Equals("Factory"))
                 {
                     if (timeCountSound < timeRandomSound)
                     {
                         timeCountSound += Time.deltaTime;
                     }
                     else
                     {
                         RandomSound(30, "May moc chay");
                         timeCountSound = 0;
                     }
                 }
             }
             else
             {
                 if (animator != null)
                 {
                     animator.Play("may" + (levelMachine) + "_idle");
                 }
             }
         }
     }
     else
     {
         if (!Application.loadedLevelName.Equals("Factory") && commonObject != null && !isRePairting)
         {
             commonObject.GetComponent <CommonObjectScript>().WarningVisible(CommonObjectScript.Button.Factory);
         }
         if (animator != null)
         {
             animator.Play("may" + (levelMachine) + "_i");
         }
         if (timeCountWarning >= timeCheckWarning)
         {
             warningFail      = new WarningTextView(FactoryScenesController.languageHungBV["MACHINEFAIL"], 4);
             timeCountWarning = 0;
         }
         else
         {
             timeCountWarning += Time.deltaTime;
         }
     }
 }
Ejemplo n.º 2
0
    public IEnumerator GrowUp(int indexPopup)
    {
        yield return(new WaitForSeconds(0.5f));

        if (listDatas[indexPopup].idBreed != 0)
        {
            GameObject.FindGameObjectWithTag("CommonObject").GetComponent <CommonObjectScript>().AddDiamond(0);//update diamond
            listDatas[indexPopup].timeGrowUp = listDatas[indexPopup].maxtimeGrowUp;
            listDatas[indexPopup].stage      = 3;
            listDatas[indexPopup].status     = "normal";
            if (DialogShop.BoughtItem[7])//auto harvest
            {
                if (Application.loadedLevelName.Equals("Farm"))
                {
                    idNeedUpdate = indexPopup;
                }
                else
                {
                    //auto increase yeild
                    CommonObjectScript.arrayMaterials[listDatas[indexPopup].idBreed - 1] += listDatas[indexPopup].Yield;

                    MissionData.farmDataMission.breedsFarm[breedFarms[listDatas[indexPopup].idBreed - 1].index].currentNumber++;
                    if (listDatas[indexPopup].idBreed < 5)
                    {
                        MissionData.farmDataMission.harvestField.currentNumber++;
                    }
                    else
                    {
                        MissionData.farmDataMission.harvestCage.currentNumber++;
                    }
                    listDatas[indexPopup] = new Breed();
                }
            }
            else
            {
                if (!Application.loadedLevelName.Equals("Farm"))
                {
                    common.WarningVisible(CommonObjectScript.Button.Farm);
                }
                if (VariableSystem.language == null || VariableSystem.language.Equals("Vietnamese"))
                {
                    textHarvest = new WarningTextView("Thu hoạch ở nông trại !", 8);
                }
                else
                {
                    textHarvest = new WarningTextView("Harvest farm !", 8);
                }
                idNeedUpdate = indexPopup;
            }
        }
    }
Ejemplo n.º 3
0
 // Update is called once per frame
 void Update()
 {
     if (countTimerePair < timeRePair)
     {
         countTimerePair += Time.deltaTime;
     }
     else
     {
         transform.parent.GetComponent <MachineController>().isFail       = false;
         transform.parent.GetComponent <MachineController>().isRePairting = false;
         if (transform.parent.GetComponent <MachineController>().warningFail != null)
         {
             transform.parent.GetComponent <MachineController>().warningFail.RemoveWarning(4);
         }
         else
         {
             WarningTextView warningFail = new WarningTextView();
             warningFail.RemoveWarning(4);
         }
         Destroy(gameObject);
     }
 }
Ejemplo n.º 4
0
 void RandomFail()
 {
     if (!DialogShop.BoughtItem[11])
     {
         //print("vao day");
         if (MissionData.factoryDataMission.positionUnlock.isCanBreak)
         {
             if (!isFail)
             {
                 if (countTimeCheck >= timeCheck)
                 {
                     int result = Random.Range(0, 10000) % 99;
                     print(result + "_" + rationFail);
                     if (result <= rationFail)
                     {
                         isFail = true;
                         CreatIconFail();
                         countTimeCheck = 0;
                         // timeCheck = Random.Range(10000, 20000) / 1000;
                         timeCheck   = 20;
                         warningFail = new WarningTextView(FactoryScenesController.languageHungBV["MACHINEFAIL"], 4);
                     }
                     else
                     {
                         //timeCheck = Random.Range(10000, 20000) / 1000;
                         // print("timeCheck " + timeCheck );
                         timeCheck      = 20;
                         countTimeCheck = 0;
                     }
                 }
                 else if (countTimeCheck < timeCheck)
                 {
                     countTimeCheck += Time.deltaTime;
                 }
                 // print(countTimeCheck);
             }
         }
     }
 }
Ejemplo n.º 5
0
    void CheckStatusLackOfMaterial()
    {
        bool isDenyCreatWarningLack = false;

        if (timeCountWarninglack >= timeCheckWarningLack)
        {
            foreach (int ID in listIDMaterialOfMachine)
            {
                if (CommonObjectScript.arrayMaterials[ID - 1] <= 0)
                {
                    isDenyCreatWarningLack = true;
                    break;
                }
            }
            if (isDenyCreatWarningLack)
            {
                warningLackOfProduct = new WarningTextView(FactoryScenesController.languageHungBV["LACKOFMATERIAL"], 7);
            }
            else
            {
                if (warningLackOfProduct != null)
                {
                    warningLackOfProduct.RemoveWarning(7);
                }
                else
                {
                    WarningTextView warningLackOfProductTemp = new WarningTextView();
                    warningLackOfProductTemp.RemoveWarning(7);
                }
            }
            timeCountWarninglack = 0;
        }
        else
        {
            timeCountWarninglack += Time.deltaTime;
        }
    }
Ejemplo n.º 6
0
 public void randSick(int index)
 {
     if (isCansick)
     {
         randValue = Random.Range(0, 1250) % 100;
         if (randValue < 7)
         {
             listDatas[index].status = "sick";
             if (!Application.loadedLevelName.Equals("Farm"))
             {
                 common.WarningVisible(CommonObjectScript.Button.Farm);
             }
             if (VariableSystem.language == null || VariableSystem.language.Equals("Vietnamese"))
             {
                 textHarvest = new WarningTextView("Dịch bệnh ở nông trại !", 5);
             }
             else
             {
                 textHarvest = new WarningTextView("Disease in farm !", 5);
             }
             idNeedUpdate = index;
         }
     }
 }
Ejemplo n.º 7
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;
        }
    }
Ejemplo n.º 8
0
    void Start()
    {
        elementPlantDataXML = new ReadXML("Farm/XMLFile/ElementFarm");
        common    = GameObject.FindGameObjectWithTag("CommonObject").GetComponent <CommonObjectScript>();
        isCansick = true;
        bool isWarning = false;

        idBreedsSorted = new List <int>();
        #region read data in mission
        countElementField = 0; countElementCage1 = 0; countElementCage2 = 0;
        tempField         = 0; tempCage1 = 0; tempCage2 = 0;
        isCansick         = MissionData.farmDataMission.isCanSick;
        foreach (FieldFarm fieldFarm in MissionData.farmDataMission.fieldFarms)
        {
            fieldFarms[fieldFarm.idField - 1].startNumber   = fieldFarm.startNumber;
            fieldFarms[fieldFarm.idField - 1].targetNumber  = fieldFarm.targetNumber;
            fieldFarms[fieldFarm.idField - 1].startLevel    = fieldFarm.startLevel;
            fieldFarms[fieldFarm.idField - 1].targetLevel   = fieldFarm.targetLevel;
            fieldFarms[fieldFarm.idField - 1].maxLevel      = fieldFarm.maxLevel;
            fieldFarms[fieldFarm.idField - 1].currentNumber = fieldFarm.currentNumber;
            fieldFarms[fieldFarm.idField - 1].currentLevel  = fieldFarm.currentLevel;
        }
        #region đặt trước cây để làm guide
        if (VariableSystem.mission == 4)
        {
            listDatas[tempField] = new Breed(MissionData.farmDataMission.breedsFarm[0].idBreed, fieldFarms[0].currentLevel, elementPlantDataXML.getDataByValue("id", MissionData.farmDataMission.breedsFarm[0].idBreed.ToString()), false, false);
            tempField++;
        }
        if (VariableSystem.mission == 38)
        {
            listDatas[tempField] = new Breed(MissionData.farmDataMission.breedsFarm[0].idBreed, fieldFarms[0].currentLevel, elementPlantDataXML.getDataByValue("id", MissionData.farmDataMission.breedsFarm[0].idBreed.ToString()), true, false);
            tempField++;
        }
        #endregion
        foreach (BreedFarm breedFarm in MissionData.farmDataMission.breedsFarm)
        {
            idBreedsSorted.Add(breedFarm.idBreed);
            if (breedFarm.idBreed < 5)
            {
                countElementField++;
                if (breedFarm.startNumber != 0)
                {
                    for (int i = 0; i < breedFarm.startNumber; i++)
                    {
                        listDatas[tempField + i] = new Breed(breedFarm.idBreed, fieldFarms[0].currentLevel, elementPlantDataXML.getDataByValue("id", breedFarm.idBreed.ToString()));
                    }
                    tempField += breedFarm.startNumber;
                    isWarning  = true;
                }
            }
            else if (breedFarm.idBreed < 8)
            {
                countElementCage1++;
                if (breedFarm.startNumber != 0)
                {
                    for (int i = 0; i < breedFarm.startNumber; i++)
                    {
                        listDatas[tempCage1 + i + 12] = new Breed(breedFarm.idBreed, fieldFarms[1].currentLevel, elementPlantDataXML.getDataByValue("id", breedFarm.idBreed.ToString()));
                    }
                    tempCage1 += breedFarm.startNumber;
                    isWarning  = true;
                }
            }
            else
            {
                countElementCage2++;
                if (breedFarm.startNumber != 0)
                {
                    for (int i = 0; i < breedFarm.startNumber; i++)
                    {
                        listDatas[tempCage2 + i + 18] = new Breed(breedFarm.idBreed, fieldFarms[2].currentLevel, elementPlantDataXML.getDataByValue("id", breedFarm.idBreed.ToString()));
                    }
                    tempCage2 += breedFarm.startNumber;
                    isWarning  = true;
                }
            }
            breedFarms[breedFarm.idBreed - 1] = breedFarm;
        }
        #endregion
        idBreedsSorted.Sort();
        // print(isWarning.ToString());
        if (isWarning)
        {
            if (MissionData.targetCommon.startScene != 1)
            {
                common.WarningVisible(CommonObjectScript.Button.Farm);
            }

            if (VariableSystem.language == null || VariableSystem.language.Equals("Vietnamese"))
            {
                textHarvest = new WarningTextView("Thu hoạch ở nông trại !", 8);
            }
            else
            {
                textHarvest = new WarningTextView("Harvest farm !", 8);
            }
        }

        #region IsOpenCells
        for (int i = 0; i < 22; i++)
        {
            isOpenCells[i] = false;
            if (i < 12)
            {
                if (i < fieldFarms[0].startNumber)
                {
                    isOpenCells[i] = true;
                }
            }
            else if (i < 18)
            {
                if (i - 12 < fieldFarms[1].startNumber)
                {
                    isOpenCells[i] = true;
                }
            }
            else
            {
                if (i - 18 < fieldFarms[2].startNumber)
                {
                    isOpenCells[i] = true;
                }
            }
        }
        #endregion


        //Code of HungBV
        SetListMachineHaved();

        if (DialogShop.BoughtItem[10])
        {
            isCansick = false;
        }
    }
Ejemplo n.º 9
0
 // Update is called once per frame
 void Update()
 {
     if (!(CommonObjectScript.isEndGame || CommonObjectScript.isGuide))
     {
         foreach (FieldFarm fieldFarm in MissionData.farmDataMission.fieldFarms)
         {
             fieldFarms[fieldFarm.idField - 1].currentNumber = fieldFarm.currentNumber;
             //print(fieldFarms[fieldFarm.idField - 1].currentLevel + " so với " + fieldFarm.currentLevel);
             if (fieldFarms[fieldFarm.idField - 1].currentLevel != fieldFarm.currentLevel)
             {
                 #region upgrade Level Farm
                 fieldFarms[fieldFarm.idField - 1].currentLevel = fieldFarm.currentLevel;
                 idNeedUpdate = 1;
                 if (fieldFarm.idField == 1)
                 {
                     for (int i = 0; i < 12; i++)
                     {
                         if (isOpenCells[i] && listDatas[i].idBreed > 0)
                         {
                             listDatas[i].Yield += 2;
                         }
                     }
                 }
                 else if (fieldFarm.idField == 2)
                 {
                     for (int i = 12; i < 18; i++)
                     {
                         if (isOpenCells[i] && listDatas[i].idBreed > 0)
                         {
                             listDatas[i].Yield += 2;
                         }
                     }
                 }
                 else
                 {
                     for (int i = 18; i < 22; i++)
                     {
                         if (isOpenCells[i] && listDatas[i].idBreed > 0)
                         {
                             listDatas[i].Yield += 2;
                         }
                     }
                 }
                 #endregion
             }
         }
         isNeedWarning = false;
         for (int i = 0; i < 22; i++)
         {
             if (isOpenCells[i])
             {
                 if (listDatas[i].status.Equals("sick_fix"))
                 {
                     #region healing
                     listDatas[i].timeHealing -= Time.deltaTime;
                     if (listDatas[i].timeHealing < 0)
                     {
                         listDatas[i].timeHealing = 5f;
                         listDatas[i].status      = "normal";
                         idNeedUpdate             = i;
                     }
                     #endregion
                 }
                 else if (listDatas[i].idBreed != 0)
                 {
                     if (listDatas[i].stage == 3 || listDatas[i].status.Equals("sick"))
                     {
                         isNeedWarning = true;
                     }
                     else
                     {
                         #region grow up
                         listDatas[i].timeGrowUp += Time.deltaTime;
                         if (Mathf.Abs(listDatas[i].maxtimeGrowUp / 4 - listDatas[i].timeGrowUp) <= Time.deltaTime / 2)
                         {
                             randSick(i);
                         }
                         else if (Mathf.Abs(listDatas[i].maxtimeGrowUp * 3 / 4 - listDatas[i].timeGrowUp) <= Time.deltaTime / 2)
                         {
                             randSick(i);
                         }
                         else if (listDatas[i].timeGrowUp >= listDatas[i].maxtimeGrowUp)
                         {
                             listDatas[i].stage = 3;
                             if (DialogShop.BoughtItem[7])//auto harvest
                             {
                                 if (Application.loadedLevelName.Equals("Farm"))
                                 {
                                     idNeedUpdate = i;
                                 }
                                 else
                                 {
                                     //auto increase yeild
                                     CommonObjectScript.arrayMaterials[listDatas[i].idBreed - 1] += listDatas[i].Yield;
                                     MissionData.farmDataMission.breedsFarm[breedFarms[listDatas[i].idBreed - 1].index].currentNumber++;
                                     if (listDatas[i].idBreed < 5)
                                     {
                                         MissionData.farmDataMission.harvestField.currentNumber++;
                                     }
                                     else
                                     {
                                         MissionData.farmDataMission.harvestCage.currentNumber++;
                                     }
                                     listDatas[i] = new Breed();
                                 }
                             }
                             else
                             {
                                 idNeedUpdate = i;
                                 if (!Application.loadedLevelName.Equals("Farm"))
                                 {
                                     common.WarningVisible(CommonObjectScript.Button.Farm);
                                 }
                                 if (VariableSystem.language == null || VariableSystem.language.Equals("Vietnamese"))
                                 {
                                     textHarvest = new WarningTextView("Thu hoạch ở nông trại !", 8);
                                 }
                                 else
                                 {
                                     textHarvest = new WarningTextView("Harvest farm !", 8);
                                 }
                             }
                         }
                         else if (listDatas[i].timeGrowUp / listDatas[i].maxtimeGrowUp >= 0.5 && listDatas[i].stage == 1)
                         {
                             listDatas[i].stage = 2;
                             randSick(i);
                             idNeedUpdate = i;
                         }
                         #endregion
                     }
                 }
             }
         }
     }
     if (Application.loadedLevelName.Equals("Mission"))//mission complete
     {
         GameObject.Destroy(this.gameObject);
     }
 }