Esempio n. 1
0
    //開啟時,一次加回超時的疲勞值
    private void OnEnable()
    {
        //讀檔
        TimeManager.timeData = Save_LoadSystem.LoadTimeData();
        if (TimeManager.timeData == null)
        {
            TimeManager.timeData = new TimeManager.TimeData();
        }

        //總經過時間.秒數/恢復所需時間.秒數 =疲勞值恢復數量
        TimeSpan duration = TimeManager.timeData.NextAPrestoreTime - TimeManager.NowTime;

        Debug.Log("中途時間 " + duration);
        Debug.Log("下個AP時間 " + TimeManager.timeData.NextAPrestoreTime.ToString());
        int _ap = Mathf.FloorToInt((float)duration.TotalSeconds / (TimeManager.NextAP_Gap * 60));

        Debug.Log("<color=red>這期間恢復了 " + _ap + " 疲勞</color>");

        //AP上限
        if (_ap >= 0)
        {
            GM.playerData.AP += _ap;
            if (GM.playerData.AP >= 5)
            {
                GM.playerData.AP = 5;
            }
        }
    }
Esempio n. 2
0
    //右邊頁面->存讀玩家偏好
    public void OpenRightWindow()
    {
        Animator animator = RightWindo.GetComponent <Animator>();

        if (animator.GetCurrentAnimatorStateInfo(0).IsName("Menu_RightWindow_Close"))
        {
            animator.Play("Menu_RightWindow_Open");
            if (BoxSet != null)
            {
                BoxSet.GetComponent <Image>().raycastTarget = false;
            }
            //設偏好
            SetPerfernce();
        }

        else
        {
            animator.Play("Menu_RightWindow_Close");
            if (BoxSet != null)
            {
                BoxSet.GetComponent <Image>().raycastTarget = true;
            }

            //存偏好
            Save_LoadSystem.SavePlayerPreferenceData(GM.playerPreference);
        }
    }
Esempio n. 3
0
    //存檔
    void SaveMissionData()
    {
        //存檔案
        //取得目前所有任務資訊
        MissionClass[] missionClass = GameObject.FindObjectsOfType <MissionClass>();
        Debug.Log("存檔時任務數量:" + missionClass.Length);
        for (int i = 0; i < missionClass.Length; i++)
        {
        }

        if (missionDatas != null)
        {
            missionDatas.Clear();
        }

        foreach (MissionClass ms in missionClass)
        {
            MissionData _missiondata = new MissionData(ms.Type, ms.CurrentProgress, ms.Requirment, ms.ExpReward, ms.TotalScoreRequirment);

            if (missionDatas == null)
            {
                missionDatas = new List <MissionData>();
            }

            missionDatas.Add(_missiondata);
        }

        //SAVE
        Save_LoadSystem.SaveMissionData(missionDatas);
    }
Esempio n. 4
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
            return;
        }
        DontDestroyOnLoad(gameObject);

        DetectLanguage();

        Application.runInBackground = true;


        //等級讀檔
        GM.playerData = Save_LoadSystem.LoadPlayerData();
        if (GM.playerData == null)
        {
            GM.playerData = new PlayerData();
        }
    }
Esempio n. 5
0
    //等待結束時:
    IEnumerator TimetoEnd(float time)
    {
        yield return(new WaitForSeconds(time + 5));

        //建檔儲存
        Save_LoadSystem.SaveNodeData(nodes, _songName);

        GM.instance.SceneLoad("MainScene");
    }
Esempio n. 6
0
 private void Awake()
 {
     Debug.Log("Load TimeData!");
     //讀檔
     timeData = Save_LoadSystem.LoadTimeData();
     if (timeData == null)
     {
         timeData = new TimeData();
     }
 }
Esempio n. 7
0
    private void Awake()
    {
        //讀取檔案
        nodes = Save_LoadSystem.LoadNodeData(GM.instance.TempSongData.SongName);

        //放在畫面上
        if (nodes != null)
        {
            LoadInNodes();
            NodeTypeEvent.Nodes = nodes;
            Debug.Log(NodeTypeEvent.Nodes.Count);
        }
    }
Esempio n. 8
0
    void SetAP()
    {
        //疲勞值-1
        //GM.playerData.AP -= 1; 不限制AP

        //下個疲勞恢復時間
        if (TimeManager.timeData.IsCountingNextAPTime == false)
        {
            TimeManager.timeData.IsCountingNextAPTime = true;
            TimeManager.timeData.NextAPrestoreTime    = TimeManager.NowTime.AddMinutes(TimeManager.NextAP_Gap);
        }
        Save_LoadSystem.SaveTimeData(TimeManager.timeData);
        Debug.Log("下一個AP恢復時間:" + TimeManager.timeData.NextAPrestoreTime);
    }
