IEnumerator ShowLaterMessage_()
    {
        TxtLaterMsg.text = MessageFetcher.GetLaterThatDayString();
        TxtLaterMsg.gameObject.SetActive(true);

        var col = TxtLaterMsg.color;

        for (float i = 0f; i < 1f; i += 0.1f)
        {
            TxtLaterMsg.color = new Color(col.r, col.g, col.b, i);
            yield return(new WaitForSeconds(0.1f));
        }

        yield return(new WaitForSeconds(2f));

        // move to the end position
        SetEndPositions_();

        for (float i = 1f; i >= 0f; i -= 0.1f)
        {
            TxtLaterMsg.color = new Color(col.r, col.g, col.b, i);
            yield return(new WaitForSeconds(0.1f));
        }

        TxtLaterMsg.color = new Color(col.r, col.g, col.b, 0);

        yield return(new WaitForSeconds(1));

        LaterFader.StartFade(1f, 0f, StartResults_);
    }
Exemplo n.º 2
0
        private async Task <List <string> > MessageStream(IAmazonS3 s3Client, string bucketName, string fileName, AmazonSQSClient sqsClient, AmazonSimpleNotificationServiceClient snsClient, string topicArn, CreateQueueRequest createQueueRequest)
        {
            List <string>   messageStream   = new List <string>();
            LocationChecker locationChecker = new LocationChecker();

            using MessageFetcher messageFetcher = new MessageFetcher(sqsClient, snsClient, topicArn, createQueueRequest);
            var           messages      = (await messageFetcher.FetchMessages(sqsClient, snsClient, topicArn, createQueueRequest)).ToList();
            MessageParser messageParser = new MessageParser();
            var           readings      = messages.Select(message => messageParser.ParseMessage(message));

            foreach (var reading in readings)
            {
                var messageX = @$ "
            Timestamp: {reading.Timestamp}
            Location ID: {reading.LocationId}
            Event ID: {reading.EventId}
            Value: {reading.Value}
            ";
                if (await locationChecker.CheckLocation(reading.LocationId, s3Client, bucketName, fileName))
                {
                    messageStream.Add(messageX);
                }
            }
            messageFetcher.Dispose();
            return(messageStream);
        }
    /// <summary>
    /// Sets the values of the burger
    /// </summary>
    /// <param name="customer">The complaints</param>
    /// <param name="tip">How much top was given</param>
    /// <param name="totalScore">Score achieved for this burger</param>
    /// <param name="playerIndex">Index of the player who made the burger</param>
    internal void Initialise(List <BurgerComplaint> complaints, int tip, int totalScore, int playerIndex, string customerName)
    {
        Sprite bread = null;

        _complaints = complaints;

        // display tip
        for (int i = 0; i < TipsRenderers.Length; i++)
        {
            TipsRenderers[i].gameObject.SetActive((tip) >= ((i + 1) * 10));
        }

        StarImage.sprite     = LicenseToGrillController.Instance.StarImages[((totalScore + 19) / 20)];
        ColourBar.color      = ColourFetcher.GetColour(playerIndex);
        TxtCustomerName.text = customerName;

        // display burger
        var index   = 0;
        var message = "";

        foreach (var item in complaints)
        {
            // add to the message
            if (message.Length > 0)
            {
                message += ", ";
            }
            message += (message.Length > 0) ? item.ErrorMessage().ToLower() : item.ErrorMessage();

            if (item.GetSprite() != null)
            {
                // if bread, add both parts
                if (item.ErrorMessage().ToLower().Contains("bread"))
                {
                    bread = LicenseToGrillController.Instance.BreadTop[item.GetSpriteIndex()];
                }

                // show the image
                ElementRenderers[index].sprite = item.GetSprite();

                ElementRenderers[index].color = item.GetColour();
                ElementRenderers[index].gameObject.SetActive(true);
                index++;
            }
        }

        // update message if flawless
        if (complaints.Count == 0)
        {
            message = MessageFetcher.GetPerfectBurgerMessage();
        }

        // format message
        TxtDescription.text = TextFormatter.GetBurgerReviewString(message);

        // show heading based on score
        TxtTitle.text = GetHeading_(totalScore);

        // add second part of bread
        if (bread)
        {
            // show the image
            ElementRenderers[index].sprite = bread;

            ElementRenderers[index].color = Color.white;
            ElementRenderers[index].gameObject.SetActive(true);
            index++;
        }

        // hide unused elements
        for (; index < ElementRenderers.Length; index++)
        {
            ElementRenderers[index].gameObject.SetActive(false);
        }
    }
    /// <summary>
    /// Reads out the jokes for current player - includes pauses
    /// </summary>
    IEnumerator CurrentPlayerReadJokes()
    {
        yield return(new WaitForSeconds(1));

        _endSpeed = 1f;

        // reset points
        TxtTotalPoints.text = "0";
        PnlTotalPoints.SetActive(true);

        // reset status
        _targetScore         = 0;
        _currentDisplayScore = 0;

        // if there are jokes to display
        if (_players[_resultsPlayerIndex].GetJokes().Count > 0)
        {
            // don't animate while telling jokes
            _players[_resultsPlayerIndex].SetAnimatorState(false);

            // loop through each joke
            foreach (var joke in _players[_resultsPlayerIndex].GetJokes())
            {
                // setup
                Speak(joke.Setup);
                yield return(new WaitForSeconds(4 * _endSpeed));

                // Pause
                HideSpeech();
                yield return(new WaitForSeconds(1 * _endSpeed));

                // punchline
                Speak(joke.Punchline);

                // add points
                var newPoints = UnityEngine.Random.Range(80, 120);
                _players[_resultsPlayerIndex].AddPoints(newPoints);

                yield return(new WaitForSeconds(2 * _endSpeed));

                // laugh
                StartCoroutine(DisplayLaughter());
                CrowdReact_(newPoints);

                _targetScore = _players[_resultsPlayerIndex].GetPoints();
                StartCoroutine(ShowNewPointsFlashUp(newPoints));
                yield return(new WaitForSeconds(2 * _endSpeed));

                // Pause
                HideSpeech();
                yield return(new WaitForSeconds(1 * _endSpeed));
            }
        }
        else
        {
            // no jokes for this player
            Speak("I got nothing...");
            yield return(new WaitForSeconds(2 * _endSpeed));
        }

        yield return(new WaitForSeconds(2 * _endSpeed));

        PnlTotalPoints.SetActive(false);

        if (_players[_resultsPlayerIndex].GetJokes().Count > 0)
        {
            // exit speech
            Speak(MessageFetcher.GetEndOfJokesString());
            yield return(new WaitForSeconds(3 * _endSpeed));
        }

        CrowdReactEnd_(_players[_resultsPlayerIndex].GetPoints());

        // walk off
        HideSpeech();
        yield return(new WaitForSeconds(1 * _endSpeed));

        // re-enable animation
        _players[_resultsPlayerIndex].SetAnimatorState(true);

        // finished
        _players[_resultsPlayerIndex].WalkOff(NextPlayerResults);
    }