コード例 #1
0
 /// <summary>
 /// Destroys the specified actor and removes it from memory
 /// NOTE: An actor MUST be in the scene's actor collection to exist. Actors removed from the collection
 /// are dereferenced completely.
 /// </summary>
 /// <param name="_actor"></param>
 public void DestroyActor(EditorActor _actor)
 {
     if (_actor != null)
     {
         try {
             //Find the actor
             foreach (EditorActor _a in SCENE_ACTORS)
             {
                 if (_a.GetUniqueId() == _actor.GetUniqueId())
                 {
                     //Call the actor's dispose method
                     if (_a.Destroy() == 0)
                     {
                         //Remove the actor from the list
                         SCENE_ACTORS.Remove(_a);
                         //Dereference and call GC
                         GC.Collect();
                         return;
                     }
                 }
             }
             Editor.EngineMessage("ERROR: Failed to destroy scene actor because the actor does not exist.", Editor.eEngineMessageType.EXCEPTION);
             return;
         } catch (NullReferenceException _n) {
             Editor.EngineMessage(_n.Message, Editor.eEngineMessageType.EXCEPTION);
         }
     }
 }
コード例 #2
0
 /// <summary>
 /// Actor Collection Methods
 /// </summary>
 public void AddActorToScene(ref EditorActor _newActor)
 {
     if (_newActor != null)
     {
         //Generate new unique id for this actor
         _newActor.GenerateUniqueId();
         try {
             _newActor.position = _newActor.position - new Vector2f(_newActor.actorSprite.Texture.Size.X / 2, _newActor.actorSprite.Texture.Size.Y / 2);
             SCENE_ACTORS.Add(_newActor);
             _newActor.Create();
         } catch (NullReferenceException _n) {
             Editor.EngineMessage(_n.Message, Editor.eEngineMessageType.EXCEPTION);
         }
     }
     else
     {
         Editor.EngineMessage("ERROR: FAILED TO ADD ACTOR TO SCENE BECAUSE THE OBJECT YOU ARE TRYING TO ADD IS NULL");
     }
 }
コード例 #3
0
 public void OnMouseClick(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Left && EditorInput.bModifier == 0)
     {
         foreach (EditorActor _a in EditorScene.SCENE_ACTORS)
         {
             if (_a.actorSprite.GetGlobalBounds().Contains(Form1.mouseWorldPos.X, Form1.mouseWorldPos.Y))
             {
                 ClearSelectedActors();
                 SelectedActors.Add(_a);
                 HighlightSelectedActors();
             }
         }
     }
     if (e.Button == System.Windows.Forms.MouseButtons.Left && EditorInput.Alt == 1 && EditorInput.Ctrl == 0)
     {
         EditorActor _newActor = new EditorActor("Test Actor", Form1.mouseWorldPos);
         Editor.SCENE.AddActorToScene(ref _newActor);
     }
 }