Exemplo n.º 1
0
        public Form1(Game game, KeyHandler handler, User user)
        {
            this.Game    = game;
            this.handler = handler;
            this.user    = user;

            #region - Add custom methods to the existing Paint event
            // Add the methods to the event
            this.Paint += DrawTerrain;
            this.Paint += DrawGameObjects;
            #endregion

            #region - Initializing the updating events (information, game objects)
            //Initialize the customized event to set the information on the upper-left screen

            updateInfo  = new UpdateInfo(this.SetLevel);
            updateInfo += this.SetUserName;
            updateInfo += this.SetScore;
            updateInfo += this.SetHp;
            updateInfo += this.SetPause;

            updateObjects  = new UpdateObjects(this.DetectFlashCollision);
            updateObjects += this.DetectPlayerFireCollision;
            updateObjects += this.ClearObjects;

            #endregion

            InitializeComponent();
        }
Exemplo n.º 2
0
 public static void UpdateAllObjects()
 {
     for (int i = 0; i < UpdateObjects.Count; i++)
     {
         if (UpdateObjects[i] != null)
         {
             UpdateObjects[i].UpdateAnimation();
             UpdateObjects[i].Update();
         }
         else
         {
             UpdateObjects.RemoveAt(i);
             i--;
             continue;
         }
         if (UpdateObjects[i] != null)
         {
             if (UpdateObjects[i].ToUpdate)
             {
                 UpdateObjects[i].ChainUpdate();
             }
         }
         else
         {
             UpdateObjects.RemoveAt(i);
             i--;
             continue;
         }
     }
 }
 public void Remove(QBehavior script)
 {
     Objects.Remove(script.Parent);
     if (script is IQLoad l)
     {
         LoadObjects.Remove(l);
     }
     if (script is IQStart s)
     {
         StartObjects.Remove(s);
     }
     if (script is IQFixedUpdate u)
     {
         FixedUpdateObjects.Remove(u);
     }
     if (script is IQUpdate up)
     {
         UpdateObjects.Remove(up);
     }
     if (script is IQLateUpdate late)
     {
         LateUpdateObjects.Remove(late);
     }
     if (script is IQSprite ds)
     {
         SpriteObjects.Remove(ds);
     }
     if (script is IQGui dg)
     {
         GuiObjects.Remove(dg);
     }
     if (script is IQDestroy des)
     {
         des.OnDestroy();
         DestroyObjects.Remove(des);
     }
     if (script is IQUnload un)
     {
         UnloadObjects.Remove(un);
     }
     //invokes event even if does not inherit OnDestroy
     script.DestroyEvent();
 }
 public void Add(QBehavior script)
 {
     Objects.Add(script.Parent);
     if (script is IQLoad l)
     {
         LoadObjects.Add(l);
     }
     if (script is IQStart s)
     {
         StartObjects.Add(s);
     }
     if (script is IQFixedUpdate u)
     {
         FixedUpdateObjects.Add(u);
     }
     if (script is IQUpdate up)
     {
         UpdateObjects.Add(up);
     }
     if (script is IQLateUpdate late)
     {
         LateUpdateObjects.Add(late);
     }
     if (script is IQSprite ds)
     {
         SpriteObjects.Add(ds);
     }
     if (script is IQGui dg)
     {
         GuiObjects.Add(dg);
     }
     if (script is IQDestroy des)
     {
         DestroyObjects.Add(des);
     }
     if (script is IQUnload un)
     {
         UnloadObjects.Add(un);
     }
 }
 public QnAMakerUpdateKBInput()
 {
     Add    = new AddObjects();
     Update = new UpdateObjects();
 }