Clock.Update C# (CSharp) Method

Update() public method

public Update ( ) : void
return void
    void Update()
    {
        //-- calculate time
        msecs += Time.deltaTime * clockSpeed;
        if(msecs >= 1.0f)
        {
        msecs -= 1.0f;
        seconds++;
        if(seconds >= 60)
        {
            seconds = 0;
            minutes++;
            if(minutes > 60)
            {
                minutes = 0;
                hour++;
                if(hour >= 24)
                    hour = 0;
            }
        }
        }

        //-- calculate pointer angles
        float rotationSeconds = (360.0f / 60.0f)  * seconds;
        float rotationMinutes = (360.0f / 60.0f)  * minutes;
        float rotationHours   = ((360.0f / 12.0f) * hour) + ((360.0f / (60.0f * 12.0f)) * minutes);

        //-- draw pointers
        pointerSeconds.transform.localEulerAngles = new Vector3(0.0f, 0.0f, rotationSeconds);
        pointerMinutes.transform.localEulerAngles = new Vector3(0.0f, 0.0f, rotationMinutes);
        pointerHours.transform.localEulerAngles   = new Vector3(0.0f, 0.0f, rotationHours);
    }

Usage Example

Beispiel #1
0
 public override void Update(Delta delta)
 {
     if (currentStatusEffectPartyMemberIndex < currentStatusEffectParty.Count)
     {
         if (currentStatusEffectParty[currentStatusEffectPartyMemberIndex].Alive)
         {
             PushState(new HandleStatusEffects(Battle, StatusEffectEvent.EndTurn, partyMember: currentStatusEffectParty[currentStatusEffectPartyMemberIndex]));
         }
         else
         {
             ++currentStatusEffectPartyMemberIndex;
         }
     }
     else if (currentStatusEffectParty == Battle.PlayerParty)
     {
         currentStatusEffectParty            = Battle.EnemyParty;
         currentStatusEffectPartyMemberIndex = 0;
     }
     else if (clockTime < clockHourTransistionTimeInSeconds)
     {
         clockTime += delta.Time;
         Clock.Update(delta.Time / clockHourTransistionTimeInSeconds);
     }
     else
     {
         Finish();
     }
 }
All Usage Examples Of Clock::Update