Exemplo n.º 1
0
    void Update()
    {
        if (UIManager.Instance.isPlay)
        {
            time += Time.deltaTime;
            if (time >= DeltaTimeGame)
            {
                int month = dateGame.Month;
                int year  = dateGame.Year;
                dateGame = dateGame.AddDays(1f);
                SetDate();
                UpdateDataUser(main);
                if (dateGame.Month == 1)
                {
                    for (int i = 0; i < main.lsCoutryReady.Count; i++)
                    {
                        main.lsCoutryReady[i].ResetDataCol();
                    }
                }
                if (dateGame.Month != month)
                {
                    world_main.PullData();
                    for (int i = 0; i < main.lsCoutryReady.Count; i++)
                    {
                        main.lsCoutryReady[i].PullData();
                    }
                    if (main.lsCoutryReady.Count > 0)
                    {
                        checkMonth++;
                        if (checkMonth >= GameConfig.Instance.dTime)
                        {
                            NewsGame();
                            checkMonth = 0;
                        }
                        if (WorldManager.Instance.idSelectWord < main.lsCoutryReady.Count &&
                            UIManager.Instance.indexScene == 1)
                        {
                            if (WorldManager.Instance.idSelectWord != -1)
                            {
                                main.lsCoutryReady[WorldManager.Instance.idSelectWord].LoadDataChart();
                            }
                            else
                            {
                                world_main.LoadDataChart();
                            }
                        }
                    }
                }
                if (modePlay == 1)
                {
                    if (year - dateStartPlay.Year >= 5 && UIManager.Instance.isPlay)
                    {
                        UIManager.Instance.isPlay = false;
                        if (main.dollars > 1000000000)
                        {
                            AudioManager.Instance.Stop("GamePlay");
                            AudioManager.Instance.Play("OverWin");

                            UIManager.Instance.panelWin.SetActive(true);
                            UIManager.Instance.isPlay = false;
                        }
                        else
                        {
                            AudioManager.Instance.Stop("GamePlay");
                            AudioManager.Instance.Play("OverWin");

                            UIManager.Instance.panelGameOver.SetActive(true);
                            UIManager.Instance.isPlay = false;
                        }
                        GameConfig.Instance.bitCoin = main.bitCoin;
                        PlayerPrefs.SetInt("BitCoin", (int)main.bitCoin);
                        PlayerPrefs.SetInt("isData", 0);
                    }
                }

                UpdateUI();
                time = 0;
            }
        }
    }