Esempio n. 9
0
    //讀檔
    private void Start()
    {
        //讀檔 :任務檔案
        missionDatas = Save_LoadSystem.LoadMissinData();
        //清空所有目前任務:
        MissionClass[] _nowMis = gameObject.GetComponents <MissionClass>();
        for (int i = 0; i < _nowMis.Length; i++)
        {
            Destroy(_nowMis[i]);
        }

        //
        if (missionDatas != null)
        {
            Debug.Log("讀檔任務有:" + missionDatas.Count);
            SetLoadedMission();
        }
    }
Esempio n. 10
0
    //**********************************


    //設定偏好
    public void SetPerfernce()
    {
        //讀偏好:
        GM.PlayerPreference _temp = Save_LoadSystem.LoadPlayerPreferenceData();
        if (_temp != null)
        {
            GM.playerPreference = _temp;

            //難度
            //GM.playerPreference.Difficult = _temp.Difficult;

            //設定值
            ChangeImage(GM.playerPreference.IsMetronome, MetronomeImg, Metronome_active, Metronome_deactive);
            ChangeImage(GM.playerPreference.IsVibrate, VibrateImg, Vibrate_active, Vibrate_deactive);


            //音效:
            SetVolume_BGM(GM.playerPreference.MainBGM_V);
            SetVolume_Effect(GM.playerPreference.SoundEffect_V);
            SetVolume_Music(GM.playerPreference.GamePlayMusic_V);
            SetVolume_Metronome(GM.playerPreference.Metronome_V);

            Music.value     = GM.playerPreference.GamePlayMusic_V;
            BGM.value       = GM.playerPreference.MainBGM_V;
            Effect.value    = GM.playerPreference.SoundEffect_V;
            Metronome.value = GM.playerPreference.Metronome_V;

            bpmSlider.GetComponent <Slider>().value = GM.playerPreference.Metronome_bpm;
            bpm_text.text = GM.playerPreference.Metronome_bpm.ToString();
            if (GM.playerPreference.IsMetronome)
            {
                bpmSlider.SetActive(true);
            }
            else
            {
                //關閉Metronome
                bpmSlider.SetActive(false);
            }
        }
    }
Esempio n. 11
0
    //開啟時,一次加回超時的任務
    private void OnEnable()
    {
        //讀檔
        TimeManager.timeData = Save_LoadSystem.LoadTimeData();
        if (TimeManager.timeData == null)
        {
            TimeManager.timeData = new TimeManager.TimeData();
        }

        //總經過時間.秒數/任務產生所需時間.秒數 =任務增加數量
        TimeSpan duration = TimeManager.timeData.NextMissionTime - TimeManager.NowTime;

        Debug.Log("任務中途時間 " + duration);
        Debug.Log("下個任務時間 " + TimeManager.timeData.NextMissionTime.ToString());

        int _mis = Mathf.FloorToInt((float)duration.TotalSeconds / (TimeManager.NextMissionGap * 60));

        Debug.Log("<color=red>這期間恢復了 " + _mis + " 個任務</color>");

        //產生任務
        if (_mis >= 0)
        {
            //目前任務數量
            int _missinonCount = MissionManager.instance.GetComponents <MissionClass>().Length;
            //任務上限
            _mis = ((_missinonCount + _mis) > 5) ? (5 - _missinonCount) : _mis;

            //增加任務
            for (int i = 0; i < _mis; i++)
            {
                //生產任務
                int _type = UnityEngine.Random.Range(0, 30);

                RamdomAddMission((_type % _missionTypeTotalCount) + 1);
            }
            //刷新頁面
            CreatMissionList();
        }
    }
Esempio n. 12
0
 //儲存目前進度
 public void Save()
 {
     Save_LoadSystem.SaveNodeData(NodeTypeEvent.Nodes, GM.instance.TempSongData.SongName);
     //播放音效
     audioSource.Play();
 }
