コード例 #1
0
ファイル: ComponentEditor.cs プロジェクト: TyrelBaux/Gibbo2D
        public ComponentEditor(GameObject gameObject)
        {
            InitializeComponent();

            this.gameObject = gameObject;
            this.Text = gameObject.Name + " - " + this.Text;

            this.bufferedTreeView.TreeViewNodeSorter = new NodeSorter();
        }
コード例 #2
0
        public AddNewItemWindow(UIElement target)
        {
            InitializeComponent();

            itemListBox.SelectedIndex = 1;

            this.target = target;
            if (target != null && (target as DragDropTreeViewItem).Tag is GameObject)
                targetObject = (target as DragDropTreeViewItem).Tag as GameObject;

            this.KeyUp += AddNewItemWindow_KeyUp;
        }
コード例 #3
0
ファイル: Transform.cs プロジェクト: TyrelBaux/Gibbo2D
        protected Transform(SerializationInfo info, StreamingContext context)
        {
            if (info == null)
                throw new ArgumentNullException("info");

            gameObject = info.GetValue("gameObject", typeof(GameObject)) as GameObject;
            parent = info.GetValue("parent", typeof(Transform)) as Transform;
            position = (Vector2)info.GetValue("position", typeof(Vector2));
            rotation = (float)info.GetDouble("rotation");

            object obj = info.GetValue("scale", typeof(object));
            if (obj is Vector2)
                scale = (Vector2)info.GetValue("scale", typeof(Vector2));
            else
                scale = Vector2.One;
        }
コード例 #4
0
ファイル: UndoRedo.cs プロジェクト: TyrelBaux/Gibbo2D
 /// <summary>
 /// 
 /// </summary>
 /// <param name="rotate"></param>
 /// <param name="oldRotate"></param>
 /// <param name="element"></param>
 public void InsertInUnDoRedoForRotate(float rotate, float oldRotate, GameObject element)
 {
     ICommand cmd = new RotateCommand(rotate, oldRotate, element);
     _Undocommands.Push(cmd);
     _Redocommands.Clear();
 }
コード例 #5
0
ファイル: UndoRedo.cs プロジェクト: TyrelBaux/Gibbo2D
 /// <summary>
 /// 
 /// </summary>
 /// <param name="position"></param>
 /// <param name="before"></param>
 /// <param name="element"></param>
 public void InsertInUnDoRedoForMove(Vector2 position, Vector2 oldPosition, GameObject element)
 {
     ICommand cmd = new MoveCommand(position, oldPosition, element);
     _Undocommands.Push(cmd);
     _Redocommands.Clear();
 }
コード例 #6
0
ファイル: GameObject.cs プロジェクト: Alexz18z35z/Gibbo2D
        private static GameObject FindNext(GameObject gameObject, string src, SearchOptions searchOption)
        {
            if (FindComparer(gameObject, src, searchOption) != null) return gameObject;

            foreach (GameObject _gameObject in gameObject.Children)
            {
                GameObject result = FindNext(_gameObject, src, searchOption);

                // The game object was found?
                if (result != null)
                    return result;
            }

            // Not found
            return null;
        }
コード例 #7
0
ファイル: GameObject.cs プロジェクト: Alexz18z35z/Gibbo2D
        /// <summary>
        /// Removes a game object by it's reference
        /// </summary>
        /// <param name="gameObject">The object to remove</param>
        /// <returns></returns>
        public static GameObject Remove(GameObject gameObject)
        {
            gameObject.Remove();

            return gameObject;
        }
コード例 #8
0
ファイル: GameObject.cs プロジェクト: Alexz18z35z/Gibbo2D
 /// <summary>
 /// Event thrown when another object collides with this.
 /// </summary>
 /// <param name="other"></param>
 public void OnCollisionEnter(GameObject other)
 {
     // send notification to components that this object collided with other
     foreach (ObjectComponent component in components)
         if ((SceneManager.IsEditor && component is ExtendedObjectComponent) || !SceneManager.IsEditor)
             if (!component.Disabled)
                 component.OnCollisionEnter(other);
 }
コード例 #9
0
ファイル: Tween.cs プロジェクト: TyrelBaux/Gibbo2D
 /// <summary>
 /// 
 /// </summary>
 /// <param name="target"></param>
 public Tween(GameObject target)
 {
     this.target = target;
 }
