You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
3.8 KiB

7 years ago
  1. using UnityEngine;
  2. using System.Collections;
  3. using DentedPixel;
  4. public class GeneralUISpaceCS : MonoBehaviour {
  5. public RectTransform mainWindow;
  6. public RectTransform mainParagraphText;
  7. public RectTransform mainTitleText;
  8. public RectTransform mainButton1;
  9. public RectTransform mainButton2;
  10. public RectTransform pauseRing1;
  11. public RectTransform pauseRing2;
  12. public RectTransform pauseWindow;
  13. public RectTransform chatWindow;
  14. public RectTransform chatRect;
  15. public Sprite[] chatSprites;
  16. public RectTransform chatBar1;
  17. public RectTransform chatBar2;
  18. public UnityEngine.UI.Text chatText;
  19. public RectTransform rawImageRect;
  20. void Start () {
  21. // Time.timeScale = 1f/4f;
  22. // *********** Main Window **********
  23. // Scale the whole window in
  24. mainWindow.localScale = Vector3.zero;
  25. LeanTween.scale( mainWindow, new Vector3(1f,1f,1f), 0.6f).setEase(LeanTweenType.easeOutBack);
  26. LeanTween.alphaCanvas( mainWindow.GetComponent<CanvasGroup>(), 0f, 1f).setDelay(2f).setLoopPingPong().setRepeat(2);
  27. // Fade the main paragraph in while moving upwards
  28. mainParagraphText.anchoredPosition3D += new Vector3(0f,-10f,0f);
  29. LeanTween.textAlpha( mainParagraphText, 0f, 0.6f).setFrom(0f).setDelay(0f);
  30. LeanTween.textAlpha( mainParagraphText, 1f, 0.6f).setEase(LeanTweenType.easeOutQuad).setDelay(0.6f);
  31. LeanTween.move( mainParagraphText, mainParagraphText.anchoredPosition3D + new Vector3(0f,10f,0f), 0.6f).setEase(LeanTweenType.easeOutQuad).setDelay(0.6f);
  32. // Flash text to purple and back
  33. LeanTween.textColor( mainTitleText, new Color(133f/255f,145f/255f,223f/255f), 0.6f).setEase(LeanTweenType.easeOutQuad).setDelay(0.6f).setLoopPingPong().setRepeat(-1);
  34. // Fade button in
  35. LeanTween.textAlpha(mainButton2, 1f, 2f ).setFrom(0f).setDelay(0f).setEase(LeanTweenType.easeOutQuad);
  36. LeanTween.alpha(mainButton2, 1f, 2f ).setFrom(0f).setDelay(0f).setEase(LeanTweenType.easeOutQuad);
  37. // Pop size of button
  38. LeanTween.size(mainButton1, mainButton1.sizeDelta * 1.1f, 0.5f).setDelay(3f).setEaseInOutCirc().setRepeat(6).setLoopPingPong();
  39. // *********** Pause Button **********
  40. // Drop pause button in
  41. pauseWindow.anchoredPosition3D += new Vector3(0f,200f,0f);
  42. LeanTween.moveY( pauseWindow, pauseWindow.anchoredPosition3D.y + -200f, 0.6f).setEase(LeanTweenType.easeOutSine).setDelay(0.6f);
  43. // Punch Pause Symbol
  44. RectTransform pauseText = pauseWindow.Find("PauseText").GetComponent<RectTransform>();
  45. LeanTween.moveZ( pauseText, pauseText.anchoredPosition3D.z - 80f, 1.5f).setEase(LeanTweenType.punch).setDelay(2.0f);
  46. // Rotate rings around in opposite directions
  47. LeanTween.rotateAroundLocal(pauseRing1, Vector3.forward, 360f, 12f).setRepeat(-1);
  48. LeanTween.rotateAroundLocal(pauseRing2, Vector3.forward, -360f, 22f).setRepeat(-1);
  49. // *********** Chat Window **********
  50. // Flip the chat window in
  51. chatWindow.RotateAround(chatWindow.position, Vector3.up, -180f);
  52. LeanTween.rotateAround(chatWindow, Vector3.up, 180f, 2f).setEase(LeanTweenType.easeOutElastic).setDelay(1.2f);
  53. // Play a series of sprites on the window on repeat endlessly
  54. LeanTween.play(chatRect, chatSprites).setLoopPingPong();
  55. // Animate the bar up and down while changing the color to red-ish
  56. LeanTween.color( chatBar2, new Color(248f/255f,67f/255f,108f/255f, 0.5f), 1.2f).setEase(LeanTweenType.easeInQuad).setLoopPingPong().setDelay(1.2f);
  57. LeanTween.scale( chatBar2, new Vector2(1f,0.7f), 1.2f).setEase(LeanTweenType.easeInQuad).setLoopPingPong();
  58. // Write in paragraph text
  59. string origText = chatText.text;
  60. chatText.text = "";
  61. LeanTween.value(gameObject, 0, (float)origText.Length, 6f).setEase(LeanTweenType.easeOutQuad).setOnUpdate( (float val)=>{
  62. chatText.text = origText.Substring( 0, Mathf.RoundToInt( val ) );
  63. }).setLoopClamp().setDelay(2.0f);
  64. // Raw Image
  65. LeanTween.alpha(rawImageRect,0f,1f).setLoopPingPong();
  66. }
  67. }