public void Initialize(string a_text, SPEAKER_TYPE a_speaker) { string temp_speakerPrefix = null; if (a_speaker == SPEAKER_TYPE.PLAYER) { temp_speakerPrefix = GameObject.Find("Player").GetComponent<PlayerStats>().playerName; GetComponent<Image>().color = UnityEngine.Color.cyan; } else if (a_speaker == SPEAKER_TYPE.IMOUTO) { temp_speakerPrefix = GameObject.Find("Object_Imouto").GetComponent<ImoutoObject>().imoutoName; GetComponent<Image>().color = UnityEngine.Color.magenta; } // Make the message box transparent Color c = GetComponent<Image>().color; GetComponent<Image>().color = new Color(c.r, c.g, c.b, 0.4f); // Set text of the chat bubble GetComponentInChildren<Text>().text = temp_speakerPrefix + "\n\t" + a_text; SetTransforms(); StartCoroutine(Wait()); }
/// <summary> /// コンストラクタ /// </summary> public Speach( string text // セリフのテキストデータ ) { // セリフのテキストデータ this.text = text; // 発声者タイプの読み込み this.speakerType = (SPEAKER_TYPE)ReadType(typeof(SPEAKER_TYPE)); // コメントタイプの設定 switch (this.speakerType) { case SPEAKER_TYPE.SYSTEM: this.commentType = COMMENT_TYPE.SYSTEM_MESSAYGE; break; default: this.commentType = COMMENT_TYPE.CHARA_SPEACH; break; } // 発声者名の設定 switch (this.speakerType) { case SPEAKER_TYPE.PLAYER: this.speakerName = "プレイヤー"; break; case SPEAKER_TYPE.COMMANDER: this.speakerName = "指令キャラ"; break; case SPEAKER_TYPE.ENEMY: this.speakerName = "敵"; break; default: this.speakerName = ""; break; } // イベント番号の読み込み this.iventNumber = ReadNumber(); // 寿命の設定 // // キャラのセリフは数秒で自動消滅、システムメッセージは無制限。 // if ( (int)SPEAKER_TYPE.SYSTEM > (int)this.speakerType ) this.lifeTime = 2.0f; // else this.lifeTime = -1; this.lifeTime = -1; triggerFlg = false; isFinished = false; differentialTimeCounter = 0; }
public void AddChatBubble(string a_text, SPEAKER_TYPE a_spt) { GameObject temp_chatBubble = Instantiate(Resources.Load("Textbubble") as GameObject); temp_chatBubble.GetComponent<ChatBubbleScript>().Initialize(a_text, a_spt); temp_chatBubble.GetComponentInChildren<SetNumber>().SetTextNumber(numMessages++); if (transform.childCount > maxMessages) { Destroy(transform.GetChild(0).gameObject); } // Ensure that the player's chat bubble appears before the game begins processing imouto's response if (a_spt == SPEAKER_TYPE.PLAYER) { GameObject.Find("Object_Imouto").GetComponent<ImoutoObject>().Respond(a_text); } }