Esempio n. 13
0
    public void ShowclipInfo(WWW www)
    {
        GameObject InfoPanel = GameObject.Find("InfoPanel");

        BestScore      = InfoPanel.transform.Find("BestScore Text").GetComponent <TextMeshProUGUI>();
        BestPercentage = InfoPanel.transform.Find("BestPercentage Text").GetComponent <TextMeshProUGUI>();

        //讀取資料------------------------------------------------------
        GM.instance.TempSongData = Save_LoadSystem.LoadSongData(Path.GetFileNameWithoutExtension(www.url));
        Debug.Log("Load Item:" + Path.GetFileName(www.url));
        Debug.Log(GM.instance.TempSongData);

        //先前已有紀錄=> 讀進資料
        if (GM.instance.TempSongData != null)
        {
            BestScore.text      = GM.instance.TempSongData.BestScore.ToString();
            BestPercentage.text = GM.instance.TempSongData.BestPercentage.ToString("p1");
        }
        else
        {
            GM.instance.TempSongData = new SongClass();
            BestScore.text           = "0";
            BestPercentage.text      = "0%";
        }

        GM.instance.TempSongData.SongFilePath = www.url;
        GM.instance.TempSongData.SongName     = Path.GetFileNameWithoutExtension(www.url);
        //--------------------------------------------------------------


        //Title:
        Title      = InfoPanel.transform.Find("Title Text").GetComponent <TextMeshProUGUI>();
        Title.text = Path.GetFileNameWithoutExtension(www.url.ToString());

        //音樂長度
        ClipDuration      = InfoPanel.transform.Find("Duration Text").GetComponent <TextMeshProUGUI>();
        ClipDuration.text = ((int)GM.instance.GetComponent <AudioSource>().clip.length / 60).ToString() + " : " + ((int)GM.instance.GetComponent <AudioSource>().clip.length % 60).ToString();

        //預覽音樂=>從音樂一半開始播放
        if (GM.instance.audioSource.clip == null)
        {
            Debug.LogError("GM.instance.audioSource.clip =NULL");
            return;
        }
        try
        {
            GM.instance.audioSource.Play();
            GM.instance.audioSource.time = GM.instance.audioSource.clip.length / 2;
        }
        catch (System.Exception ex) { }

        //動畫=> 打開顯示資料的面板
        animator.Play("Menu_ShowInfo");

        //若有自訂譜: 出現遊玩選項
        if (CheckCustumeFile(Path.GetFileNameWithoutExtension(www.url)))
        {
            GameObject btn = GameObject.FindGameObjectWithTag("HideBtn");
            btn.GetComponent <Image>().enabled  = true;
            btn.GetComponent <Button>().enabled = true;
            btn.transform.GetChild(0).GetComponent <TextMeshProUGUI>().enabled = true;
        }
        else
        {
            GameObject btn = GameObject.FindGameObjectWithTag("HideBtn");
            btn.GetComponent <Image>().enabled  = false;
            btn.GetComponent <Button>().enabled = false;
            btn.transform.GetChild(0).GetComponent <TextMeshProUGUI>().enabled = false;
        }
    }
Esempio n. 14
0
    public float BobbleLifetime;//氣泡存活時間

    private void Start()
    {
        nodes = Save_LoadSystem.LoadNodeData(GM.instance.TempSongData.SongName);
    }
Esempio n. 15
0
    void OnSceneLoaded(Scene scence, LoadSceneMode mod)
    {
        //重置
        if (scence.name == "GamePlay_TypingMode" || scence.name == "GamePlay_PlayCustume")
        {
            gm = GameObject.FindObjectOfType <GM>().gameObject;

            TimeToEnd = gm.GetComponent <GM>().audioSource.clip.length + 5;

            StartCoroutine(_countdown());


            ComboControl.Combototal   = 0;
            ComboControl.CurrtenCombo = 0;
            ComboControl.HighestCombo = 0;
            ComboControl.MissCombo    = 0;
            ComboControl.Weighting[0] = 0;
            ComboControl.Weighting[1] = 0;
            ComboControl.Weighting[2] = 0;
            ComboControl.TotalScore   = 0;
        }


        if (scence.name == "EndingCounting")
        {
            GM.IsFirstIn = false;

            //處理疲勞值
            SetAP();

            //故事控制=>玩完一局才能觸發下個對話-------------
            StoryManager.storyProcess.IsNextGame = true;
            Save_LoadSystem.SaveStoryProcess(StoryManager.storyProcess);
            //---------------------------------

            float _bestPercentage = (float)ComboControl.Combototal / (float)(ComboControl.Combototal + ComboControl.MissCombo);

            total_text.text         = ComboControl.Combototal.ToString();
            complete_text.text      = _bestPercentage.ToString("p1");
            hightestCombo_text.text = ComboControl.HighestCombo.ToString();
            Miss_text.text          = ComboControl.MissCombo.ToString();
            Perfect_text.text       = ComboControl.Weighting[0].ToString();
            Good_text.text          = ComboControl.Weighting[1].ToString();
            Bad_text.text           = ComboControl.Weighting[2].ToString();

            //算加權分數
            //ComboControl.TotalScore         = ComboControl.Weighting[0] * 5 + ComboControl.Weighting[1] * 2 + ComboControl.Weighting[2] - ComboControl.MissCombo * 3;
            WeightingScore_text.text = ComboControl.TotalScore.ToString();


            //如果紀錄有超越前面的=>寫入更新
            GM.instance.TempSongData.BestPercentage = (GM.instance.TempSongData.BestPercentage > _bestPercentage) ? GM.instance.TempSongData.BestPercentage : _bestPercentage;
            GM.instance.TempSongData.BestScore      = (GM.instance.TempSongData.BestScore > ComboControl.TotalScore) ? GM.instance.TempSongData.BestScore : ComboControl.TotalScore;

            //計算經驗值
            GM.playerData.CurrentExp += 5 * (int)Mathf.Pow(ComboControl.TotalScore, 0.2f) * GM.playerData.Level;
            if (GM.playerData.CurrentExp <= 0)
            {
                GM.playerData.CurrentExp = 0;
            }

            Save_LoadSystem.SaveSongData(GM.instance.TempSongData);
        }
    }
