Exemplo n.º 1
0
        /* Happiness */

        private void UpdateHappinessTimedData(object sender, ElapsedEventArgs e)
        {
            TimeSpan timeHappinessElapsed = e.SignalTime - timeKeeperHappiness.StartTime;

            HappinessState newHappinessState = happiness.CurrentHappinessState;

            /* Timer statement to display state */

            if (timeHappinessElapsed.TotalSeconds < 20)
            {
                newHappinessState = HappinessState.good;
                HappinessProgressBar.ProgressTo(1, 900, Easing.Linear);
            }
            else if (timeHappinessElapsed.TotalSeconds < 30)
            {
                newHappinessState = HappinessState.bad;
                HappinessProgressBar.ProgressTo(0.5, 900, Easing.Linear);
            }
            else if (timeHappinessElapsed.TotalSeconds >= 40)
            {
                newHappinessState = HappinessState.worse;
                HappinessProgressBar.ProgressTo(0.1, 900, Easing.Linear);
            }

            /* Update state */

            if (newHappinessState != happiness.CurrentHappinessState)
            {
                happiness.CurrentHappinessState = newHappinessState;
                updateHappinessUI();
            }
        }
Exemplo n.º 2
0
    public static HappinessState GetHappinessStateFromValue(float happiness)
    {
        HappinessState result = HappinessState.Neutral;

        if (happiness > 0.25f)
        {
            result = HappinessState.Happy;
        }
        else if (happiness < -0.25f)
        {
            result = HappinessState.Unhappy;
        }
        return(result);
    }
Exemplo n.º 3
0
        public static string GetHappinessString(HappinessState happinessState)
        {
            switch (happinessState)
            {
            case HappinessState.good:
                return("good");

            case HappinessState.bad:
                return("bad");

            case HappinessState.worse:
                return("worse");

            default:
                return("good");
            }
        }
Exemplo n.º 4
0
    private void UpdateFaceSprite()
    {
        HappinessState happinessState = HappinessUtils.GetHappinessStateFromValue(happiness);

        Sprite currentSprite = neutralFace;

        switch (happinessState)
        {
        case HappinessState.Happy:
            currentSprite = happyFace;
            break;

        case HappinessState.Unhappy:
            currentSprite = sadFace;
            break;
        }

        faceRenderer.sprite = currentSprite;
    }
Exemplo n.º 5
0
    private float GetHappinessSize(float happiness)
    {
        HappinessState happinessState = HappinessUtils.GetHappinessStateFromValue(happiness);

        float result = sizeNeutral;

        switch (happinessState)
        {
        case HappinessState.Happy:
            result = sizeHappy;
            break;

        case HappinessState.Unhappy:
            result = sizeUnhappy;
            break;
        }

        return(result);
    }
Exemplo n.º 6
0
    private Color GetHappinessColor(float happiness)
    {
        HappinessState happinessState = HappinessUtils.GetHappinessStateFromValue(happiness);

        Color result = uiNeutralColor;

        switch (happinessState)
        {
        case HappinessState.Happy:
            result = uiHappyColor;
            break;

        case HappinessState.Unhappy:
            result = uiUnhappyColor;
            break;
        }

        return(result);
    }