private void LoadSetting()
        {
            // Language setting
            var laSetting = PlayerPrefs.GetString(CTaskUtil.LA_SETTING, CTaskUtil.Get(CTaskUtil.LA_SETTING).ToString());

            CTaskUtil.Set(CTaskUtil.LA_SETTING, laSetting);
            // User energy display
            var maxEnergy     = (int)CTaskUtil.Get(CTaskUtil.PLAYER_MAX_ENERGY);
            var currentEnergy = PlayerPrefs.GetInt(CTaskUtil.PLAYER_ENERGY, maxEnergy);
            var saveTimer     = long.Parse(PlayerPrefs.GetString(CTaskUtil.PLAYER_ENEGY_SAVE_TIMER, this.m_CurrentTime.ToString()));
            var firstTimer    = long.Parse(PlayerPrefs.GetString(CTaskUtil.GAME_FIRST_TIME, this.m_CurrentTime.ToString()));
            var playerEnergy  = CTaskUtil.Get(CTaskUtil.PLAYER_ENERGY) as CPlayerEnergy;

            playerEnergy.currentEnergy   = currentEnergy;
            playerEnergy.maxEnergy       = maxEnergy;
            playerEnergy.incrementEnergy = 1;
            playerEnergy.timePerPoint    = 60 * 15f;                // 15 Minute
            playerEnergy.currentTimer    = this.m_CurrentTime;
            playerEnergy.saveTimer       = saveTimer;
            playerEnergy.firstTimer      = firstTimer;
            playerEnergy.repeatCounting  = true;
            playerEnergy.StartCounting();
            playerEnergy.CalculateEnergy();
            playerEnergy.CalculateTimer();
            // Song volume
            var soundVolume = PlayerPrefs.GetFloat(CTaskUtil.GAME_SOUND_VOLUME, (float)CTaskUtil.Get(CTaskUtil.GAME_SOUND_VOLUME));

            CTaskUtil.Set(CTaskUtil.GAME_SOUND_VOLUME, soundVolume);
        }
Пример #2
0
        protected virtual void UpdateGame()
        {
            this.m_IsPlaying = true;
            var audioTime = (int)this.m_AudioSource.time;
            var step      = 100;

            while (step > 0 && m_NodeIndex < m_ListNodeData.Count)
            {
                var currentNodeData = m_ListNodeData [m_NodeIndex];
                if (audioTime == currentNodeData.audioTime && audioTime != m_PreviousTime)
                {
                    var nodeType = (ENodeType)currentNodeData.nodeType;
                    var node     = SpawnNode(nodeType.ToString());
                    this.SetUpNode(node);
                    node.SetPosition2D(currentNodeData.nodePosition.ToVector2());
                    node.SetScale(currentNodeData.nodeScale);
                    node.SetNodeType(nodeType);
                    m_NodeIndex++;
                }
                else
                {
                    m_PreviousTime = audioTime;
                    break;
                }
                step--;
            }
            this.m_AudioSource.volume = (float)CTaskUtil.Get(CTaskUtil.GAME_SOUND_VOLUME);
        }
Пример #3
0
        private void SetupSongItem(int index, CUISongItem item, GameObject parent, string text, Sprite bg, int hardPoint, Action submit)
        {
            var playerEnergy = CTaskUtil.Get(CTaskUtil.PLAYER_ENERGY) as CPlayerEnergy;

            item.transform.SetParent(parent.transform);
            item.gameObject.SetActive(true);
            item.SetUpSongItem(index, text, bg, hardPoint, playerEnergy.currentEnergy < hardPoint, submit);
        }
Пример #4
0
        public override void StartTask()
        {
            base.StartTask();
            this.m_UIManager = CUIManager.GetInstance();

            var soundVolume = (float)CTaskUtil.Get(CTaskUtil.GAME_SOUND_VOLUME);

            this.m_UIManager.SetSoundVolume(soundVolume);
        }
