Beispiel #1
0
        private void addCubeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GameObject go = new GameObject("Cube");

            if (Engine.GameEngine.Manager.AddObject(go))
            {
                Add_RemoveObject("Cube Added");
            }
        }
        /// <summary>
        /// Add an object to the list
        /// </summary>
        /// <param name="obj">The object to be added</param>
        /// <returns>True when successful, false otherwise</returns>
        public bool AddObject(GameObject obj)
        {
            try
            {
                lock (GameObjects)
                {
                    if (obj.GetType() == typeof(LightClass))
                    {
                        ((LightClass)obj).index = ++_index;
                    }
                    obj.ID = ++_id;
                    GameObjects.Add(obj);
                }
            }
            catch (Exception e)
            {
                Engine.GameEngine.Exception.Exceptions.Add(new ExceptionData(e.Message, e.Source, e.StackTrace));
                return false;
            }

            return true;
        }
Beispiel #3
0
        private void addObjectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();
            open.Multiselect = false;

            DialogResult result = open.ShowDialog();

            if (result == DialogResult.OK)
            {
                if (open.SafeFileName.ToLower().EndsWith(".x"))
                {
                    GameObject objclass = new GameObject(fileName: open.SafeFileName, path: open.FileName);
                    if (Engine.GameEngine.Manager.AddObject(objclass))
                    {
                        Add_RemoveObject(open.SafeFileName + " added");
                    }
                }
            }
        }