Esempio n. 16
0
 private void OnLevelWasLoaded(int level)
 {
     Debug.Log("Time");
     //存檔
     Save_LoadSystem.SaveTimeData(timeData);
 }
Esempio n. 17
0
 private void OnApplicationQuit()
 {
     //存檔
     Save_LoadSystem.SaveTimeData(timeData);
 }
Esempio n. 18
0
    //進入場景時
    void OnSceneLoaded(Scene scence, LoadSceneMode mod)
    {
        //載入偏好設定
        if (GameObject.FindObjectOfType <SubMenuManager>() != null)
        {
            GameObject.FindObjectOfType <SubMenuManager>().SetPerfernce();
        }

        if (scence.name == "FirstScene")
        {
            //如果是第一次進入=>開頭
            if (IsFirstIn)
            {
                //SceneLoad(0);
            }
            else
            {
                SceneManager.LoadScene("MainScene");
            }
        }

        //結束頁面=>跳播音樂
        if (scence.name == "StoryEnding")
        {
            GameObject.Find("BGMPlayer").GetComponent <AudioSource>().time = 20;
        }

        if (scence.name == "GamePlay_TypingMode" || scence.name == "GamePlay_PlayCustume")
        {
            if (audioSource != null)
            {
                GM.instance.audioSource.Stop();
                //設定難度
                if (GameObject.FindObjectOfType <TypingCellControl>() != null)
                {
                    if (scence.name == "GamePlay_TypingMode")
                    {
                        SetDifficultLevel();
                    }
                    if (scence.name == "GamePlay_PlayCustume")
                    {
                        SetDifficultLevel_forCustume();
                    }
                }
                //設回時間
                GM.instance.audioSource.time = 0;

                //把GM的mixer設定成無聲頻道
                //GM.instance.Mute_audioSource.outputAudioMixerGroup = Mute_mixerGroup;
                GM.instance.GetComponent <AudioSource>().outputAudioMixerGroup = Mute_mixerGroup;

                //先倒數再開始=>播放無聲音樂(產生打擊點用)
                StartCoroutine(CountDown_coro(4));
                //播放有聲音樂
                try
                {
                    Debug.Log("Start Delay" + MuteSoundPlayDelay);
                    StartCoroutine(PlayRealSound(MuteSoundPlayDelay));
                }
                catch (System.Exception) { }
            }
        }

        if (scence.name == "GamePlay_CustumeMode" || scence.name == "EditCustumeNode")
        {
            GM.instance.audioSource.Stop();

            GM.instance.audioSource.time = 0;

            //把GM的mixer設定成有聲頻道
            //GM.instance.Mute_audioSource.outputAudioMixerGroup = Sound_mixerGroup;
            GM.instance.GetComponent <AudioSource>().outputAudioMixerGroup = Sound_mixerGroup;

            //先倒數再開始
            StartCoroutine(CountDown_coro(4));
        }

        //選單
        if (scence.name == "MainMenu")
        {
            //GM.instance.Mute_audioSource.outputAudioMixerGroup = Sound_mixerGroup;
            GM.instance.GetComponent <AudioSource>().outputAudioMixerGroup = Sound_mixerGroup;
        }

        if (scence.name == "MainScene")
        {
            GM.instance.audioSource.Stop();

            //處理升等:
            if (GM.playerData.CurrentExp >= GM.playerData.MaxExp)
            {
                LevelUP();
            }

            //存檔
            Save_LoadSystem.SavePlayerData(GM.playerData);

            Debug.Log("目前經驗" + GM.playerData.CurrentExp);
            //更新等級介面:
            GameObject.FindObjectOfType <EXPcontrol>().SetExpUIRing();
            GameObject.FindObjectOfType <EXPcontrol>().SetLevel_Text();
            GameObject.FindObjectOfType <EXPcontrol>().SetPercentage_text();
        }
    }