Пример #5
0
        private void SaveTask()
        {
            var playerEnergy = CTaskUtil.REFERENCES [CTaskUtil.PLAYER_ENERGY] as CPlayerEnergy;

            playerEnergy.CalculateSaveTimer();
            playerEnergy.CalculateTimer();
            PlayerPrefs.SetInt(CTaskUtil.PLAYER_ENERGY, playerEnergy.currentEnergy);
            PlayerPrefs.SetString(CTaskUtil.PLAYER_ENEGY_SAVE_TIMER, playerEnergy.saveTimer.ToString());
            PlayerPrefs.SetFloat(CTaskUtil.GAME_SOUND_VOLUME, (float)CTaskUtil.Get(CTaskUtil.GAME_SOUND_VOLUME));
            PlayerPrefs.Save();
        }
        public override void EndTask()
        {
            base.EndTask();
            var laName       = CTaskUtil.Get(CTaskUtil.LA_SETTING).ToString();
            var currentTimer = System.DateTime.UtcNow.Ticks;

            PlayerPrefs.SetString(CTaskUtil.LA_SETTING, laName);
            PlayerPrefs.SetInt(CTaskUtil.GAME_FIRST_LAUNCH, 1);
            PlayerPrefs.SetInt(CTaskUtil.GAME_RESOURCE_COMPLETED, 1);
            PlayerPrefs.SetFloat(CTaskUtil.GAME_SOUND_VOLUME, (float)CTaskUtil.Get(CTaskUtil.GAME_SOUND_VOLUME));
            PlayerPrefs.GetString(CTaskUtil.PLAYER_ENEGY_SAVE_TIMER, currentTimer.ToString());
            PlayerPrefs.GetString(CTaskUtil.GAME_FIRST_TIME, currentTimer.ToString());
            PlayerPrefs.Save();
        }
        public CLoadingResourceTask() : base()
        {
            this.taskName = "LoadingResource";
            var firstSetting = PlayerPrefs.GetInt(CTaskUtil.GAME_FIRST_LAUNCH, 0) == 1;
            var host         = CTaskUtil.Get(CTaskUtil.HOST);

            if (firstSetting == false)
            {
                this.nextTask = "LocalSetting";
            }
            else
            {
                this.nextTask = "SelectSong";
            }
#if UNITY_EDITOR || UNITY_STANDALONE
            this.m_Request = new CRequest(host + "/version?plf=standalone");
#else
            this.m_Request = new CRequest(host + "/version?plf=android");
#endif
            this.m_CurrentTime      = DateTime.Now.Ticks;
            this.m_OnLoadingProcess = false;
        }
Пример #8
0
        public override void StartTask()
        {
            base.StartTask();
            this.m_UISelectGame = CUISelectSong.GetInstance();
            this.m_PlayerEnergy = CTaskUtil.REFERENCES [CTaskUtil.PLAYER_ENERGY] as CPlayerEnergy;

            var listSongs = CTaskUtil.REFERENCES [CTaskUtil.LIST_SONG] as List <CSongData>;

            if (listSongs != null)
            {
                this.m_UISelectGame.LoadListSongs(listSongs);
            }
            else
            {
                CLog.LogError("Error: Can not load song data.");
            }

            var energyText = string.Format("{0}/{1}", this.m_PlayerEnergy.currentEnergy, this.m_PlayerEnergy.maxEnergy);

            this.m_UISelectGame.SetEnergyDisplayText(energyText);
            this.m_UISelectGame.SetEnergyReloadActive(this.m_PlayerEnergy.currentEnergy < this.m_PlayerEnergy.maxEnergy);
            this.m_PlayerEnergy.OnUpdatePoint  = null;
            this.m_PlayerEnergy.OnUpdatePoint += () => {
                var energyText2 = string.Format("{0}/{1}", this.m_PlayerEnergy.currentEnergy, this.m_PlayerEnergy.maxEnergy);
                this.m_UISelectGame.SetEnergyDisplayText(energyText2);
            };

            this.m_PlayerEnergy.OnUpdateTimer  = null;
            this.m_PlayerEnergy.OnUpdateTimer += (timeUpdate) => {
                float minute = (int)(timeUpdate / 60f);
                float second = (int)(timeUpdate % 60f);
                this.m_UISelectGame.SetEnergyReloadText(string.Format("{0}:{1}", minute.ToString("00"), second.ToString("00")));
            };

            var soundVolume = (float)CTaskUtil.Get(CTaskUtil.GAME_SOUND_VOLUME);

            this.m_UISelectGame.SetSoundVolume(soundVolume);
        }