예제 #1
0
    public void PressEigoButton()
    {
        var button = EigoButton.GetComponent <Button>();

        CanWordText.text = "";

        if (btnFlg == ButtonFlg.PRESSED)
        {
            audioSource      = this.GetComponent <AudioSource>();
            audioSource.clip = soundCancel;
            audioSource.Play();

            EigoText = "";
            EigoButton.GetComponentInChildren <Text>().text = EigoText;
            SelectAllCanceled();
            btnFlg = ButtonFlg.NORMAL;

            ButtonColorChange(button);

            //ブロックデータリストをクリア
            PuzzleDataList.Clear();
        }
        else if (btnFlg == ButtonFlg.EIGO)
        {
            AudioSource a1;
            AudioClip   audio = Resources.Load("SOUND/SE/decision4", typeof(AudioClip)) as AudioClip;
            a1      = gameObject.AddComponent <AudioSource>();
            a1.clip = audio;
            a1.Play();

            // 和訳表示処理に移行
            GameFlg = GameLoopFlg.Translate;
        }
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        if (UnderArrowHeight == 0)
        {
            UnderArrow.SetActive(false);
        }
        else
        {
            // 画面に表示されない縦数を表示する
            UnderArrow.GetComponentInChildren <Text>().text = UnderArrowHeight.ToString();
        }

        // ゲーム開始前処理
        if (GameFlg == GameLoopFlg.StartInfo)
        {
            // スマホのタッチと、PCのクリック判定
            if (Input.GetMouseButtonDown(0))
            {
                StartWindow.SetActive(false);
                //Vector2 pos = new Vector2(0, -170);
                //TransWindow.transform.position = pos;

                // プレイ中処理に移行
                GameFlg = GameLoopFlg.PlayNow;
            }
            return;
        }
        // 和訳表示中処理
        else if (GameFlg == GameLoopFlg.Translate)
        {
            CanWordText.GetComponent <Text>().text = "";

            TransWindow.SetActive(true);

            Vector2   pos   = new Vector2(0, -580);
            Transform trans = GameObject.Find("UICanvas").GetComponent <Transform>();
            TransWindow.transform.SetParent(trans);
            TransWindow.transform.localPosition = pos;

            Text EngText = GameObject.Find("EngWord").GetComponent <Text>();
            EngText.GetComponent <Text>().text = TransEigoText;

            Text JapText = GameObject.Find("JapWord").GetComponent <Text>();

            // スペースを取り除く
            string str = TransText.Replace(" ", "").Replace(" ", "");

            //先頭から12行✕3列分の文字列を取得
            if (str.Length > 36)
            {
                str = str.Substring(0, 36);
            }

            JapText.GetComponent <Text>().text = str;

            var button = EigoButton.GetComponent <Button>();

            //スターリワードをチェック
            StarData.StarCheck(EigoText);

            StartCoroutine(BreakBlockCoroutine());

            if (isRunning == false)
            {
                StatusData.HandScoreUpdate(EigoText);

                //英語ボタンの文字を消す
                EigoText = "";
                EigoButton.GetComponentInChildren <Text>().text = EigoText;

                SelectEigoDestroy();

                btnFlg = ButtonFlg.NORMAL;

                // ブロック移動中処理に移行
                GameFlg   = GameLoopFlg.BlockMove;
                isRunning = true;

                ButtonColorChange(button);

                //ブロックデータリストをクリア
                PuzzleDataList.Clear();

                return;
            }
        }
        // ブロック移動中処理
        else if (GameFlg == GameLoopFlg.BlockMove)
        {
            // 救出済ねこがいない時、移動中のブロックがない時
            if (CheckBlockMove() == false)
            {
                // 和訳の表示をしない
                TransWindow.SetActive(false);

                if (DeathCat() == false)
                {
                    //SelectEigoDestroy();
                    if (CheckBlockSpace() == false)
                    {
                        GameFlg = GameLoopFlg.UndderArrow;
                    }
                }

                /*
                 * audioSource = this.GetComponent<AudioSource>();
                 * audioSource.clip = soundStar;
                 * audioSource.Play();
                 */
            }
        }
        // 地面の下にブロックがある時の処理
        else if (GameFlg == GameLoopFlg.UndderArrow)
        {
            while (UndderArrowCheck())
            {
            }

            GameFlg = GameLoopFlg.PlayBefore;
        }
        // ゲーム中処理に戻る前の処理
        else if (GameFlg == GameLoopFlg.PlayBefore)
        {
            // can_alphabetにパズルエリアのアルフェベットを格納
            CheckPotentialPuzzle();

            GameFlg = GameLoopFlg.PlayNow;
        }
        // ゲーム中処理
        else if (GameFlg == GameLoopFlg.PlayNow)
        {
            //ゲームクリア判定
            if (StatusData.Cat == 0)
            {
                // インステンシル広告を表示
                if (InAd)
                {
                    GameObject.Find("GameRoot").GetComponent <AdInterstitial>().ShowInterstitial();
                    InAd = false;
                }

                GameOverObj.GetComponent <Text>().text = "GameClear!!\n次のステージへ";
                GameOverObj.SetActive(true);
            }
            //ゲームーバー判定
            else if (StatusData.Hand == 0)
            {
                GameOverObj.GetComponent <Text>().text = "GameOver!!";
                GameOverObj.SetActive(true);
            }

            // スマホのタッチと、PCのクリック判定
            if (Input.GetMouseButtonDown(0))
            {
                Vector2    point       = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                Collider2D collition2d = Physics2D.OverlapPoint(point);

                BlockData blockData;

                // ここでRayが当たったGameObjectを取得できる
                if (collition2d)
                {
                    if (collition2d.tag == "Block")
                    {
                        blockData = collition2d.GetComponent <BlockData>();

                        if (blockData.blockType == BlockType.ALPHABET)
                        {
                            if (!blockData.Selected)
                            {
                                // プレイヤーがタップできるPuzzleDataのマスの高さ
                                if (blockData.Y >= ActiveBlockHeight)
                                {
                                    audioSource      = this.GetComponent <AudioSource>();
                                    audioSource.clip = soundTap;
                                    audioSource.Play();

                                    PuzzleDataList.Add(collition2d.gameObject);

                                    blockData.TapBlock();

                                    // ここでRayが当たったGameObjectを取得できる
                                    EigoText += blockData.Alphabet;
                                    EigoButton.GetComponentInChildren <Text>().text = EigoText;
                                    //                            Debug.Log(EigoText);

                                    //英単語になったかの判定
                                    bool judge = EigoJudgement();

                                    //英単語になった時
                                    if (judge)
                                    {
                                        btnFlg = ButtonFlg.EIGO;
                                        SelectEigoChange();
                                    }
                                    //英単語ではない
                                    else
                                    {
                                        btnFlg = ButtonFlg.PRESSED;
                                    }
                                    var button = EigoButton.GetComponent <Button>();
                                    ButtonColorChange(button);
                                }
                            }
                            else
                            {
                                int x = PuzzleDataList[PuzzleDataList.Count - 1].GetComponent <BlockData>().X;
                                int y = PuzzleDataList[PuzzleDataList.Count - 1].GetComponent <BlockData>().Y;

                                // 最後にタップしたブロックの選択を解除
                                if (blockData.X == x && blockData.Y == y)
                                {
                                    PuzzleDataList[PuzzleDataList.Count - 1].GetComponent <BlockData>().ChangeBlock(false, false);
                                    PuzzleDataList.RemoveRange(PuzzleDataList.Count - 1, 1);

                                    //末尾から1文字削除する
                                    EigoText = EigoText.Remove(EigoText.Length - 1, 1);
                                    EigoButton.GetComponentInChildren <Text>().text = EigoText;
                                    EigoJudgement();
                                }
                            }
                        }
                    }
                }
            }
        }
    }