Exemplo n.º 1
0
    void Update()
    {
        hkey = Input.GetAxis("Horizontal");
        vkey = Input.GetAxis("Vertical");
        xkey = Input.GetKeyDown(KeyCode.X);
        zkey = Input.GetKeyDown(KeyCode.Z);
        ekey = Input.GetKeyDown(KeyCode.E);
        this.elapsed_time += Time.deltaTime;

        //Debug.Log(status);
        switch (this.state)
        {
        case "create":    //1フレーム

            this.playboard.CreateNextPuyo();
            this.state = "movenext";
            this.elapsed_createtime = 0;
            break;

        case "movenext":    //Configs.create_time

            this.elapsed_createtime += Time.deltaTime;
            this.playboard.MoveNextPuyos(this.elapsed_createtime / Configs.create_time);

            if (this.elapsed_createtime > Configs.create_time)
            {
                this.playpuyo = this.playboard.CreatePuyo();
                this.playpuyo.SetInitPos(Configs.init_pos);
                this.old_time = this.elapsed_time;
                state         = "move";
            }
            break;

        case "move":    //設置するまで

            this.playpuyo.Move(this.playboard.field_bool, vkey, hkey, xkey, zkey);
            playchecker.update_text(this.playpuyo, hkey, vkey, xkey, zkey);
            state = this.playpuyo.state;

            if (this.playpuyo.state == "split")
            {
                this.playboard.SetFieldPuyo(this.playpuyo.mpuyo);
                this.playboard.SetFieldPuyo(this.playpuyo.spuyo);
                //this.playpuyo = null;
                state = "check_fall";
            }
            break;

        case "check_fall":    //1フレーム

            this.playboard.CheckFallPuyos();
            if (playboard.is_falling)
            {
                state = "fall";
                this.fall_starttime = Time.time;
            }
            else
            {
                state = "chain";
            }

            break;

        case "fall":
            this.playboard.FallPuyos();
            if (!playboard.is_falling)
            {
                Debug.Log(Time.time - this.fall_starttime);

                playboard.UpdateFieldPuyo();
                playboard.UpdateFieldBool();
                state = "chain";
                this.elapsed_erase_time = 0;
            }
            break;

        case "chain":
            this.elapsed_erase_time += Time.deltaTime;
            playboard.CheckErasePuyos();
            playboard.SetPuyoImages();

            if (playboard.is_erasing)     // ぷよを消せる。
            {
                if (this.elapsed_erase_time >= Configs.erase_time)
                {
                    playboard.ErasePuyos();
                    playboard.UpdateFieldPuyo();
                    playboard.UpdateFieldBool();
                    playscore.CalculateScore(playboard.eraseinfo_list);
                    playscore.AddChainnum();
                    playscore.UpdateText(playboard);

                    state = "check_fall";
                }
            }
            else
            {
                if (playboard.field_puyo[2, 11])
                {
                    state = "batan";
                }
                else
                {
                    state = "create";
                }
            }
            break;

        case "batan":
            //Debug.Log("batan kyu");
            break;
        }
        Debug.Log(state);
        playboard.ColorizeFalse();
    }