コード例 #10
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gameObject"></param>
        /// <returns></returns>
        internal ImageSource GameObjectImageSource(GameObject gameObject)
        {
            if ((gameObject is Sprite) || (gameObject is AnimatedSprite))
                return (ImageSource)FindResource("GameObjectIcon_Sprite");
            else if (gameObject is BMFont)
                return (ImageSource)FindResource("GameObjectIcon_Text");
            else if (gameObject is AudioObject)
                return (ImageSource)FindResource("GameObjectIcon_Audio");
            else if (gameObject is Tileset)
                return (ImageSource)FindResource("GameObjectIcon_Tileset");
            else if (gameObject is ParticleEmitter)
                return (ImageSource)FindResource("GameObjectIcon_Particle");

            // Empty game object
            return (ImageSource)FindResource("GameObjectIcon_Empty");
        }
コード例 #11
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="_gameObject"></param>
        /// <param name="node"></param>
        private void FillGameObjects(GameObject _gameObject, DragDropTreeViewItem node)
        {
            foreach (GameObject gameObject in _gameObject.Children)
            {
                string name = gameObject.Name == null ? "Game Object" : gameObject.Name;
                gameObject.Name = name;

                DragDropTreeViewItem _node = AddNode(node, gameObject, GameObjectImageSource(gameObject));
                //_node.ContextMenuStrip = objectContextMenuStrip;

                FillGameObjects(gameObject, _node);
            }
        }
コード例 #12
0
        internal void AddGameObject(GameObject gameObject, string type, bool autoselect = true, bool addToSelectedParent = false, bool expand = false)
        {
            if (gameObject == null)
            {
                switch (type.ToLower())
                {
                    case "empty":
                        gameObject = new GameObject();
                        gameObject.Name = "Empty Game Object";

                        break;

                    case "sprite":
                        gameObject = new Sprite();
                        gameObject.Name = "Sprite Game Object";

                        break;

                    case "animatedsprite":
                        gameObject = new AnimatedSprite();
                        gameObject.Name = "Animated Sprite Game Object";

                        break;

                    case "audio":
                        gameObject = new AudioObject();
                        gameObject.Name = "Audio Game Object";

                        break;

                    case "tileset":
                        gameObject = new Tileset();
                        gameObject.Name = "Tileset Game Object";

                        break;

                    case "bmfont":
                        gameObject = new BMFont();
                        gameObject.Name = "Bitmap Font Object";

                        break;

                    case "particleemitter":
                        gameObject = new ParticleEmitter();
                        gameObject.Name = "Particle Emitter Object";

                        break;
                }
            }
            else
            {
                gameObject.Initialize();
            }

            if (SelectedItem == null)
            {
                SceneManager.ActiveScene.GameObjects.Add(gameObject);
            }
            else
            {
                if (addToSelectedParent)
                {
                    GameObject _gameObject = (GameObject)(SelectedItem as DragDropTreeViewItem).Tag;
                    if (_gameObject.Transform.Parent == null)
                        SceneManager.ActiveScene.GameObjects.Add(gameObject);
                    else
                        _gameObject.Transform.Parent.GameObject.Children.Add(gameObject);
                }
                else
                {
                    GameObject _gameObject = (GameObject)(SelectedItem as DragDropTreeViewItem).Tag;
                    _gameObject.Children.Add(gameObject);
                }
            }

            if (gameObject != null)
            {
                DragDropTreeViewItem _parent = SelectedItem as DragDropTreeViewItem;
                if (addToSelectedParent)
                {
                    var tmp = EditorUtils.FindVisualParent<DragDropTreeViewItem>(_parent);

                    if (tmp != null)
                        _parent = tmp;
                    else
                        _parent = null;
                }

                DragDropTreeViewItem node = AddNode(_parent, gameObject, GameObjectImageSource(gameObject));

                if (_parent != null && expand)
                {
                    //_parent.ExpandSubtree();
                    _parent.IsExpanded = true;
                }

                node.ContextMenu = contextMenu;
                // AddNodes(gameObject);
                //node.IsSelected = true;

                AttachChildren(node);
                //foreach (GameObject _obj in gameObject.Children)
                //    AddGameObject(_obj, string.Empty);

                if (autoselect)
                {
                    node.IsSelected = true;
                    EditorHandler.SelectedGameObjects = new List<GameObject>();
                    EditorHandler.SelectedGameObjects.Add(gameObject);
                }
            }
        }
