Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (pause)
        {
            input_after_pause = true;
            return;
        }


        if (stop_flag)
        {
            return;
        }

        Vector3 pos = transform.position;

        if (fall_flag)//落下中
        {
            //new ver
//            stop_flag = true;
            Vector3 Cubes_pos = transform.position;
            Cubes_pos.y -= fall_speed * Time.deltaTime;
//            transform.position = Cubes_pos;
            if (Cubes_pos.y <= -26 + fall_dist)  //落下完了
            {
                stop_flag   = true;
                Cubes_pos.y = -26 + fall_dist;
                //列削除確認
                Falled_Management.Check_Line();//列確認

                //GAME_OVER確認
                for (int n = 0; n < transform.childCount; n++)
                {
                    int[] _id = transform.GetChild(n).transform.GetComponent <Cube_Script>().get_fallen_id();
                    if (_id[1] >= 21)  //GAME_OVER
                    {
                        Debug.Log("GameOver!");
                        Canvas_Script.SetActive("Button_Title", true);
                        Canvas_Script.SetActive("Button_Again", true);
                        Canvas_Script.SetActive("Button_Pause", false);
                        Canvas_Script.SetActive("Text_Result", true);
                        Canvas_Script.SetActive("Text_Result_Label", true);
                        Canvas_Script.SetActive("Text_Gameover", true);


                        Text Score  = GameObject.FindGameObjectWithTag("Score").GetComponent <Text>();
                        Text Result = GameObject.FindGameObjectWithTag("Result").GetComponent <Text>();
                        Result.text = Score.text;
                        int score = int.Parse(Score.text);

                        Canvas_Script.SetActive("Text_Score", false);
                        Canvas_Script.SetActive("Text_Score_Label", false);
                        Canvas_Script.SetActive("Text_Highscore", false);
                        Canvas_Script.SetActive("Text_Highscore_Label", false);

                        int high_score = PlayerPrefs.GetInt(HIGH_SCORE, 0);
                        if (score > high_score)
                        {
                            PlayerPrefs.SetInt(HIGH_SCORE, score);
                        }



                        Instantiate(gameover_board);
                        Generate_Cube.generate = false;

                        return;
                    }
                }
            }
            transform.position = Cubes_pos;
        }
        else  //制御可能
        {
            pos.z -= slide_speed * Time.deltaTime;
            pos.y -= slide_speed * Mathf.Tan(Mathf.PI / 6) * Time.deltaTime;
            switch (Input_Manager())
            {
            case NO_INPUT:
                break;

            case SWIPE_RIGHT:
                Move_Right();
                break;

            case SWIPE_LEFT:
                Move_Left();
                break;

            case SWIPE_DOWN:
                Move_Down();
                return;

            case TOUCH:
                for (int n = 0; n < transform.childCount; n++)
                {
                    transform.GetChild(n).GetComponent <Cube_Script>().Clicked();
                }
                break;
            }


            if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                Move_Right();
            }
            if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                Move_Left();
            }
            if (pos.z < -10.1f)
            {
                pos.z     = -10.1f;
                fall_flag = true;
                //ここで落下ポジション決定する
                fall_dist = Determin_Fall(gameObject);//返り値が落ちる高さ


                Generate_Cube.generate = true;
            }
            if (transform.childCount == 0)
            {//全部削除された
                Generate_Cube.generate = true;
                Destroy(gameObject);
            }
            transform.position = pos;
        }
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        if (end)
        {
            if (fall_flag)//落下中
            {
                //new ver
                //            stop_flag = true;
                Vector3 Cubes_pos = transform.position;
                Cubes_pos.y -= fall_speed * Time.deltaTime;
                //            transform.position = Cubes_pos;
                if (Cubes_pos.y <= -26 + fall_dist)
                {//落下完了
                    stop_flag   = true;
                    Cubes_pos.y = -26 + fall_dist;
                    //列削除確認
                    Falled_Management.Check_Line();//列確認
                }
                transform.position = Cubes_pos;
            }
            return;//チュートリアル終了ブロック
        }
        if (tutorial_num == 0)
        {
            if (pause)
            {
                tutorial_text = GameObject.Find("Text_Tutorial").GetComponent <Text>();
                text_time    += Time.deltaTime;
                if (text_time < 3)
                {
                    tutorial_text.text = "ブロックは奥から出てくるよ";
                }
                else
                {
                    tutorial_text.text = "右にスワイプしてみよう!" + "\n" + "ブロックを右に動かせるよ";
                }
            }
            switch (Input_Manager())
            {
            case SWIPE_RIGHT:
                Move_Right();
                tutorial_text.text = "いいね!" + "\n" + "右に動かせたよ!";
                pause = false;
                break;
            }

            if (!pause)
            {
                Vector3 pos1 = transform.position;
                pos1.z -= slide_speed * Time.deltaTime;
                pos1.y -= slide_speed * Mathf.Tan(Mathf.PI / 6) * Time.deltaTime;

                if (pos1.z < -10.1f)
                {
                    pos1.z             = -10.1f;
                    fall_flag          = true;
                    tutorial_text.text = "ブロックは手前まで移動すると" + "\n" + "下に落ちるよ";
                    end = true;
                    //ここで落下ポジション決定する
                    fall_dist = Determin_Fall(gameObject);//返り値が落ちる高さ

                    tutorial_num           = 2;
                    Generate_Cube.generate = true;
                }
                transform.position = pos1;

                if (fall_flag)//落下中
                {
                    //new ver
                    //            stop_flag = true;
                    Vector3 Cubes_pos = transform.position;
                    Cubes_pos.y -= fall_speed * Time.deltaTime;
                    //            transform.position = Cubes_pos;
                    if (Cubes_pos.y <= -26 + fall_dist)
                    {//落下完了
                        stop_flag   = true;
                        Cubes_pos.y = -26 + fall_dist;
                        //列削除確認
                        Falled_Management.Check_Line();//列確認
                    }
                    transform.position = Cubes_pos;
                }


                if (transform.childCount == 0)
                {//全部削除された
                    Generate_Cube.generate = true;
                    Destroy(gameObject);
                }
            }
        }
        else if (tutorial_num == 2)
        {
            if (pause)
            {
                text_time    += Time.deltaTime;
                tutorial_text = GameObject.Find("Text_Tutorial").GetComponent <Text>();
                if (text_time > 2)
                {
                    pause = true;
                    tutorial_text.text = "次はブロックを削ってみよう!" + "\n" + "";
                }
                if (text_time > 4)
                {
                    tutorial_text.text = "ブロックをタッチすると" + "\n" + "削れるよ!";
                    switch (Input_Manager())
                    {
                    case TOUCH:
                        for (int n = 0; n < transform.childCount; n++)
                        {
                            transform.GetChild(n).GetComponent <Cube_Script>().Clicked();
                            text_time = 0;
                        }
                        break;
                    }
                }
            }
            else
            {
                tutorial_text = GameObject.Find("Text_Tutorial").GetComponent <Text>();
                text_time    += Time.deltaTime;
                if (text_time < 2)
                {
                    tutorial_text.text = "ナイス!" + "\n" + "これでブロックを操作して" + "\n" + "上手に落とそう!";
                }
                else
                {
                    tutorial_text.text = "削りすぎるとスコアが" + "\n" + "減るから気を付けてね";
                }
                if (!pause)
                {
                    Vector3 pos1 = transform.position;
                    pos1.z -= slide_speed * Time.deltaTime;
                    pos1.y -= slide_speed * Mathf.Tan(Mathf.PI / 6) * Time.deltaTime;

                    if (pos1.z < -10.1f)
                    {
                        pos1.z    = -10.1f;
                        fall_flag = true;
                        end       = true;
                        //ここで落下ポジション決定する
                        fall_dist = Determin_Fall(gameObject);//返り値が落ちる高さ

                        tutorial_num           = 4;
                        Generate_Cube.generate = true;
                    }
                    transform.position = pos1;

                    if (fall_flag)//落下中
                    {
                        //new ver
                        //            stop_flag = true;
                        Vector3 Cubes_pos = transform.position;
                        Cubes_pos.y -= fall_speed * Time.deltaTime;
                        //            transform.position = Cubes_pos;
                        if (Cubes_pos.y <= -26 + fall_dist)
                        {//落下完了
                            stop_flag   = true;
                            Cubes_pos.y = -26 + fall_dist;
                            //列削除確認
                            Falled_Management.Check_Line();//列確認
                        }
                        transform.position = Cubes_pos;
                    }


                    if (transform.childCount == 0)
                    {//全部削除された
                        Generate_Cube.generate = true;
                        Destroy(gameObject);
                    }
                }
            }
        }
        else if (tutorial_num == 4)
        {
            if (pause)
            {
                text_time    += Time.deltaTime;
                tutorial_text = GameObject.Find("Text_Tutorial").GetComponent <Text>();
                if (text_time > 4)
                {
                    tutorial_text.text = "下にスワイプしてみよう!" + "\n" + "ブロックをすぐに落とせるよ";
                    switch (Input_Manager())
                    {
                    case SWIPE_DOWN:
                        Move_Down();
                        tutorial_text.text = "ナイス!" + "\n" + "これで全ての操作だよ";
                        end       = true;
                        fall_flag = true;
                        Generate_Cube.generate = true;
                        fall_dist = Determin_Fall(gameObject);    //返り値が落ちる高さ

                        tutorial_num = 6;

                        return;
                    }
                }
                else if (text_time > 2)
                {
                    pause = true;
                    tutorial_text.text = "次が最後の操作だよ!" + "\n" + "";
                }
            }
        }
        else if (tutorial_num == 6)
        {
            tutorial_text = GameObject.Find("Text_Tutorial").GetComponent <Text>();
            text_time    += Time.deltaTime;
            if (text_time > 2)
            {
                tutorial_text.text = "さあ、本番を始めよう!";
                Tutorial_Canvas_Script.SetActive("Button_Start", true);
                PlayerPrefs.SetInt(TUTORIAL_KEY, TUTORIAL_DONE);
                Generate_Cube.tutorial = false;
            }
        }

        /*
         * if (pause)
         * {
         *  input_after_pause = true;
         *  return;
         * }
         *
         *
         * if (stop_flag)
         *  return;
         *
         * Vector3 pos = transform.position;
         * if (fall_flag)//落下中
         * {
         *  //new ver
         *  //            stop_flag = true;
         *  Vector3 Cubes_pos = transform.position;
         *  Cubes_pos.y -= fall_speed;
         *  //            transform.position = Cubes_pos;
         *  if (Cubes_pos.y <= -26 + fall_dist)
         *  {//落下完了
         *      stop_flag = true;
         *      Cubes_pos.y = -26 + fall_dist;
         *      //列削除確認
         *      Falled_Management.Check_Line();//列確認
         *
         *      //GAME_OVER確認
         *      for (int n = 0; n < transform.childCount; n++)
         *      {
         *          int[] _id = transform.GetChild(n).transform.GetComponent<Cube_Script>().get_fallen_id();
         *          if (_id[1] >= 21)
         *          {//GAME_OVER
         *              Debug.Log("GameOver!");
         *              Canvas_Script.SetActive("Button_Title", true);
         *              Canvas_Script.SetActive("Button_Again", true);
         *              Canvas_Script.SetActive("Button_Pause", false);
         *              Canvas_Script.SetActive("Text_Result", true);
         *              Canvas_Script.SetActive("Text_Result_Label", true);
         *              Canvas_Script.SetActive("Text_Gameover", true);
         *
         *
         *              Text Score = GameObject.FindGameObjectWithTag("Score").GetComponent<Text>();
         *              Text Result = GameObject.FindGameObjectWithTag("Result").GetComponent<Text>();
         *              Result.text = Score.text;
         *              int score = int.Parse(Score.text);
         *
         *              Canvas_Script.SetActive("Text_Score", false);
         *              Canvas_Script.SetActive("Text_Score_Label", false);
         *              Canvas_Script.SetActive("Text_Highscore", false);
         *              Canvas_Script.SetActive("Text_Highscore_Label", false);
         *
         *
         *
         *
         * //                        Instantiate(gameover_board);
         *              Generate_Cube.generate = false;
         *
         *              return;
         *
         *          }
         *      }
         *
         *  }
         *  transform.position = Cubes_pos;
         *
         *
         *
         *
         * }
         * else
         * {//制御可能
         *  pos.z -= slide_speed;
         *  pos.y -= slide_speed * Mathf.Tan(Mathf.PI / 6);
         *  switch (Input_Manager())
         *  {
         *      case NO_INPUT:
         *          break;
         *      case SWIPE_RIGHT:
         *          Move_Right();
         *          break;
         *      case SWIPE_LEFT:
         *          Move_Left();
         *          break;
         *      case SWIPE_DOWN:
         *          Move_Down();
         *          return;
         *      case TOUCH:
         *          for (int n = 0; n < transform.childCount; n++)
         *          {
         *              transform.GetChild(n).GetComponent<Cube_Script>().Clicked();
         *          }
         *          break;
         *  }
         *
         *
         *  if (Input.GetKeyDown(KeyCode.RightArrow))
         *      Move_Right();
         *  if (Input.GetKeyDown(KeyCode.LeftArrow))
         *      Move_Left();
         *  if (pos.z < -10.1f)
         *  {
         *      pos.z = -10.1f;
         *      fall_flag = true;
         *      //ここで落下ポジション決定する
         *      fall_dist = Determin_Fall(gameObject);//返り値が落ちる高さ
         *
         *
         *      Generate_Cube.generate = true;
         *  }
         *  if (transform.childCount == 0)
         *  {//全部削除された
         *      Generate_Cube.generate = true;
         *      Destroy(gameObject);
         *  }
         *  transform.position = pos;
         * }
         */
    }