Unity_Project/Assets/Scripts/FishMachine.cs
/* TODO: maybe put UpdateFishCondition inside ChangeState, since that is the only place it will likely ever be called */
/// <summary>
/// UpdateFishCondition takes one parameter - the state we are changing to. This function will update the 
/// fish's stats accordingly.
/// </summary>
/// <param name="to">The state the the fish will transition to</param>
UpdateFishCondition takes one parameter - the state we are changing to. This function will update the
fish's stats accordingly.
UpdateFishCondition takes one parameter - the state we are changing to . This function will update the fish ' s stats accordingly .
private void UpdateFishCondition(State to)
    {
        switch (to)
        {
            case State.FEEDING:
                if (feedingTimer == float.MaxValue)
                {
                    feedingIncrement = (1.0f - fullness) / 3.0f;
                    fullness += feedingIncrement;
                    feedingTimer = Time.time;
                }
                else if (fullness < 1.0f)
                {
                    fullness += feedingIncrement;
                }
                break;
            case State.SHY:
            case State.CURIOUS:
                if(pointingTimer == float.MaxValue) 
                {
                    pointingTimer = Time.time;
                    pointingIncrement = (1.0f - happiness) / 3.0f;
                    happiness += pointingIncrement;
                    fullness -= 0.1f;
                }
                else if(happiness < 1.0f) 
                {
                    happiness += pointingIncrement;
                    fullness -= 0.05f;
                }
                break;
            case State.DYING:
                happiness = initialHappiness;
                fullness = initialFullness;
                decayTimer = float.MaxValue; 
                break;
            case State.OPENING:
                decayTimer = Time.time;
                break;
        }
    }
private void UpdateFishCondition ( State to ) { switch ( to ) { case State . FEEDING : if ( feedingTimer == float . MaxValue ) { feedingIncrement = ( 1.0f - fullness ) / 3.0f ; fullness += feedingIncrement ; feedingTimer = Time . time ; } else if ( fullness < 1.0f ) { fullness += feedingIncrement ; } break ; case State . SHY : case State . CURIOUS : if ( pointingTimer == float . MaxValue ) { pointingTimer = Time . time ; pointingIncrement = ( 1.0f - happiness ) / 3.0f ; happiness += pointingIncrement ; fullness -= 0.1f ; } else if ( happiness < 1.0f ) { happiness += pointingIncrement ; fullness -= 0.05f ; } break ; case State . DYING : happiness = initialHappiness ; fullness = initialFullness ; decayTimer = float . MaxValue ; break ; case State . OPENING : decayTimer = Time . time ; break ; } }
UpdateFishCondition takes one parameter - the state we are changing to.
UpdateFishCondition takes one parameter - the state we are changing to .
//Eating makes the fish fuller, and if the fish is not overfull, then it will make the fish happier //Since fish should be fully fed after 3 sprinkles, take the remaining hunger and divide by 3 //Add the food to the fish's belly //Open the feeding window! //If the timer is running, then just add the food //Being pointed at makes the fish either shy or curious. Handle that by... //If the timer is STOPPED //...starting the timer... //...making Winsor happier and... //...expending a little energy //if the timer is running... //Just do the stat changes //When the fish is starting to "hibernate," reset its stats //decayTimer is set to its max value so that the timer does not //tick while the fish is unfolded //
to
State
The state the the fish will transition to
The state the the fish will transition to