void OnCollisionEnter2D(Collision2D collision) { if (collision.collider.tag == "doorway" && !enteringDoorway) { standingInDoorway = true; messager.displayNewMessage(doorwayMessage); print("entering doorway"); } if (collision.collider.tag == "highScore" && !readingHighScore) { standingNearHighScore = true; messager.displayNewMessage(highScoreMessage); print("entering high score"); } if (collision.collider.tag == "levelListing" && !readingLevelListing) { standingNearLevelListing = true; messager.displayNewMessage(levelListingMessage); print("entering level listing"); } }
void UpdateMessager() { if (introIndex == 3) { AudioSource.PlayClipAtPoint(startSound, player.transform.position); } messager.displayNewMessage(introSequence[introIndex]); introIndex += 1; timeToShowNextMessage = false; currentMessageTimePassed = 0.0f; if (introIndex >= introSequence.Length) { EndIntroSequence(); } }
void DisplayWinMessage() { winMessageDisplayed = true; messager.displayNewMessage("All the resources are collected! Proceed upwards to the portal!"); Invoke("DeleteWinMessage", 5f); }
// Update is called once per frame void Update() { if (player == null) { player = FindObjectOfType <PlayerController>(); } if (isFull) { persent = 100; } if (decreasing && !LoseDetector.lost) { decreasePercent(); } if (color.Length != 4) { Debug.LogError("dont change Color array size, equale 4 !!!"); } d = (109f / 100f) * persent; centerBar.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, d); topBar.transform.localPosition = emptyTopPos + new Vector2(0, d); if (persent <= 0) { if (decreasing) { AudioSource.PlayClipAtPoint(loseSound, player.transform.position); } persent = 0; decreasing = false; LoseDetector.lost = true; bar.SetActive(false); fullBar.SetActive(false); player.gameObject.SetActive(false); loseDetector.ShowLosePanel(LoseDetector.LoseReason.resource); if (color.Length > 0 && color.Length < 5) { SetColor(color[3]); } } else if (persent > 0 && persent < 100) { bar.SetActive(true); fullBar.SetActive(false); if (d < 25 && color.Length > 0 && color.Length < 5) { SetColor(color[3]); } else if (persent > 25 && persent < 50 && color.Length > 0 && color.Length < 5) { SetColor(color[2]); } else if (persent > 50 && persent < 75 && color.Length > 0 && color.Length < 5) { SetColor(color[1]); } else if (persent > 75 && color.Length > 0 && color.Length < 5) { SetColor(color[0]); } } else if (persent >= 100 && !isFull) { bar.SetActive(false); fullBar.SetActive(true); decreasing = false; persent = 100; isFull = true; AudioSource.PlayClipAtPoint(fullBarSound, player.transform.position); if (color.Length > 0 && color.Length < 5) { SetColor(color[0]); } } if (isFull && !displayedFullMessage) //allows only one full bar message to display at a time. If a bar is full when another message is showing, the message will show afterwards { if (!messager.displayingMessage) { messager.displayNewMessage(gameObject.name + " is now full!"); Invoke("deleteFullBarMessage", 3f); displayedFullMessage = true; winDetector.numBarsFilled += 1; } } }