// [[ ----- PURCHASE CHECKPOINT ----- ]] private void PurchaseCheckpoint() { // check if pc has enough ffs if (SceneMaster.active.FOwnedCount >= 3) { // PURCHASE CHECKPOINT AudioMaster.active.SoundEffect(AudioMaster.FXType.Checkpoint, 0); // deduct the ffs SceneMaster.active.UpdateFFCount(-3); // Make active checkpoint Checkpoint.OnCheckpointHit(gameObject.name); // reset ff pickups foreach (FireflyPickup ff in FireflyPickup.MasterList) { ff.SetActive(true); } // Unlock door SceneMaster.active.UnlockDoor(); } else { // display how many ffs required int ffreq = 3 - SceneMaster.active.FOwnedCount; popupText.SetText(noticeString1 + ffreq + noticeString2); popupText.PlayAnim(); } }
public void GenerateText(string text, Vector3 otherPos) { GameObject newTransform = CloseCallTxtPooler.GetPooledObject(); PopupText popup = newTransform.GetComponentInChildren <PopupText>(); popup.SetText(text); /*switch (num) * { * case 1: * popup.SetColor(new Color(250, 197, 28)); * break; * case 2: * popup.SetColor(new Color(251, 160, 38)); * break; * case 3: * popup.SetColor(new Color(243, 121, 52)); * break; * }*/ newTransform.transform.SetParent(aux.inGameCanvas.transform, false); /*Vector2 canvasPos; * Vector3 newPos = cam.WorldToScreenPoint(otherTransform.position); * RectTransformUtility.ScreenPointToLocalPointInRectangle(inGameCanvas.GetComponent<RectTransform>(), newPos, null, out canvasPos);*/ newTransform.transform.position = aux.WorldToUISpace(aux.inGameCanvas, otherPos); newTransform.transform.rotation = Quaternion.identity; newTransform.gameObject.SetActive(true); }
/// <summary> /// Creates the popup text. /// </summary> /// <param name="text">Text.</param> /// <param name="position">Position.</param> public static void CreatePopupText(string text, Vector3 position, Color color) { PopupText instance = Instantiate(_popupText); instance.transform.SetParent(_canvas.transform, false); instance.transform.position = position; instance.SetText(text, color); }
public void CreatePopupText(string text, Transform location) { PopupText popupText = Instantiate(Resources.Load <PopupText>("Prefabs/GUI/PopupTextParent")); Vector2 screenPosition = Camera.main.WorldToScreenPoint(location.position); popupText.transform.SetParent(canvas.transform, false); popupText.transform.position = new Vector2(screenPosition.x + Random.Range(-0.5f, 0.5f), screenPosition.y + Random.Range(-0.5f, 0.5f)); popupText.SetText(text); }
public static void CreatePopupText(string text, Transform transform) { PopupText instance = Instantiate(popupTextPrefab); Vector2 screenPosition = Camera.main.WorldToScreenPoint(transform.position); instance.transform.SetParent(canvas.transform, false); instance.transform.position = screenPosition; instance.SetText(text); }
public static void CreatePopup(string text, Vector3 position, Color color) { PopupText instance = Instantiate(staticPopup); Vector2 screenPos = Camera.main.WorldToScreenPoint(position); instance.transform.SetParent(canvas.transform, false); instance.transform.position = position; instance.SetText(text); instance.SetColor(color); }
public static void PopupText(string text, Transform attachTo) { PopupText textGameObject = Instantiate(popupText); textGameObject.SetText(text); // Set position textGameObject.transform.SetParent(canvas.transform, false); // Map 3d position of transform we are attaching to into flat camera/screen position textGameObject.transform.position = (Vector2)Camera.main.WorldToScreenPoint(attachTo.position); }
public static void CreateFloatingText(string text, Transform location) { PopupText instance = Instantiate(popupText); //Vector2 screenPosition = Camera.main.WorldToScreenPoint(new Vector2(location.position.x + Random.Range(-.5f,.5f), location.position.y + Random.Range(-.5f, .5f))); Vector2 screenPosition = Camera.main.WorldToScreenPoint(location.position); Debug.Log("X = " + screenPosition.x + ", Y = " + screenPosition.y); instance.transform.SetParent(canvas.transform, false); instance.transform.position = screenPosition; instance.SetText(text); }
public void Invoke() { foreach (Interaction interaction in interactions) { if (interaction.RequiredItemAction == inventory.SelectedItem) { string dialogText = null; if (interaction.MatchRequirements(ref dialogText)) { interaction.Action.Invoke(); } else { dialog.SetText(dialogText); dialog.ActivateForReadableTime(); } return; } } dialog.SetText("This does not make sense."); dialog.ActivateForReadableTime(); }
// Update is called once per frame void Update() { if (!Global.PauseEnemy.IsActive() && !Global.pause_game && !eating) { if (isSpawned) { roundedPosX = Mathf.Round(transform.position.x * 2.0f) / 2.0f; roundedPosY = Mathf.Round(transform.position.y * 2.0f) / 2.0f; if ((roundedPosX * 2 != matrix_x || roundedPosY * 2 != matrix_y) && ((direction == 0 && transform.position.x < roundedPosX) || (direction == 1 && transform.position.x > roundedPosX) || (direction == 2 && transform.position.y > roundedPosY) || (direction == 3 && transform.position.y < roundedPosY))) { //get level matrix coordinates matrix_x = Mathf.RoundToInt(roundedPosX * 2.0f); matrix_y = Mathf.RoundToInt(roundedPosY * 2.0f); //get enemy pos from coordinates enemy_pos = Global.levelmatrix [matrix_y, matrix_x]; if (enemy_pos > 1) { transform.position = new Vector3(roundedPosX, roundedPosY, 0); } //fix enemy position when go out of playground if (enemy_pos == -1) { fix_enemy_pos(matrix_x, matrix_y); } //fix direction if (enemy_pos == 0 && (direction == 2 || direction == 3)) { direction = 0; if (animation_type == 1) { transform.localEulerAngles = new Vector3(0, 0, 90); } } else if (enemy_pos == 1 && (direction == 0 || direction == 1)) { direction = 2; if (animation_type == 1) { transform.localEulerAngles = new Vector3(0, 0, 0); } } //move back if the enemy go out of camera view if (transform.position.y > camera.transform.position.y + Global.view_range_top && enemy_pos != 0 && enemy_pos != 2 && enemy_pos != 3 && enemy_pos != 7 && enemy_pos != 11) { direction = 3; if (animation_type == 1) { transform.localEulerAngles = new Vector3(0, 0, 180); } } else if (isAlly && transform.position.y < camera.transform.position.y + Global.view_range_bottom + 1.0f && enemy_pos != 0 && enemy_pos != 6 && enemy_pos != 4 && enemy_pos != 5 && enemy_pos != 11) { direction = 2; if (animation_type == 1) { transform.localEulerAngles = new Vector3(0, 0, 0); } } //determine enemy's moving direction else { if (enemy_pos > 1) { if (Global.classic && ( enemy_type < 2 || enemy_type == 2 && Vector3.Distance(transform.position, pock_man.position) > 2.85f || enemy_type == 3 && Vector3.Distance(transform.position, pock_man.position) > 5.55f) || (enemy_type == 5 && Vector3.Distance(transform.position, new Vector3(camera.position.x, camera.position.y + 2.5f, camera.position.z)) > 3.55f)) { switch (enemy_type) { case 0: searchAI.search(matrix_x, matrix_y, (Math.Abs(pac_script.back_x - pock_man.position.x * 2) < Math.Abs(pac_script.front_x - pock_man.position.x * 2) ? pac_script.back_x : pac_script.front_x), ((Math.Abs(pac_script.back_y - pock_man.position.y * 2) < Math.Abs(pac_script.front_y - pock_man.position.y * 2) ? pac_script.back_y : pac_script.front_y))); break; case 1: searchAI.search(matrix_x, matrix_y, pac_script.front_x, pac_script.front_y); break; case 2: searchAI.search(matrix_x, matrix_y, pac_script.front_x, pac_script.front_y, 4); break; case 3: searchAI.search(matrix_x, matrix_y, 4, pac_script.front_y, 8); break; case 5: searchAI.search(matrix_x, matrix_y, (int)(camera.position.x * 2.0f), (int)(camera.position.y * 2.0f) + 5, 5); break; } if (searchAI.NextWayX() > matrix_x) { direction = 1; } else if (searchAI.NextWayX() < matrix_x) { direction = 0; } else if (searchAI.NextWayY() > matrix_y) { direction = 2; } else if (searchAI.NextWayY() < matrix_y) { direction = 3; } else { if (direction < 2) { if ((int)(pock_man.position.y * 2.0f) > matrix_y) { direction = 2; } else if ((int)(pock_man.position.y * 2.0f) < matrix_y) { direction = 3; } } else { if ((int)(pock_man.position.x * 2.0f) > matrix_x) { direction = 1; } else if ((int)(pock_man.position.x * 2.0f) < matrix_x) { direction = 0; } } } setRotation(); } else { determine_direction(); } } } //change enemy's sprite if (!Global.Invertibility.IsActive()) { if (animation_type == 0) { current_sprite.sprite = sprites [direction + ally_sprite]; } } //deactivate enemy at top of level if (!Global.classic && matrix_y > Global.level_height - 8) { Global.enemies.Remove(this); Destroy(gameObject); } } if (Global.controll_type == 0 && !isAlly && !Global.Invertibility.IsActive() && Vector3.Distance(transform.position, pock_man.position) < 2.0f) { if (matrix_y == (int)(pock_man.position.y * 2.0f)) { if ((pac_script.getDirection == 0 && transform.position.x > pock_man.position.x) || (pac_script.getDirection == 1 && transform.position.x < pock_man.position.x)) { pac_script.setBehindEnemy = true; Debug.Log("Enemy behind horizontal"); } } else if (matrix_x == (int)(pock_man.position.x * 2.0f)) { if ((pac_script.getDirection == 2 && transform.position.y < pock_man.position.y) || (pac_script.getDirection == 3 && transform.position.y > pock_man.position.y)) { pac_script.setBehindEnemy = true; Debug.Log("Enemy behind vertical"); } } } //invertibility time section if (Global.Invertibility.IsActive()) { if (!invertibility) { invertibility = true; invTime = 100; } //enemy sprite will be blue if invertibility is active and change lower speed if (Global.Invertibility.TimeRemaining > 2.0f) { if (animation_type == 0) { current_sprite.sprite = sprites [direction + 4]; } else { current_sprite.sprite = sprites [1]; } speed = 0.8f; } else { if (invTime / 20 % 2 == 0) { if (animation_type == 0) { current_sprite.sprite = sprites [direction + 4]; } else { current_sprite.sprite = sprites [1]; } } else { if (animation_type == 0) { current_sprite.sprite = sprites [direction + 8]; } else { current_sprite.sprite = sprites [2]; } } invTime--; } } else if (invertibility) { speed = (Global.classic ? Global.enemy_speed : Global.enemy_speed * 0.8f); if (animation_type < 5) { current_sprite.sprite = sprites [ally_sprite]; } invertibility = false; } //ally activation section if (isAlly) { if (Time.timeSinceLevelLoad - allyTime > 10.0f) //end of ally { deconvertFromAlly(); } else if (Time.timeSinceLevelLoad - allyTime > 7.0f) { if (allyAnim / 20 % 2 == 0) { setAllySprite(true); } else { setAllySprite(false); } allyAnim--; } } //die enemy in case of going out of camera view (in rush mode only) if (!Global.classic && transform.position.y < camera.transform.position.y + Global.view_range_bottom) { Global.enemies.Remove(this); Destroy(gameObject); } //move of enemy if (animation_type == 0 || animation_type == 2) { if (direction == 0) { transform.Translate(-speed * Time.deltaTime, 0, 0); } else if (direction == 1) { transform.Translate(speed * Time.deltaTime, 0, 0); } else if (direction == 2) { transform.Translate(0, speed * Time.deltaTime, 0); } else if (direction == 3) { transform.Translate(0, -speed * Time.deltaTime, 0); } } else { transform.Translate(0, speed * Time.deltaTime, 0); } //collision of enemy if (!isAlly && !Global.PauseEnemy.IsActive() && !pac_script.dead && isSpawned && Vector2.Distance(transform.position, pock_man.position) < 0.25f) { //enemy kills the player if (!Global.Invertibility.IsActive()) { pac_script.anim.SetBool("dead", true); pac_script.dead = true; Global.pause_game = true; //invertibility enabled } else { Global.score += pac_script.ghost_combo; //show total ghost combo if (pac_script.ghost_combo == 250) { pock_man.GetComponentInChildren <manage_pickups>().activate_rate_text("Total ghost combo!"); } //set and show ghost combo title GhostComboPopup.Activate(3.0f); GhostComboPopup.SetText("+" + pac_script.ghost_combo.ToString()); Transform new_dead = (Transform)Instantiate(enemy_dead, transform.position, Quaternion.identity); new_dead.position = transform.position; new_dead.gameObject.SetActive(true); pac_script.ghost_combo += 50; Global.enemies.Remove(this); Destroy(gameObject); if (Global.classic) { killSpecialEnemy(); } } } } else { if (Time.timeSinceLevelLoad - spawnTime > 2.0f) { isSpawned = true; } count_down--; //animatoin of enemy respawning if (animation_type == 0) { current_sprite.sprite = sprites[12 + (count_down / 5 % 4)]; } else { current_sprite.sprite = sprites[3 + (count_down / 5 % 4)]; } //deactivation at end of level /*if (count_down < -8) { * count_down = 0; * Global.enemies.Remove(gameObject); * Destroy(gameObject); * }*/ if (isSpawned) { if (animation_type == 0) { current_sprite.sprite = sprites[direction]; } else { current_sprite.sprite = sprites[0]; } } } } if (eating && Time.timeSinceLevelLoad - eatTime > 1.5f) { eating = false; } }
// Update is called once per frame void Update() { if (Global.global_points > 2000 && Global.Ammo.Level == 1 && Global.Thunder.Level == 1 && Global.Mine.Level == 1 && Global.Magneton.Level == 1) { if (!main_text_active) { setActiveTutorialText(true); main_text.text = language_Manager.GetTextByValue("Tutorial11"); upgrade_btn.color = red; } } else if (Global.global_stars > 25 && Global.global_stars < 31) { if (Global.level_menu == 3 || Global.level_menu == 4) { if (Global.own_cards[0] != -1 && tutorial_frame == 0) { tutorial_frame = 1; } if (tutorial_frame > 0 && tutorial_frame < 10) { if (!TutorialText.isActive()) { if (tutorial_frame == 1) { own_place.color = red; TutorialText.SetText(language_Manager.GetTextByValue("Tutorial1")); back_btn.SetActive(false); DropText.gameObject.SetActive(false); } else if (tutorial_frame == 2) { TutorialText.SetText(language_Manager.GetTextByValue("Tutorial2")); } else if (tutorial_frame == 3) { TutorialText.SetText(language_Manager.GetTextByValue("Tutorial3")); } else if (tutorial_frame == 4) { TutorialText.SetText(language_Manager.GetTextByValue("Tutorial4")); } else if (tutorial_frame == 5) { own_place.color = white; drop_btn1.color = red; drop_btn2.color = red; drop_btn3.color = red; TutorialText.SetText(language_Manager.GetTextByValue("Tutorial5")); } else if (tutorial_frame == 6) { drop_btn1.color = white; drop_btn2.color = white; drop_btn3.color = white; free_card_text.color = red; TutorialText.SetText(language_Manager.GetTextByValue("Tutorial6")); } else if (tutorial_frame == 7) { TutorialText.SetText(language_Manager.GetTextByValue("Tutorial7")); } else if (tutorial_frame == 8) { TutorialText.SetText(language_Manager.GetTextByValue("Tutorial8")); } else if (tutorial_frame == 9) { DropText.gameObject.SetActive(true); back_btn.SetActive(true); } if (tutorial_frame < 9) { TutorialText.ActivateForReadableTime(); } tutorial_frame++; } } } else if ((Global.level_menu == 1 || Global.level_menu == 2) && !main_text_active) { setActiveTutorialText(true); main_text.text = language_Manager.GetTextByValue("Tutorial10"); dropping_btn.color = red; } } else if (main_text_active) { setActiveTutorialText(false); upgrade_btn.color = orange; } }
//appearing rate text public void activate_rate_text(string title) { RateText.SetText(title); RateText.Activate(3.0f); }