protected override void BaseGameForm_Init(IGameControl sender, GameControlTimedEventArgs args) { this.AltSkins = null; this.ChildForms = new Dictionary<string, IGameForm>(); this.Controls = new Dictionary<string, IGameControl>(); this.CurrentSkin = null; this.DefaultSkin = null; this.Enabled = true; this.Focus = true; this.Location = Vector3.Zero; this.ParentForm = null; this.RenderColour = Vector4.One; this.RenderRectangle = Rectangle.Empty; this.Root = true; this.Shader = null; this.Visible = true; this.ElapsedTime = args.ElapsedTime; this.TotalTime = args.TotalTime; base.BaseGameForm_Init(sender, args); }
/// <summary> /// Default Update Event Handler /// </summary> protected virtual void BaseGameForm_Update(IGameControl sender, GameControlTimedEventArgs args) { //Focus this.Focus = (UI.FormWithFocus == this); ElapsedTime = args.ElapsedTime; TotalTime = args.TotalTime; //Update all controls at root level foreach (IGameControl control in Controls.Values) control.RaiseEvent(BaseControlEvents.Update, control, args); //update all child forms foreach (IGameForm form in ChildForms.Values) form.RaiseEvent(BaseControlEvents.Update, form, args); }
/// <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); }
protected override void BaseGameControl_Update(IGameControl sender, GameControlTimedEventArgs args) { float interval = args.TotalTime - lastblinktime; if (interval > 500) { lastblinktime = args.TotalTime; blink = !blink; } base.BaseGameControl_Update(sender, args); }