示例#1
0
    void Update()
    {
        if (CommonData.timestep >= 0.25 && CommonData.timestep_Go && CommonData.stepafteranimation)
        {
            Next_Element(blockController);
            ResetPosition();
            CommonData.timestep_Go = false;
        }
        CommonData.timestep          += Time.deltaTime;
        CommonData.timeforLogoTetris += Time.deltaTime;
        CommonData.countforanimation += Time.deltaTime;
        timeCountForHighSpeed        += Time.deltaTime;
        timeCountForAvtoDown         += Time.deltaTime;

        if (CommonData.animation_1_active)
        {
            Animation_1_lines();
        }
        if (CommonData.animation_2_active)
        {
            StartCoroutine(anim_fall_lines());
            CommonData.animation_2_active = false;
            CommonData.animation_1_active = false;
        }

        if (CommonData.compressactive)
        {
            CompressLine();
            CommonData.compressactive     = false;
            CommonData.stepafteranimation = true;
        }

        if (timeCountForAvtoDown > TimeLevelCount && CommonData.stepafteranimation && CommonData.Play)
        {
            blockController.DownAuto();
            if (CommonData.timestep_Go)
            {
                CommonData.countforanimation  = 0;
                CommonData.animation_1_active = true;
            }
            ResetPosition();
            timeCountForAvtoDown = 0;
        }
        if (Input.GetKey(KeyCode.RightArrow) && CommonData.Play)
        {
            if (timeCountForHighSpeed > 0.1)
            {
                blockController.Right();
                timeCountForHighSpeed = 0;
                ResetPosition();
            }
        }
        if (Input.GetKey(KeyCode.LeftArrow) && CommonData.Play)
        {
            if (timeCountForHighSpeed > 0.1)
            {
                blockController.Left();
                timeCountForHighSpeed = 0;
                ResetPosition();
            }
        }
        if (Input.GetKeyDown(KeyCode.DownArrow) && CommonData.Play)
        {
            blockController.DownOneStep();
            CommonData.countforanimation  = 0;
            CommonData.animation_1_active = true;
            ResetPosition();
        }

        if (Input.GetKeyDown(KeyCode.UpArrow) && CommonData.Play)
        {
            Sound_Rotation();
            CommonData.ResetCasper();
            blockController.Rotate();
            CommonData.animation_1_active = false;
            ResetPosition();
        }
        if (Input.GetKeyDown(KeyCode.Return))
        {
            ResetGame(blockController);
            ResetPosition();
        }
        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (CommonData.Play)
            {
                CommonData.Play = false;
                CommonData.Logo_Pause.SetActive(true);
            }
            else
            {
                CommonData.Play = true;
                CommonData.Logo_Pause.SetActive(false);
            }
        }

        Line.text  = "Line " + CommonData.Line;
        Score.text = "Score " + CommonData.Score;
        LevelTimeAvtoDownStep();
        Set_Logo_Tetris();
    }