void Start() { messagesQueue = new Queue <MessagePiece>(); fade = GetComponent <MessageFade>(); fade.OnFinishFade += DequeueMessage; messages = new string[3][]; messages[0] = new string[1] { "Relax, you cannot die..." }; messages[1] = new string[2] { "Darkness is not safe...", "Try light" }; switch (Random.Range(0, 7)) { case 0: messages[2] = new string[] { "My wife just dumped me...", "She wasn't pretty, though." }; break; case 1: messages[2] = new string[] { "Do you see that whale?", "It reminds me my wife." }; break; case 2: messages[2] = new string[] { "I want to be like James Cameron, you know...", "Could I find the Titanic down here?" }; break; case 3: messages[2] = new string[] { "And let us do that again...", "Oh schnaps, again?" }; break; case 4: messages[2] = new string[] { "Yeah, I have father issues." }; break; case 5: messages[2] = new string[] { "As Quorthon used to say...", "It is a fine day to die." }; break; case 6: messages[2] = new string[] { "Let's do it, player. Yahooooooo" }; break; } int deaths = PlayerPrefs.GetInt("StartingText", 0); if (deaths < 2) { PlayerPrefs.SetInt("StartingText", deaths + 1); } float fIn = 1.5f; float fOut = 0.5f; for (int i = 0; i < messages[deaths % messages.Length].Length; i++) { messagesQueue.Enqueue(new MessagePooler.MessagePiece { message = messages[deaths][i], fadeIn = fIn, time = 3f, fadeOut = fOut }); fIn = 0.5f; } if (messagesQueue.Count > 0) { fade.ShowMessage(messagesQueue.Dequeue()); } }
// Use this for initialization void Start() { messagesQueue = new Queue <MessagePooler.MessagePiece>(); speeches = new string[7][]; speeches[0] = new string[] { "I will build a net all over the sea...", "and make the shrimps pay for it" }; speeches[1] = new string[] { "Orange is the new black." }; speeches[2] = new string[] { "Make the sea great again!" }; speeches[3] = new string[] { "Happy Global Game Jam to all, including to my...", " sleep that have fought me and lost so badly they just don’t know what to do. Love!" }; speeches[4] = new string[] { "The beauty of me is that I’m very orange." }; speeches[5] = new string[] { "It’s freezing and snowing in Vancouver – we need global warming!" }; speeches[6] = new string[] { "You're disgusting!" }; rb = GetComponent <Rigidbody2D>(); Player = GameObject.FindGameObjectWithTag("Player").transform; rb.AddForce(new Vector2(Random.Range(-0.1f, 0.1f), Random.Range(-0.1f, 0.1f)), ForceMode2D.Impulse); anim = GetComponent <Animator>(); messenger = GetComponentInChildren <MessageFade>(); messenger.OnFinishFade += DequeueMessage; madeHisPoint = false; }