private void open_message_box() { int current_message = 0; if (map.map_value(x, y + 1.0f) == 1) { current_message = 1; } else if (map.map_value(x, y + 1.0f) == 2) { current_message = 2; } else if (map.map_value(x, y + 1.0f) == 3) { current_message = 3; } if (current_message != last_message) { if (current_message == 0) { MAP_MESSAGES.HIDE_MESSAGE(last_message_id); } if (current_message == 1) { last_message_id = MAP_MESSAGES.SHOW_MESSAGE("TALO 1"); } if (current_message == 2) { last_message_id = MAP_MESSAGES.SHOW_MESSAGE("TALO 2"); } if (current_message == 3) { last_message_id = MAP_MESSAGES.SHOW_MESSAGE("TALO 3"); } if (current_message > 0) { Debug.Log("MAP_CHARACTER_SCRIPT: näytetään message " + current_message + " (id=" + last_message_id + ")"); } else { Debug.Log("MAP_CHARACTER_SCRIPT: piilotetaan message " + last_message_id); } last_message = current_message; } if (Input.GetKeyDown(KeyCode.Z)) { MAP_MESSAGES.HIDE_MESSAGE(); Debug.Log("piilotetaan mikä hyvänsä viesti"); } if (Input.GetKeyDown(KeyCode.X)) { int id = MAP_MESSAGES.SHOW_MESSAGE("TEST TEST"); Debug.Log("näytetään viesti (id=" + id + ")"); } }
private void talk_to_character() { Vector2 pos = new Vector2(0, 0); Vector2 size = new Vector2(0, 0); player.get_map_character_position(ref pos, ref size); sees_player = false; Vector2 seeing_point = new Vector2(x, y + 2 * RADIUS_Y); // looking up if (spritesheet_square_y == 1) { seeing_point = new Vector2(x, y - 2 * RADIUS_Y); // looking down } if (spritesheet_square_y == 2) { seeing_point = new Vector2(x - 2 * RADIUS_X, y); // looking left } if (spritesheet_square_y == 3) { seeing_point = new Vector2(x + 2 * RADIUS_X, y); // looking right } if (spritesheet_square_y == 0 || spritesheet_square_y == 1) // looking up or down { if (pos.x + size.x > seeing_point.x - 0.5f && pos.x - size.x < seeing_point.x + 0.5f && pos.y + size.y > seeing_point.y && pos.y - size.y < seeing_point.y) { sees_player = true; } } if (spritesheet_square_y == 2 || spritesheet_square_y == 3) // looking left or right { if (pos.x + size.x > seeing_point.x && pos.x - size.x < seeing_point.x && pos.y + size.y > seeing_point.y - 0.5f && pos.y - size.y < seeing_point.y + 0.5f) { sees_player = true; } } talk_timer += Time.deltaTime; if (sees_player && talk_id == -1 && talk_timer > 0.1f) { Debug.Log("REPLIIKKI!!! character pos=" + pos + " size=" + size + " sees=" + sees_player); if (sentence == 0) { talk_id = MAP_MESSAGES.SHOW_MESSAGE("HEI OLEN KYLAN", "AINOA IDIOOTTI.", "TAI ONHAN TOI", "NORSUKIN AIKA TYHMEA."); } if (sentence == 1) { talk_id = MAP_MESSAGES.SHOW_MESSAGE("POIS EESTA !!!!!!", "!!!!!!!!!!!"); } if (sentence == 2) { talk_id = MAP_MESSAGES.SHOW_MESSAGE("GOOD AFTERNOON. I AM", "PLEASE TO MEET YOU", "STRANGE GREEN MAN."); } if (sentence == 3) { talk_id = MAP_MESSAGES.SHOW_MESSAGE("OSAAN SANOA", "MONTA ERI ASIAA", "KOSKA OLEN AIKA", "SMART."); } sentence++; if (sentence > 3) { sentence = 0; } talk_timer = 0.0f; spritesheet_animation_timer = 0.0f; } if (!sees_player && talk_id != -1 && talk_timer > 0.5f) { MAP_MESSAGES.HIDE_MESSAGE(talk_id); talk_id = -1; talk_timer = 0.0f; } }