Exemple #1
0
    /// <summary>
    /// 用于读取相应记分,用法实例:TuneScoreSheet.instance.ReadScore(TunesTypeEnum.FwdTune,JudgementEnum.Great)
    /// </summary>
    /// <param name="tunesType"></param>
    /// <param name="judgementType"></param>
    /// <returns></returns>
    public string ReadScore(TunesTypeEnum tunesType, JudgementEnum judgementType)
    {
        //	return ReferenceDataTable.Rows[1]["Cool"].ToString();
        var score = _referenceDataTable.Rows[(int)tunesType][judgementType.ToString()].ToString();

        return(score);
    }
Exemple #2
0
 /// <summary>
 /// 重载:用于读取相应记分,并且以特定秒数做记分标准
 /// </summary>
 /// <param name="tunesType"></param>
 /// <param name="judgementType"></param>
 /// <param name="playerSerialTime"></param>
 /// <param name="judgeTime"></param>
 /// <returns></returns>
 public string ReadScore(TunesTypeEnum tunesType, JudgementEnum judgementType, float playerSerialTime, float judgeTime = 0.5f)
 {
     //	return ReferenceDataTable.Rows[1]["Cool"].ToString();
     var score = _referenceDataTable.Rows[(int)tunesType][judgementType.ToString()].ToString();
     var Score = Convert.ToInt32(score);
     {
         return((Ceiling(playerSerialTime * 2, judgeTime) / 2 * Score).ToString());
     }
 }
    void Update()
    {
        //计时
        _timertime = _timer.Elapsed.TotalMilliseconds;

        //判断是否前仰,,,用鼠标左键代替
        _isFwd = Input.GetMouseButton(0);
        //暂时去掉鼠标左键
        _isFwd = true;
        //判断是否在音符内
        var ray = Camera.main.ScreenPointToRay(new Vector2(Screen.width / 2, Screen.height / 2));

        _insideNote = Physics.Raycast(ray);

        if (Input.GetKey(KeyCode.Space) && _insideNote && _isFwd)
        {
            if (_fpController != null && _fpController.activeSelf)
            {
                _fpController.SetActive(false);
            }
        }
        else
        {
            if (_fpController != null && !_fpController.activeSelf)
            {
                _fpController.SetActive(true);
            }
        }

        if (Input.GetKeyDown(KeyCode.Space) && Judgeonce && _isFwd)
        {
            //产生单次音符敲击动画
            var center = app.model.FpModel.DynamicPos.GetComponent <Transform>().position;
            app.model.FpModel.DynamicEffect.SetActive(true);
            Instantiate(app.model.FpModel.DynamicEffect, center, GetComponent <Transform>().rotation);
            //按键时间
            _beatsSigm = _timertime / 1000;
            _timer.Stop();
            var a = new JudgementSystem();
            resultJudgement = a.Judgement(_insideNote, _beatsSigm, _codeBias);

            if (resultJudgement == JudgementEnum.NotClick)
            {
                return;
            }
            // TuneStatusCO.SetActive(true);
            //animator.SetInteger("TuneStatues", result);

            #region ADDSCORE

            Debug.Log("前仰音点击时间 " + _beatsSigm + "评级 " + resultJudgement.ToString());

            Debug.Log("此次得分:" + TuneScoreSheet.GetInstance.ReadScore(TunesTypeEnum.FwdTune, resultJudgement, 3.0f, 0.5f));

            ScoreSystem.GetInstance.CalculateCurrentScore(float.Parse(TuneScoreSheet.GetInstance.ReadScore(TunesTypeEnum.FwdTune, resultJudgement, 3.0f, 0.5f)));

            Debug.Log("当前分数 :" + ScoreSystem.GetInstance.CurrentScore);

            FindObjectOfType <ScoreField>()
            .GetComponent <ScoreField>()
            .UpdateScore(ScoreSystem.GetInstance.CurrentScore);

            #endregion

            #region ADDCOMBO

            //			if(resultJudgement!=JudgementEnum.Miss)
            //			{
            //				ComboSystem.GetInstance.AddCurrentCombo(time,musicPointPrefab);
            //			}

            if (resultJudgement != JudgementEnum.Miss)
            {
                ComboSystem.GetInstance.AddCurrentCombo();
            }
            else if (resultJudgement == JudgementEnum.Miss)
            {
                ComboSystem.GetInstance.ResetCurrentCombo();
            }


            #endregion
            if (SongModel.HandlerDictionary.Count != 0)
            {
                SongModel.Curtunetime = SongModel.HandlerDictionary.Keys.Min();
            }
            SongModel.Curover = true;
            // judgeonce = false;
            _timer.Start();
        }

        if (_timertime > 1000 && Judgeonce == true)
        {
            //TuneStatusCO.SetActive(true);
            //animator.SetInteger("TuneStatues", 4);
        }

        if (Input.GetKeyUp(KeyCode.Space) && Judgeonce == true && _isFwd == true && _insideNote == true)
        {
            //产生单次音符敲击动画
            var center = app.model.FpModel.DynamicPos.GetComponent <Transform>().position;
            app.model.FpModel.DynamicEffect.SetActive(true);
            Instantiate(app.model.FpModel.DynamicEffect, center, this.GetComponent <Transform>().rotation);
            //按键时间
            _beatsSigm = (_timertime - 1000) / 1000;
            _timer.Stop();
            var a = new JudgementSystem();
            resultJudgement = a.Judgement(_insideNote, _beatsSigm, _codeBias);
            TuneStatusCo.SetActive(true);
            _animator.SetInteger("TuneStatues", (int)resultJudgement);
            print("点击时间" + _beatsSigm + "评级" + resultJudgement);
            Judgeonce = false;
            if (SongModel.HandlerDictionary.Count != 0)
            {
                SongModel.Curtunetime = SongModel.HandlerDictionary.Keys.Min();
            }
            SongModel.Curover = true;
            _timer.Start();
        }

        if (_timertime > 3000 && Judgeonce == true)
        {
            if (SongModel.HandlerDictionary.Count != 0)
            {
                SongModel.Curtunetime = SongModel.HandlerDictionary.Keys.Min();
            }
            SongModel.Curover = true;
            TuneStatusCo.SetActive(true);
            _animator.SetInteger("TuneStatues", (int)JudgementEnum.Miss);

            resultJudgement = JudgementEnum.Miss;

            if (resultJudgement == JudgementEnum.Miss)
            {
                ComboSystem.GetInstance.ResetCurrentCombo();
            }
        }
        if (_timertime >= 4200)
        {
            if (SongModel.HandlerDictionary.Count != 0)
            {
                SongModel.Curtunetime = SongModel.HandlerDictionary.Keys.Min();
            }
            SongModel.Curover = true;
            Destroy(gameObject);
            //print("DestroygameObject");
        }
    }
    private void Update()
    {
        //计时
        _timertime = _timer.Elapsed.TotalMilliseconds;

        //判断是否在音符内
        var        ray = Camera.main.ScreenPointToRay(new Vector2(Screen.width / 2, Screen.height / 2));
        RaycastHit hitInfo;
        string     myname = transform.name;

        if (Physics.Raycast(ray, out hitInfo) && hitInfo.collider.name == myname)
        {
            _insideNote = true;
        }
        else
        {
            _insideNote = false;
        }

        if (Input.GetKeyDown(KeyCode.Space) && Judgeonce)
        {
            //产生单次音符敲击动画
            var center = app.model.FpModel.DynamicPos.GetComponent <Transform>().position;
            app.model.FpModel.DynamicEffect.SetActive(true);
            Instantiate(app.model.FpModel.DynamicEffect, center, this.GetComponent <Transform>().rotation);
            //按键时间
            _beatsSigm = _timertime / 1000;
            _timer.Stop();
            var a = new JudgementSystem();
            resultJudgement = a.Judgement(_insideNote, _beatsSigm, _codeBias);
            TuneStatusCo.SetActive(true);
            _animator.SetInteger("TuneStatues", (int)resultJudgement);
            #region ADDSCORE

            Debug.Log("单音点击时间 " + _beatsSigm + "评级 " + resultJudgement.ToString());

            Debug.Log("此次得分:" + TuneScoreSheet.GetInstance.ReadScore(TunesTypeEnum.SingleTune, resultJudgement));

            //通知ScoreSystem增加对应得分
            ScoreSystem.GetInstance.CalculateCurrentScore(
                float.Parse(TuneScoreSheet.GetInstance.ReadScore(TunesTypeEnum.SingleTune, resultJudgement)));

            Debug.Log("当前分数 :" + ScoreSystem.GetInstance.CurrentScore);

            //找到分数显示区域,通知它改变总分
            FindObjectOfType <ScoreField>()
            .GetComponent <ScoreField>()
            .UpdateScore(ScoreSystem.GetInstance.CurrentScore);


            #endregion

            #region ADDCOMBO

//			if(resultJudgement!=JudgementEnum.Miss)
//			{
//				ComboSystem.GetInstance.AddCurrentCombo(time,musicPointPrefab);
//			}

            if (resultJudgement != JudgementEnum.Miss)
            {
                ComboSystem.GetInstance.AddCurrentCombo();
            }
            else if (resultJudgement == JudgementEnum.Miss)
            {
                ComboSystem.GetInstance.ResetCurrentCombo();
            }


            #endregion

            Judgeonce = false;

            if (SongModel.HandlerDictionary.Count != 0)
            {
                SongModel.Curtunetime = SongModel.HandlerDictionary.Keys.Min();
            }
            SongModel.Curover = true;
            _timer.Start();
        }

        if (_timertime > 2000 && Judgeonce)
        {
            TuneStatusCo.SetActive(true);
            _animator.SetInteger("TuneStatues", (int)JudgementEnum.Miss);

            Judgeonce = false;

            if (SongModel.HandlerDictionary.Count != 0)
            {
                SongModel.Curtunetime = SongModel.HandlerDictionary.Keys.Min();
            }
            SongModel.Curover = true;
            //ComboSystem.GetInstance.ResetCurrentCombo();

            resultJudgement = JudgementEnum.Miss;

            if (resultJudgement == JudgementEnum.Miss)
            {
                ComboSystem.GetInstance.ResetCurrentCombo();
            }
        }
        if (_timertime >= 3300)
        {
            if (SongModel.HandlerDictionary.Count != 0)
            {
                SongModel.Curtunetime = SongModel.HandlerDictionary.Keys.Min();
            }
            SongModel.Curover = true;
            Destroy(gameObject);
        }
    }