public void SendHelpButton() { string mUserIds = ""; List <Transform> arrItem = gridView.gameObject.GetComponent <UIGrid>().GetChildList(); for (int i = 0; i < arrItem.Count; i++) { if (arrItem[i].FindChild("Checkbox").gameObject.GetComponent <UIToggle>().value) { mUserIds += arrItem[i].gameObject.GetComponent <ItemSelectFriend>().UserId + ","; } } DFB.FBSendLife(mUserIds.Split(','), result => { int leng = mUserIds.Split(',').Length; if (!String.IsNullOrEmpty(result.Error)) { Debug.Log(result.Error); } else { Debug.Log(result.Text); var dict = Json.Deserialize(result.Text) as IDictionary; if (dict != null && dict["request"] != null) { //--------------Achievement 1------------------------------------ DialogAchievement.AddDataAchievement(1, leng - 1); CloseButton(); } } }); }
public void SendInviteFriend() { string mUserIds = ""; List <Transform> arrItem = gridView.gameObject.GetComponent <UIGrid>().GetChildList(); for (int i = 0; i < arrItem.Count; i++) { if (arrItem[i].FindChild("Checkbox").gameObject.GetComponent <UIToggle>().value) { if (mUserIds.Length < 1) { mUserIds += arrItem[i].gameObject.GetComponent <ItemSelectFriend>().UserId; } else { mUserIds += "," + arrItem[i].gameObject.GetComponent <ItemSelectFriend>().UserId; } } } Debug.Log(" Count FRIEND --- " + mUserIds.Length); DFB.FBRequestDirect(mUserIds.Split(','), "Invite Your Friends", "Play this game with me!", (result) => { int leng = mUserIds.Split(',').Length; Debug.Log(result.Text); var dict = Json.Deserialize(result.Text) as IDictionary; if (dict != null && dict["request"] != null) { //--------------Achievement 22------------------------------------ DialogAchievement.AddDataAchievement(22, leng); CloseButton(); } }); }
public void AddStar(int star) { if (currentStar < targetStar) { currentStar += star; if (currentStar >= targetStar) { rewardCustomerRate = 2; } else if (currentStar * 1f / targetStar >= 0.8f) { rewardCustomerRate = 1; } else { rewardCustomerRate = 0; } } else { currentStar += star; } if (currentStar >= targetStar) { starBar.fillAmount = 1; } else { starBar.fillAmount = (currentStar * 1f) / targetStar; } MissionData.targetCommon.currentLevel += star; DialogAchievement.AddDataAchievement(20, star); }
public void SpinWheelLuck() // button Spin Click Event { this.gameObject.GetComponent <Animator>().enabled = false; if (isAgain) { if (!isSpinning) { audioControl.PlaySound("Quay xo so"); isSpinning = true; isLight = true; float zChange = Random.Range(-4150, -2000); LeanTween.rotateZ(wheelLuck, zChange, 5).setEase(LeanTweenType.easeInOutQuad).setOnComplete(delegate() { isCompleteSpin = true; isLight = false; }); SetStatusButtonSpin(false); DialogAchievement.AddDataAchievement(6, 1); MissionData.townDataMission.currentNumber += 1; } isAgain = false; } else { if (!isSpinning) { if (VariableSystem.diamond >= countSpin) { audioControl.PlaySound("Quay xo so"); isSpinning = true; isLight = true; float zChange = Random.Range(-4150, -2000); LeanTween.rotateZ(wheelLuck, zChange, 5).setEase(LeanTweenType.easeInOutQuad).setOnComplete(delegate() { isCompleteSpin = true; isLight = false; }); AddCommonObject(0, -countSpin); countSpin++; SetStatusButtonSpin(false); DialogAchievement.AddDataAchievement(6, 1); MissionData.townDataMission.currentNumber += 1; } else { audioControl.PlaySound("Click 1"); DialogInapp.ShowInapp(); } } } // SaveCountSpin(); }
public void Nextday()//next day { maxTimeOfMission--; if (maxTimeOfMission == 0) { if (VariableSystem.language.Equals("Vietnamese")) { labelsInCommon[1].text = "Hết giờ"; } else { labelsInCommon[1].text = "Time out"; } setActiveButton(false, false, false, false, false, false, false, false); DialogResult.ShowResult(); } else { 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!"; } if (maxTimeOfMission > 0 && maxTimeOfMission < 7) { labelsInCommon[1].color = new Color32(255, 0, 0, 255); } } idDay++; //Hungbv - Bắt đầu vào ngày chủ nhật - Chỉ chạy 1 lần if (idDay == 7) { LotteryController.countSpin = 0; // LotteryController.SaveCountSpin(); } if (idDay == 8) { idDay = 1; labelsInCommon[0].color = new Color32(255, 255, 0, 255); } else if (idDay == 7) { labelsInCommon[0].color = new Color32(255, 0, 0, 255); } labelsInCommon[0].text = getNameDay(idDay); DialogAchievement.AddDataAchievement(21, 1); // time of người chơi đã qua }
public static void AddDiamond(int value) { if (diamond + value < 0) { Debug.LogError("Trừ nhiều tiền quá, không chấp nhận được. Cần check lại ngay !!!!"); return; } diamond += value; isNeedUpdateValueDiamond = true; if (value < 0) { DialogAchievement.AddDataAchievement(4, 1); DialogAchievement.AddDataAchievement(5, -value); } PlayerPrefs.SetInt("diamond", diamond); }
public void OKComfirm_ClickComfirm() { audioControl.PlaySound("Click 1"); iDButtonComfirmApply = 1; panelCofirmApply.GetComponent <Animator>().Play("InVisible"); if (!isApply) { if (idButton == 0 || idButton == 1) { 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 { // print(TownScenesController.ListMaketResearchItem[idButtonItem].costCoin + "aaaaaaaaaaaaaa"); if (TownScenesController.ListMaketResearchItem[idButtonItem].costCoin != 0) { GameObject.Find("CommonObject").GetComponent <CommonObjectScript>().ChangeDolar(TownScenesController.ListMaketResearchItem[idButtonItem].costCoin - CommonObjectScript.dollar); } else { DialogInapp.ShowInapp(); } } } isApply = true; } }
void getAchievement(int index) { DialogAchievement.AddDataAchievement(11, 1); // phục vụ khách hàng switch (index) { case 0: DialogAchievement.AddDataAchievement(7, 1); break; //bánh mì case 5: DialogAchievement.AddDataAchievement(16, 1); break; //cá nướng case 6: DialogAchievement.AddDataAchievement(10, 1); break; //đùi gà quay case 7: DialogAchievement.AddDataAchievement(17, 1); break; //humberger case 9: DialogAchievement.AddDataAchievement(18, 1); break; //nho case 11: DialogAchievement.AddDataAchievement(9, 1); break; //sữa dâu case 12: DialogAchievement.AddDataAchievement(8, 1); break; //sữa tươi default: break; } }
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); } }
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; } }
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; } }