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; } }
// 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(); } } } } } } } }
bool EigoJudgement() { // 英単語が作れるかチェック CheckPotentialWords(EigoText); //英単語になったかの判定(2文字以上の時) bool judge = false; //英単語になったときの単語 string eigoword = "temp"; if (EigoText.Length >= 2) { string eigo = EigoText.ToLowerInvariant(); string query = "select word,mean from items where word ='" + eigo + "'"; DataTable dataTable = sqlDB.ExecuteQuery(query); TransText = ""; foreach (DataRow dr in dataTable.Rows) { judge = true; string word = (string)dr["word"]; string str = (string)dr["mean"]; eigoword = word; TransText += str; } if (judge == false) { //全て小文字にする string inStr = EigoText.ToLowerInvariant(); //1文字目を大文字で検索 TextInfo ti = CultureInfo.CurrentCulture.TextInfo; string outStr = ti.ToTitleCase(inStr); query = "select word,mean from items where word ='" + outStr + "'"; dataTable = sqlDB.ExecuteQuery(query); TransText = ""; foreach (DataRow dr in dataTable.Rows) { judge = true; string word = (string)dr["word"]; string str = (string)dr["mean"]; eigoword = word; TransText += str; } } if (judge == false) { //全て大文字にする string inStr = EigoText.ToUpperInvariant(); query = "select word,mean from items where word ='" + inStr + "'"; dataTable = sqlDB.ExecuteQuery(query); TransText = ""; foreach (DataRow dr in dataTable.Rows) { judge = true; string word = (string)dr["word"]; string str = (string)dr["mean"]; eigoword = word; TransText += str; } } } //除外英単語の時はjudge=falseにする if (judge) { for (int i = 0; i < ignore_word.Length; i++) { //Debug.Log("英単語:" + eigoword + "無視:" + ignore_word[i]); if (ignore_word[i].ToString() == eigoword) { judge = false; } } } //英単語になった時にボタンの色を変える if (judge) { btnFlg = ButtonFlg.EIGO; for (int i = 0; i < PuzzleDataList.Count; i++) { PuzzleDataList[i].GetComponent <BlockData>().ChangeBlock(true, true); } SelectEigoChange(); TransEigoText = eigoword; for (int i = 0; i < PuzzleDataList.Count(); i++) { PuzzleDataList[i].GetComponentInChildren <TextMesh>().GetComponent <EigoWordController>().scalingFlg = true; } } else if (EigoText.Length == 0) { btnFlg = ButtonFlg.NORMAL; } //英単語ではない else { TransText = ""; btnFlg = ButtonFlg.PRESSED; for (int i = 0; i < PuzzleDataList.Count; i++) { PuzzleDataList[i].GetComponent <BlockData>().ChangeBlock(true, false); } for (int i = 0; i < PuzzleDataList.Count(); i++) { PuzzleDataList[i].GetComponentInChildren <TextMesh>().GetComponent <EigoWordController>().scalingFlg = false; } } var button = EigoButton.GetComponent <Button>(); ButtonColorChange(button); return(judge); }
void Start() { /// <summary> /// StageFileの読み込み string filename = "stage" + SampleData.SceneNo.ToString(); stageMaker(filename); Text StageNoText = GameObject.Find("StageNoText").GetComponent <Text>(); StageNoText.text = "Stage " + SampleData.SceneNo.ToString(); // ステージのクリア条件 if (SampleData.SceneNo == 1) { StatusData = new StageStatus(2, 10); } else if (SampleData.SceneNo == 2) { StatusData = new StageStatus(3, 15); } else if (SampleData.SceneNo == 3) { StatusData = new StageStatus(3, 20); } StatusData.StatusUpdate(); ActiveBlockHeight = rowLength - DefaultBlockHeight; UnderArrowHeight = ActiveBlockHeight; // can_alphabetにパズルエリアのアルフェベットを格納 CheckPotentialPuzzle(); CanWordText = GameObject.Find("CanWordText").GetComponent <Text>(); CanWordText.text = ""; ///////////////// // 画面に表示されない縦数を見つける UnderArrow = GameObject.Find("UnderArrow"); // 猫救出ラインのGlassLineを見つける GlassLine = GameObject.Find("GlassLine"); Vector3 pos = new Vector3(0, GlassLineHeight + UnderArrowHeight * -BlockSize, -1); GlassLine.transform.localPosition = pos; BackPicture = GameObject.Find("BackPicture"); pos = new Vector3(0, GlassLineHeight + UnderArrowHeight * -BlockSize + 500, 100); BackPicture.transform.localPosition = pos; //無視英単語リストを設定する // テキストファイルから読み込んだデータ TextAsset textasset = new TextAsset(); //テキストファイルのデータを取得するインスタンスを作成 textasset = Resources.Load("ignore_word", typeof(TextAsset)) as TextAsset; //Resourcesフォルダから対象テキストを取得 string TextLines = textasset.text; //テキスト全体をstring型で入れる変数を用意して入れる //Splitで一行づつを代入した1次配列を作成 ignore_word = TextLines.Split('\n'); // //★ミッションの設定 StarData = new StarReword("ANIMAL", "[名]動物", "PEOPLE", "[名]人々", "CHECK", "[動]確認する"); //DBの設定 sqlDB = new SqliteDatabase("ejdict.sqlite3"); //GameObjectを探して格納 TransWindow = GameObject.Find("TransWindow"); TransWindow.SetActive(false); StartWindow = GameObject.Find("StartWindow"); StartWindow.SetActive(true); GameOverObj = GameObject.Find("GameOverText"); GameOverObj.GetComponent <Text>().text = ""; GameOverObj.SetActive(false); btnFlg = ButtonFlg.NORMAL; EigoText = ""; TransText = ""; // 音声ファイルを設定 soundTap = Resources.Load("SOUND/SE/cursor1", typeof(AudioClip)) as AudioClip; }