コード例 #13
0
ファイル: Editor.cs プロジェクト: TyrelBaux/Gibbo2D
        private void convertToCollisionModelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (sceneEditorControl1.SelectionArea != Rectangle.Empty)
            {
                GameObject gameObject = new GameObject();
                gameObject.Name = "Collision Block";

                gameObject.Transform.Position = new Vector2(sceneEditorControl1.SelectionArea.X + sceneEditorControl1.SelectionArea.Width / 2, sceneEditorControl1.SelectionArea.Y + sceneEditorControl1.SelectionArea.Height / 2);
                gameObject.CollisionModel.Width = sceneEditorControl1.SelectionArea.Width;
                gameObject.CollisionModel.Height = sceneEditorControl1.SelectionArea.Height;

                if (SceneManager.ActiveScene.Layers == null || SceneManager.ActiveScene.Layers.Count == 0)
                {
                    SceneManager.ActiveScene.Layers.Add(new Layer());
                }

                SceneManager.ActiveScene.Layers[SceneManager.ActiveScene.Layers.Count - 1].GameObjects.Add(gameObject);

                sceneTreeView.CreateView();

                EditorHandler.SelectedGameObjects = new List<GameObject>();
                EditorHandler.SelectedGameObjects.Add(gameObject);
            }
            else
            {
                KryptonMessageBox.Show("No valid selection provided, please make a screen selection before executing this command", "Error");
            }
        }
コード例 #14
0
        /// <summary>
        /// Virtual OnCollisionEnter Event
        /// Event thrown when there is an object collision.
        /// </summary>
        /// <param name="other">The collided object</param>
        public virtual void OnCollisionEnter(GameObject other)
        {

        }
コード例 #15
0
        internal void AddGameObject(GameObject gameObject, string type, bool autoselect = true)
        {
            if (gameObject == null)
            {
                switch (type.ToLower())
                {
                    case "empty":
                        gameObject = new GameObject();
                        gameObject.Name = "Empty Game Object";

                        break;

                    case "sprite":
                        gameObject = new Sprite();
                        gameObject.Name = "Sprite Game Object";

                        break;

                    case "animatedsprite":
                        gameObject = new AnimatedSprite();
                        gameObject.Name = "Animated Sprite Game Object";

                        break;

                    case "audio":
                        gameObject = new AudioObject();
                        gameObject.Name = "Audio Game Object";

                        break;

                    case "tileset":
                        gameObject = new Tileset();
                        gameObject.Name = "Tileset Game Object";

                        break;

                    case "bmfont":
                        gameObject = new BMFont();
                        gameObject.Name = "Bitmap Font Object";

                        break;

                    case "particleemitter":
                        gameObject = new ParticleEmitter();
                        gameObject.Name = "Particle Emitter Object";

                        break;
                }
            }
            else
            {
                gameObject.Initialize();
            }

            if (SelectedItem == null)
            {
                SceneManager.ActiveScene.GameObjects.Add(gameObject);
            }
            else
            {
                GameObject _gameObject = (GameObject)(SelectedItem as DragDropTreeViewItem).Tag;
                _gameObject.Children.Add(gameObject);
            }

            if (gameObject != null)
            {
                DragDropTreeViewItem node = AddNode(SelectedItem as DragDropTreeViewItem, gameObject, GameObjectImageSource(gameObject));
                node.ContextMenu = contextMenu;
                // AddNodes(gameObject);
                //node.IsSelected = true;

                AttachChildren(node);
                //foreach (GameObject _obj in gameObject.Children)
                //    AddGameObject(_obj, string.Empty);

                if (autoselect)
                {
                    EditorHandler.SelectedGameObjects = new List<GameObject>();
                    EditorHandler.SelectedGameObjects.Add(gameObject);
                }
            }
        }
コード例 #16
0
ファイル: GameObject.cs プロジェクト: Alexz18z35z/Gibbo2D
        private static GameObject FindComparer(GameObject gameObject, string src, SearchOptions searchOption)
        {
            switch (searchOption)
            {
                case SearchOptions.Hash:
                    if (gameObject.GetHashCode() == Convert.ToInt32(src))
                        return gameObject;
                    break;
                case SearchOptions.Name:
                    if (gameObject.name == src)
                        return gameObject;
                    break;
                case SearchOptions.Tag:
                    if (gameObject.Tag == src)
                        return gameObject;
                    break;
            }

            return null;
        }
