Пример #1
0
        /// <summary>
        /// Do this in addiition to the main update.
        /// </summary>
        protected override void BaseGameControl_Update(IGameControl sender, GameControlTimedEventArgs args)
        {
            //First update
            if (LastSwitchTime == 0)
            {
                LastSwitchTime = (int)args.TotalTime;
                CurrentcreditIndex = 0;

                CurrentCredit = mCredits[CurrentcreditIndex];
                NextCredit = mCredits[(CurrentcreditIndex + 1) % mCredits.Count];
            }

            //All updates
            if (mCredits != null && mCredits.Count > 0)
            {
                //time to next switch is delay time - time since last switch
                int timeToSwitch = CurrentCredit.Delay - ((int)args.TotalTime - LastSwitchTime);

                if (timeToSwitch > 0)
                {
                    //If in last 2 seconds, apply fade
                    if (timeToSwitch < 4001)
                        CurrentFadeLevel = (float)timeToSwitch / 4000.0f;
                    else
                        CurrentFadeLevel = 1.0f;
                }
                else //Switch
                {
                    //Set credit and next credit.
                    CurrentFadeLevel = 1.0f;
                    CurrentcreditIndex = (CurrentcreditIndex + 1) % mCredits.Count;
                    CurrentCredit = mCredits[CurrentcreditIndex];
                    NextCredit = mCredits[(CurrentcreditIndex + 1) % mCredits.Count];
                    LastSwitchTime = (int)args.TotalTime;
                }
            }

            //Do the base update
            base.BaseGameControl_Update(sender, args);
        }
Пример #2
0
 /// <summary>
 /// Add a new credit to the fader.
 /// </summary>
 /// <param name="gc">The credit to add</param>
 public void AddCredit(GameCredit gc)
 {
     mCredits.Add(gc);
 }