Пример #1
0
    void UpdateClientToServer()
    {
        Debug.Log("----------------------Dua du lieu moi len server----------------------");
        AudioControl.getMonoBehaviour().StartCoroutine(DHS.PostMeCurrentMission(currentMissionClient));
        string data_mission = "";

        for (int i = 0; i < DataCache.dataMissionCache.Length; i++)
        {
            //Chi gui nhung mission da open len server
            if (DataCache.dataMissionCache[i].Open == 1)
            {
                if (data_mission.Length > 0)
                {
                    data_mission += ",";
                }
                data_mission += DataCache.dataMissionCache[i].Mission + "-" + DataCache.dataMissionCache[i].Score + "-" + DataCache.dataMissionCache[i].Star + "-" + DataCache.dataMissionCache[i].Open;
            }
            DialogLoadingFB.HideFBLoading();
        }
        AudioControl.getMonoBehaviour().StartCoroutine(DHS.PostMeInfoMissionUpdate(FB.UserId, "" + data_mission));
        DataCache.SaveAchievementCache(true);
    }
Пример #2
0
    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;
    }