コード例 #17
0
ファイル: GameObject.cs プロジェクト: Alexz18z35z/Gibbo2D
 private static void LoadNext(GameObject _gameObject, List<GameObject> gameObjectsBuffer)
 {
     foreach (GameObject gameObject in _gameObject.Children)
     {
         gameObjectsBuffer.Add(gameObject);
         LoadNext(gameObject, gameObjectsBuffer);
     }
 }
コード例 #18
0
ファイル: Camera.cs プロジェクト: TyrelBaux/Gibbo2D
 /// <summary>
 /// Calculates the transformation matrix of the camera for a given game object
 /// </summary>
 /// <param name="obj">The game object</param>
 /// <returns></returns>
 public Matrix ObjectTransform(GameObject obj)
 {                      
     return
         Matrix.CreateTranslation(-obj.Transform.Position.X, -obj.Transform.Position.Y, 0.0f) *
         Matrix.CreateRotationZ(obj.Transform.Rotation) *
         Matrix.CreateTranslation(obj.Transform.Position.X, obj.Transform.Position.Y, 0.0f) *
         CalculateTransform()
      ;
 }
コード例 #19
0
ファイル: GameObject.cs プロジェクト: Alexz18z35z/Gibbo2D
        private static GameObject RemoveNext(GameObject gameObject, string src)
        {
            foreach (GameObject _gameObject in gameObject.Children)
            {
                if (_gameObject.name == src)
                {
                    gameObject.Children.Remove(gameObject);
                    return gameObject;
                }

                GameObject result = RemoveNext(_gameObject, src);

                // The game object was found?
                if (result != null)
                {
                    _gameObject.Children.Remove(result);
                    return result;
                }
            }

            // Not found
            return null;
        }
コード例 #20
0
ファイル: ConstantTween.cs プロジェクト: Alexz18z35z/Gibbo2D
 /// <summary>
 /// 
 /// </summary>
 /// <param name="target"></param>
 public ConstantTween(GameObject target)
 {
     this.target = target;
 }
コード例 #21
0
ファイル: GameObject.cs プロジェクト: Alexz18z35z/Gibbo2D
        // Search in GameObject children
        private static List<GameObject> FindAll(GameObject gameObject, string src, SearchOptions searchOption)
        {
            List<GameObject> found = new List<GameObject>();

            if (FindComparer(gameObject, src, searchOption) != null) found.Add(gameObject);

            foreach (GameObject _gameObject in gameObject.Children)
            {
                List<GameObject> result = FindAll(_gameObject, src, searchOption);

                found.AddRange(result);
            }

            return found;
        }
コード例 #22
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="_gameObject"></param>
        /// <param name="node"></param>
        private void FillGameObjects(GameObject _gameObject, TreeNode node)
        {
            foreach (GameObject gameObject in _gameObject.Children)
            {
                string name = gameObject.Name == null ? "Game Object" : gameObject.Name;
                gameObject.Name = name;

                TreeNode _node = AddNode(node, gameObject, GameObjectImageIndex(gameObject));
                _node.ContextMenuStrip = objectContextMenuStrip;

                FillGameObjects(gameObject, _node);
            }
        }
コード例 #23
0
ファイル: ScaleCommand.cs プロジェクト: TyrelBaux/Gibbo2D
 /// <summary>
 /// 
 /// </summary>
 /// <param name="change"></param>
 /// <param name="element"></param>
 public ScaleCommand(float change, float before, GameObject element)
 {
     _change = change;
     _element = element;
     _beforeChange = before;
 }
コード例 #24
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="gameObject"></param>
 /// <returns></returns>
 private int GameObjectImageIndex(GameObject gameObject)
 {
     if (gameObject is Sprite)
         return 2;
     else if (gameObject is AnimatedSprite)
         return 4;
     else if (gameObject is AudioObject)
         return 5;
     else if (gameObject is Tileset)
         return 6;
     else if (gameObject is BMFont)
         return 7;
    
     // Empty game object
     return 3;
 }
コード例 #25
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        private bool ChildrenOfSelected(GameObject obj)
        {
            Transform o = obj.Transform.Parent;
            while (o != null)
            {
                if (EditorHandler.SelectedGameObjects.Contains(o.GameObject))
                    return true;

                o = o.Parent;
            }

            return false;
        }
