private void update_textbox() { if (initialize) { textbox = transform.FindChild("textbox"); textbox_background = textbox.FindChild("textbox_background"); for (int x = 0; x < TEXTBOX_WIDTH; x++) { for (int y = 0; y < TEXTBOX_HEIGHT; y++) { GameObject temp = (GameObject)Instantiate(letter_prefab, new Vector3(0, 0, 0), Quaternion.identity); Transform letter = temp.transform; letter.SetParent(textbox_background); letter.localScale = new Vector3(1.0f / (TEXTBOX_WIDTH + 2.0f), 1.0f / (TEXTBOX_HEIGHT + 2.0f), 1.0f); letter.localPosition = new Vector3(-0.5f + (x + 1) / (TEXTBOX_WIDTH + 2.0f) + letter.localScale.x * 0.5f, 0.5f - (y + 1) / (TEXTBOX_HEIGHT + 2.0f) - letter.localScale.y * 0.5f, -0.5f); letter_material[x, y] = letter.gameObject.GetComponent <Renderer>().material; letter_material[x, y].mainTextureScale = new Vector2(1.0f / 94.0f, 1.0f); letter_material[x, y].mainTextureOffset = new Vector2(0 / 94.0f, 0.0f); } } initialize = false; } textbox.localPosition = new Vector3(0.0f, -textbox_timer * camera_height * 2.0f, 0.0f); Vector3 background_position = textbox_background.localPosition; if (joystick_type == JOYSTICK_TYPE.SCREEN_PAD) { background_position.x = 0.0f; } else if (joystick_type == JOYSTICK_TYPE.VPAD_LEFT) { background_position.x = (arrow_right.localPosition.x + camera_width) * 0.5f; } else if (joystick_type == JOYSTICK_TYPE.VPAD_RIGHT) { background_position.x = (arrow_left.localPosition.x - camera_width) * 0.5f; } textbox_background.localPosition = background_position; /* * if (textbox_open == false) * { * if (MAP_MESSAGES.is_there_new_message()) * { * textbox_open = true; * textbox_timer = 1.0f; * for (int a = 0; a < MAP_MESSAGES.get_new_message_lines(); a++) * textbox_line[a] = MAP_MESSAGES.get_new_message_line(a); * for (int x = 0; x < TEXTBOX_WIDTH; x++) * for (int y = 0; y < TEXTBOX_HEIGHT; y++) * letter_material[x, y].mainTextureOffset = new Vector2(0 / 94.0f, 0.0f); * textbox_x = -1; * textbox_y = 0; * } * else * { * textbox_timer += Time.deltaTime * TEXTBOX_SPEED; * if (textbox_timer > 1.0f) textbox_timer = 1.0f; * } * } * else */ if (MAP_MESSAGES.is_there_new_message()) { textbox_open = true; textbox_timer = 1.0f; for (int a = 0; a < MAP_MESSAGES.get_new_message_lines(); a++) { textbox_line[a] = MAP_MESSAGES.get_new_message_line(a); } for (int x = 0; x < TEXTBOX_WIDTH; x++) { for (int y = 0; y < TEXTBOX_HEIGHT; y++) { letter_material[x, y].mainTextureOffset = new Vector2(0 / 94.0f, 0.0f); } } textbox_x = -1; textbox_y = 0; } else if (textbox_open == false) { textbox_timer += Time.deltaTime * TEXTBOX_SPEED; if (textbox_timer > 1.0f) { textbox_timer = 1.0f; } } if (textbox_open == true) { textbox_timer -= Time.deltaTime * TEXTBOX_SPEED; if (textbox_timer < 0.0f) { textbox_timer = 0.0f; } if (textbox_timer < 0.10f) { text_timer += Time.deltaTime; if (text_timer > 0.4f / TEXTBOX_SPEED) { textbox_x++; text_timer = 0.0f; if (textbox_x < textbox_line[textbox_y].Length && textbox_x < TEXTBOX_WIDTH) { //Debug.Log("textbox x,y="+textbox_x+","+textbox_y); int letter_value = (int)textbox_line[textbox_y][textbox_x] - 32; letter_material[textbox_x, textbox_y].mainTextureOffset = new Vector2(letter_value / 94.0f, 0.0f); //Debug.Log("printing new letter="+textbox_line[textbox_x]); } else { textbox_x = -1; textbox_y++; if (textbox_y > TEXTBOX_HEIGHT - 1) { textbox_y = TEXTBOX_HEIGHT - 1; } } } } if (MAP_MESSAGES.time_to_hide_message()) { textbox_open = false; } } }