Пример #1
0
 // Update is called once per frame
 void Update()
 {
     currentRhythmState = RhythmController.instance.GetCurrentState();
     if (currentRhythmState == RhythmState.Instruction)
     {
         //test.color = new Color(0, 0, 1);
         //允许有指令输入的时候
         if (Input.GetButtonDown("Fire1"))
         {
             Move(Direction.Left);
         }
         if (Input.GetButtonDown("Fire2"))
         {
             Move(Direction.Right);
         }
         RhythmController.instance.circle.GetComponent <MeshRenderer>().material.color = new Color(0, 0, 1);
     }
     else if (currentRhythmState == RhythmState.Action)
     {//允许世界上的各个要素开始运动的时候
         RhythmController.instance.circle.GetComponent <MeshRenderer>().material.color = new Color(0, 1, 0);
     }
     else
     {
         StopAllAction();
         RhythmController.instance.circle.GetComponent <MeshRenderer>().material.color = new Color(1, 0, 0);
     }
 }
Пример #2
0
    /* IEnumerator CountState()
     * {
     *   if (currentState == RhythmState.Instruction)
     *   {
     *        yield return new WaitForSeconds(instructionTime);
     *       currentState = RhythmState.Action;
     *   }else if(currentState==RhythmState.Action)
     *   {
     *        yield return new   WaitForSeconds(actionTime);
     *       currentState = RhythmState.Forbidden;
     *   }
     *   else
     *   {
     *       yield return  new WaitForSeconds(repeatTime-instructionTime-actionTime);
     *       currentState= RhythmState.Instruction;
     *   }
     *   StartCoroutine(CountState());//下一个时间状态
     * }*/
    // Update is called once per frame
    void Update()
    {
        float tempz = circle.transform.rotation.eulerAngles.z < 0 ? circle.transform.rotation.eulerAngles.z + 360 : circle.transform.rotation.eulerAngles.z; //使得角度变成连续的

        if (tempz < instructionRate * 360 && tempz >= 0)                                                                                                     //0-180*0.2都是指令时间,具体可以平移
        {
            currentState = RhythmState.Instruction;                                                                                                          //命令时间
        }
        else if (tempz > instructionRate * 360 && tempz < 360 * (instructionRate + actionRate))                                                              //180*(0.2)-180*(0.2+0.3)行动时间
        {
            currentState = RhythmState.Action;                                                                                                               //指令时间
        }
        else
        {
            currentState = RhythmState.Forbidden;//静止时间
        }
    }