コード例 #26
0
        /// <summary>
        /// 
        /// </summary>
        private void AddGameObject(GameObject gameObject, string type)
        {
            if (gameObject == null)
            {
                switch (type.ToLower())
                {
                    case "empty":
                        gameObject = new GameObject();
                        gameObject.Name = "Empty Game Object";

                        break;

                    case "sprite":
                        gameObject = new Sprite();
                        gameObject.Name = "Sprite Game Object"; 

                        break;

                    case "animatedsprite":
                        gameObject = new AnimatedSprite();
                        gameObject.Name = "Animated Sprite Game Object";

                        break;

                    case "audio":
                        gameObject = new AudioObject();
                        gameObject.Name = "Audio Game Object";

                        break;

                    case "tileset":
                        gameObject = new Tileset();
                        gameObject.Name = "Tileset Game Object";

                        break;

                    case "bmfont":
                        gameObject = new BMFont();
                        gameObject.Name = "Bitmap Font Object";

                        break;
                } 
            }
            else
            {
                gameObject.Initialize();
            }

            if (SelectedNode.Tag is Layer)
            {
                Layer layer = (Layer)SelectedNode.Tag;
                layer.GameObjects.Add(gameObject);
            }
            else if (SelectedNode.Tag is GameObject)
            {
                GameObject _gameObject = (GameObject)SelectedNode.Tag;
                _gameObject.Children.Add(gameObject);
            }

            if (gameObject != null)
            {
                TreeNode node = AddNode(SelectedNode, gameObject, GameObjectImageIndex(gameObject));
                node.ContextMenuStrip = objectContextMenuStrip;

                EditorHandler.SelectedGameObjects = new List<GameObject>();
                EditorHandler.SelectedGameObjects.Add(gameObject);
            }
        }
コード例 #27
0
ファイル: UndoRedo.cs プロジェクト: TyrelBaux/Gibbo2D
 /// <summary>
 /// 
 /// </summary>
 /// <param name="scale"></param>
 /// <param name="oldScale"></param>
 /// <param name="element"></param>
 public void InsertInUnDoRedoForScale(float scale, float oldScale, GameObject element)
 {
     ICommand cmd = new ScaleCommand(scale, oldScale, element);
     _Undocommands.Push(cmd);
     _Redocommands.Clear();
 }
コード例 #28
0
ファイル: MainWindow.xaml.cs プロジェクト: TyrelBaux/Gibbo2D
        private void ToCollisionBlock()
        {
            if (sceneViewGameControl.SelectionArea != Microsoft.Xna.Framework.Rectangle.Empty)
            {
                GameObject gameObject = new GameObject();
                gameObject.Name = "Collision Block";

                gameObject.Transform.Position = new Microsoft.Xna.Framework.Vector2(sceneViewGameControl.SelectionArea.X + sceneViewGameControl.SelectionArea.Width / 2, sceneViewGameControl.SelectionArea.Y + sceneViewGameControl.SelectionArea.Height / 2);

                SceneManager.ActiveScene.GameObjects.Add(gameObject);

                RectangleBody body = new RectangleBody();
                body.EditorExpanded = true;

                gameObject.AddComponent(body);

                body.Width = sceneViewGameControl.SelectionArea.Width;
                body.Height = sceneViewGameControl.SelectionArea.Height;
                body.BodyType = FarseerPhysics.Dynamics.BodyType.Static;

                sceneTreeView.CreateView();

                EditorHandler.SelectedGameObjects = new List<GameObject>();
                EditorHandler.SelectedGameObjects.Add(gameObject);
                EditorHandler.ChangeSelectedObjects();
            }
            else
                System.Windows.MessageBox.Show("No valid selection provided, please make a screen selection before executing this command", "Error");
        }
コード例 #29
0
ファイル: MoveCommand.cs プロジェクト: Alexz18z35z/Gibbo2D
 /// <summary>
 /// 
 /// </summary>
 /// <param name="change"></param>
 /// <param name="element"></param>
 public MoveCommand(Vector2 change, Vector2 before, GameObject element)
 {
     _change = change;
     _element = element;
     _beforeChange = before;
 }
コード例 #30
0
        /// <summary>
        /// Raises the collision enter event.
        /// This event is thrown when another object collides with this game object collision model boundries.
        /// </summary>
        /// <param name="other">The other object</param>
        public override void OnCollisionEnter(GameObject other)
        {
            base.OnCollisionEnter(other);

            // TODO: handle your object collision

        }