public void DeleteItemButton(Facebook.FacebookDelegate callback = null) { if (callback == null) { callback = result => { if (!String.IsNullOrEmpty(result.Error)) { Debug.LogError(result.Error); } else { //Cong tim khi nguoi dung nhan AudioControl.AddHeart(1); if (this != null) { Transform gridView = this.transform.parent;//This => Grid gridView.GetComponent <UIGrid>().RemoveChild(this.transform); Destroy(this.gameObject); } } }; } //Delete Request && Item if (requestId.Length > 0) { DFB.FBDeleteRequest(requestId, callback); } else { Debug.LogError("Request id not valid: " + requestId); } }
public void StartButton() { LoadingStartMenu.showFullBanner = true; //HideDialogMission(); AudioControl.DPlaySound("Click 1"); dialogLeft.GetComponent <DialogMissionLeft>().Hide(); dialogMid.GetComponent <DialogMissionMid>().Hide(); LeanTween.scale(dialogMid.gameObject, new Vector3(0, 0, 0), 0.2f).setUseEstimatedTime(true).setEase(LeanTweenType.easeInBack).setDelay(0.2f).setOnComplete(() => { MissionControl.countShowDialogLogin++; MissionControl.countShowRate++; Show = false; if (VariableSystem.heart < 1) { transform.parent.parent.GetComponent <MissionControl>().AddHeartButton(); } else { //Tru tim khi bat dau choi AudioControl.AddHeart(-1); //Chua bo dc cai dialog mission vi 1 so thanh phan cua no ko hien len sau khi goi active lai if (MissionData.targetCommon.startScene == 1) { LoadingScene.ShowLoadingScene("Farm", true); } else if (MissionData.targetCommon.startScene == 2) { LoadingScene.ShowLoadingScene("Factory", true); } else { LoadingScene.ShowLoadingScene("Store", true); } //Destroy music AudioControl.StopMusic("Nhac menu"); GoogleAnalytics.instance.LogScreen("Play level " + level); } transform.FindChild("BgBlack").gameObject.SetActive(false); }); LeanTween.scale(dialogLeft.gameObject, new Vector3(0, 0, 0), 0.1f).setUseEstimatedTime(true).setEase(LeanTweenType.easeInBack); dialogRight.GetComponent <DialogMissionRight>().HideDialog(); //HungBV - reset FactoryScenesController.isCreat = false; TownScenesController.isCreat = false; VilageResearchController.isCreate = false; CreatAndControlPanelHelp.countClickHelpPanel = 0; LotteryController.countSpin = 1; }
public void ButtonRefill() { Debug.Log("Button refill"); Transform confirm = Instantiate(DialogConfirm) as Transform; confirm.parent = transform; HideDialog(); confirm.GetComponent <DialogConfirm>().ShowDialog(MissionControl.Language["Refill"], MissionControl.Language["refill_heart"], () => { if (VariableSystem.diamond >= 3) { VariableSystem.AddDiamond(-3); AudioControl.AddHeart(5 - VariableSystem.heart); } else { DialogInapp.ShowInapp(); } }); }
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); } }
public void Show() { Time.timeScale = 1.0f; MissionControl.ResetAllItem(); LoadingScene.HideLoadingScene(); CommonObjectScript.isViewPoppup = true; //Debug.Log("Show result ----------------------------------"); missionFail.localScale = new Vector3(8, 8, 1); missionFail.gameObject.SetActive(false); TweenAlpha.Begin(missionFail.gameObject, 0, 0); star = 0; if (DialogTask.complete) { star = 1; reward = MissionData.starMission.reward[0]; if (CommonObjectScript.dollar >= MissionData.starMission.twoStar) { reward = MissionData.starMission.reward[1]; star = 2; } if (CommonObjectScript.dollar >= MissionData.starMission.threeStar) { reward = MissionData.starMission.reward[2]; star = 3; } particleWin.gameObject.SetActive(true); ///////////------------------------------------------ AudioControl.getMonoBehaviour().StartCoroutine(DHS.PostMeCurrentMission(VariableSystem.mission + 1)); //Cong tim khi thang AudioControl.AddHeart(1); //Nhac thang AudioControl.DPlaySound("Thang"); } else { //Nhac thua AudioControl.DPlaySound("Thua"); } //star = 3;////////////////////////////////////////////////////// //particleWin.gameObject.SetActive(true); if (Application.loadedLevelName.Equals("Farm")) { GameObject.Find("UI Root").transform.FindChild("PanelPlant").GetComponent <PlantControlScript>().BG_Click(); } lbReward.text = "0"; //Test //VariableSystem.dollar = 1000; //Thay doi ngon ngu bgMain.FindChild("Target").GetComponent <UILabel>().text = "" + MissionControl.Language["Require"]; bgMain.FindChild("Score").GetComponent <UILabel>().text = "" + MissionControl.Language["Your_Score"]; bgMain.FindChild("Reward").GetComponent <UILabel>().text = "" + MissionControl.Language["Reward"]; bgMain.FindChild("Ok").FindChild("Label").GetComponent <UILabel>().text = "" + MissionControl.Language["Ok"]; bgMain.FindChild("TryAgain").FindChild("Label").GetComponent <UILabel>().text = "" + MissionControl.Language["Try_Again"]; bgMain.FindChild("RewardCustomer").GetComponent <UILabel>().text = "" + MissionControl.Language["Bonus_customer_rate"]; bgMain.FindChild("LbStar1").GetComponent <UILabel>().text = "" + MissionControl.Language["All_target"]; lbTitle.text = MissionControl.Language["MISSION"] + " " + VariableSystem.mission; bgMain.FindChild("LbStar2").GetComponent <UILabel>().text = DString.ConvertString(MissionData.starMission.twoStar); bgMain.FindChild("LbStar3").GetComponent <UILabel>().text = DString.ConvertString(MissionData.starMission.threeStar); bgMain.FindChild("Score").FindChild("Label").GetComponent <UILabel>().text = DString.ConvertString(CommonObjectScript.dollar); bgBlack.gameObject.SetActive(true); LeanTween.delayedCall(1.0f, () => { Time.timeScale = 0; }).setUseEstimatedTime(true); bgMain.gameObject.SetActive(true); LeanTween.scale(bgMain.gameObject, new Vector3(1, 1, 1), 0.4f).setUseEstimatedTime(true).setEase(LeanTweenType.easeOutBack).setOnComplete(() => { star1.localScale = new Vector3(8, 8, 8); star2.localScale = new Vector3(8, 8, 8); star3.localScale = new Vector3(8, 8, 8); //Dieu kien xet sao if (star > 0) { star1.gameObject.SetActive(true); LeanTween.scale(star1.gameObject, new Vector3(1, 1, 1), 0.5f).setUseEstimatedTime(true).setEase(LeanTweenType.easeOutExpo).setOnComplete(() => { //Check dieu kien de co sao thu 2 if (star > 1) { star2.gameObject.SetActive(true); LeanTween.scale(star2.gameObject, new Vector3(1, 1, 1), 0.5f).setUseEstimatedTime(true).setEase(LeanTweenType.easeOutExpo).setOnComplete(() => { //Check dieu kien de co sao thu 3 if (star > 2) { star3.gameObject.SetActive(true); LeanTween.scale(star3.gameObject, new Vector3(1, 1, 1), 0.5f).setUseEstimatedTime(true).setEase(LeanTweenType.easeOutExpo); } }); } }); } else { missionFail.gameObject.SetActive(true); LeanTween.scale(missionFail.gameObject, new Vector3(1, 1, 1), 0.5f).setUseEstimatedTime(true).setEase(LeanTweenType.easeInOutQuart); TweenAlpha.Begin(missionFail.gameObject, 0.5f, 1); } }); //Them task nhiem vu //if (VariableSystem.mission == 1) //{ // AddItemResult("" + MissionControl.Language["Control_guide"], true, null, false); //} foreach (Transform tf in dialogTask.FindChild("Grid").GetComponent <UIGrid>().GetChildList()) { AddItemResult(tf.GetComponent <ItemTask>().lbContent.text, tf.GetComponent <ItemTask>().togComplete.value, tf.GetComponent <ItemTask>().item, tf.GetComponent <ItemTask>().typeShow1); } grid.Reposition(); transform.FindChild("SpriteBlack").gameObject.SetActive(true); //An bang task khi hien thi result GameObject task = GameObject.Find("DialogTask").gameObject; if (task != null) { task.GetComponent <DialogTask>().HideButton(); } GameObject inapp = GameObject.Find("DialogInapp").gameObject; if (inapp != null) { inapp.GetComponent <DialogInapp>().HideDialog(); } //Cap nhat lai phan thuong - Neu so sao moi <= so sao hien tai => thuong 1 kim cuong if (star > 0 && star <= DataCache.dataMissionCache[VariableSystem.mission - 1].Star) { reward = 1; } VariableSystem.AddDiamond(reward); VariableSystem.AddDiamond(CommonObjectScript.rewardCustomerRate); Debug.Log("CONG KIM CUONG -------------------- reward " + reward + " CommonObjectScript.rewardCustomerRate " + CommonObjectScript.rewardCustomerRate); DataCache.UpdateMissionScore(CommonObjectScript.dollar, star, VariableSystem.mission, 1); bool sendToServer = false; if (star > 0) { if (VariableSystem.mission < DataMissionControlNew.MAX_MISSION) { DataCache.SetMeCurrentMission(VariableSystem.mission + 1); } sendToServer = true; } DataCache.SaveMissionDataCache(sendToServer); lbReward.text = "" + reward; lbRewardCustomer.text = "" + CommonObjectScript.rewardCustomerRate; }