GameTimeEvent.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // GameTimeEvent.cs
  4. //
  5. // Microsoft XNA Community Game Platform
  6. // Copyright (C) Microsoft Corporation. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #endregion
  9. #region Using Statements
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Text;
  13. using Microsoft.Xna.Framework;
  14. using Microsoft.Xna.Framework.Graphics;
  15. using RobotGameData;
  16. #endregion
  17. namespace RobotGameData.GameEvent
  18. {
  19. /// <summary>
  20. /// When the set time is passed, this event gets executed.
  21. /// </summary>
  22. public class GameTimeEvent : GameEventBase
  23. {
  24. #region Fields
  25. protected float actionTime = 0.0f; // action execute time
  26. #endregion
  27. #region Properties
  28. public float ActionTime
  29. {
  30. get { return actionTime; }
  31. }
  32. public bool IsExecuteAction()
  33. {
  34. return (localTime >= actionTime);
  35. }
  36. #endregion
  37. /// <summary>
  38. /// Constructor.
  39. /// </summary>
  40. /// <param name="type">event type</param>
  41. /// <param name="time">event execute time</param>
  42. /// <param name="owner">event owner</param>
  43. /// <param name="visibledOwner">owner visible flag</param>
  44. public GameTimeEvent(float time, GameSceneNode owner, bool visibledOwner)
  45. {
  46. SetAction(time, owner, visibledOwner);
  47. }
  48. public void SetAction(float time, GameSceneNode owner, bool visibledOwner)
  49. {
  50. this.actionTime = time;
  51. this.owner = owner;
  52. this.owner.Enabled = false;
  53. this.owner.Visible = visibledOwner;
  54. }
  55. public override void ExecuteAction()
  56. {
  57. this.owner.Reset(true);
  58. this.owner.Enabled = true;
  59. this.owner.Visible = true;
  60. waitingAction = false;
  61. finishedAction = true;
  62. }
  63. }
  64. }