Esempio n. 1
0
 /// <summary>
 /// Make a deep copy
 /// </summary>
 /// <param name="copy"></param>
 public GameObject(GameObject copy, IObjectBuilder parent)
 {
     m_name = copy.m_name;
     m_elements = new ObservableCollection<Element>();
     //App app = (App)App.Current;
     foreach (Element comp in copy.m_elements)
     {
         Element newComp = new Element(comp);
         newComp.ParentGameObject = this;
         m_elements.Add(newComp);
         //app._3dEditorParameter(this, newComp);
     }
     m_dimension = copy.m_dimension;
     m_autoId = copy.m_autoId;
     m_parentObjectBuilder = parent;
     Point newPos = new Point(copy.m_position.X +5,copy.m_position.Y + 5);
     m_position = newPos;
 }
Esempio n. 2
0
 public void GameObject_PreviewDragOver(GameObject pGo, DragEventArgs e)
 {
     if (pGo != null)
     {
         Element element = e.Data.GetData(typeof(Element)) as Element;
         if (element != null)
         {
             e.Effects = DragDropEffects.Copy;
             e.Handled = true;
         }
         else
         {
             e.Effects = DragDropEffects.None;
         }
     }
 }
Esempio n. 3
0
 public void GameObject_Drop(GameObject pGo, DragEventArgs e)
 {
     if (pGo != null)
     {
         Element elements = e.Data.GetData(typeof(Element)) as Element;
         if (elements != null)
         {
             Element newElement = new Element(elements);
             if (pGo != null)
             {
                 pGo.Add(newElement);
                 e.Handled = true;
             }
         }
     }
 }
 public void selectGameObject(GameObject gameobject)
 {
     myCtrl.DataContext = gameobject;
 }
Esempio n. 5
0
 public LiveGameObject(GameObject copy)
 {
     m_name = copy.Name;
     foreach (Element comp in copy.Elements)
     {
         m_elements.Add(comp);
     }
 }
Esempio n. 6
0
 public GameObject newGameObject(String name)
 {
     GameObject newGo = new GameObject(name);
     m_scriptObjects.Add(newGo);
     Dirty = true;
     return newGo;
 }
Esempio n. 7
0
        public void deserializeFromXml(string filename)
        {
            m_document.Load(filename);

            XmlNode objectBuilderNode = Helper.XmlHelper.getNodeByName(m_document.ChildNodes, "ObjectBuilder");
            if (objectBuilderNode == null)
                return;

            Parameters.Clear();
            m_scriptObjects.Clear();

            foreach (XmlAttribute attrib in objectBuilderNode.Attributes)
            {
                if (attrib.Name == "name")
                    this.m_name = attrib.Value;
                else if (attrib.Name == "offset_x")
                {
                    double x;
                    if (double.TryParse(attrib.Value, out x))
                        m_offset.X = x;
                }
                else if (attrib.Name == "offset_y")
                {
                    double y;
                    if (double.TryParse(attrib.Value, out y))
                        m_offset.Y = y;
                }
                else if (attrib.Name == "is_macro")
                {
                    bool.TryParse(attrib.Value, out this.m_isMacro);
                }
            }

            // Parameters
            XmlNode parameterNode = Helper.XmlHelper.getNodeByName(objectBuilderNode.ChildNodes, "Parameters");
            if (parameterNode != null)
            {
                foreach (XmlNode parameter in parameterNode.ChildNodes)
                {
                    if (parameter is XmlElement && parameter.Name == "Parameter")
                    {
                        XmlElement param = parameter as XmlElement;
                        Parameter p = new Parameter();
                        p.deserializeFromXml(param);
                        AddParameter(p);
                    }
                }
            }

            // Objects
            XmlNode objectsNode = Helper.XmlHelper.getNodeByName(objectBuilderNode.ChildNodes, "Objects");
            if (objectsNode != null)
            {
                foreach (XmlNode object_ in objectsNode.ChildNodes)
                {
                    if (object_ is XmlElement)
                    {
                        IScriptObject so = null;
                        XmlElement obj = object_ as XmlElement;
                        if (obj.Name == "GameObject")
                        {
                            so = new GameObject(this);
                            so.deserializeFromXml(obj);
                        }
                        else if (obj.Name == "MacroCall")
                        {
                            so = new MacroCall();
                            so.deserializeFromXml(obj);
                        }
                        else if (obj.Name == "MacroRegistration")
                        {
                            so = new MacroRegistration();
                            so.deserializeFromXml(obj);
                        }
                        else if (obj.Name == "FunctionCall")
                        {
                            so = new FunctionCall();
                            so.deserializeFromXml(obj);
                        }
                        else if (obj.Name == "Function")
                        {
                            so = new Function();
                            so.deserializeFromXml(obj);
                        }
                        if (so != null)
                            m_scriptObjects.Add(so);
                    }
                }
            }
        }
Esempio n. 8
0
        public void deserialize(System.IO.BinaryReader br)
        {
            Parameters.Clear();
            m_scriptObjects.Clear();

            Name = br.ReadString();
            Point p = new Point();
            p.X = br.ReadDouble();
            p.Y = br.ReadDouble();
            m_isMacro = br.ReadBoolean();
            int parameterCount = br.ReadInt32();
            for (int i = 0; i < parameterCount; ++i)
            {
                Parameter param = new Parameter();
                param.deserialize(br);
                AddParameter(param);
            }
            m_offset = p;
            int goCount = br.ReadInt32();
            for (int i = 0; i < goCount; ++i)
            {
                String type = br.ReadString();
                IScriptObject so = null;
                if (type == "GameObject")
                {
                    so = new GameObject(this);
                }
                else if (type == "MacroCall")
                {
                    so = new MacroCall();
                }
                else if (type == "MacroRegistration")
                {
                    so = new MacroRegistration();
                }
                else if (type == "FunctionCall")
                {
                    so = new FunctionCall();
                }
                else if (type == "Function")
                {
                    so = new Function();
                }
                if (so != null)
                {
                    so.deserialize(br);
                    so.ParentObjectBuilder = this;
                    m_scriptObjects.Add(so);
                }
            }
        }
Esempio n. 9
0
        public void addScriptObjectCopy(List<IScriptObject> scriptObjects)
        {
            foreach (IScriptObject so in scriptObjects)
            {
                if (so is GameObject)
                {
                    GameObject go = so as GameObject;
                    GameObject newGo = new GameObject(go, this);
                    m_scriptObjects.Add(newGo);
                }
                else if (so is LiveGameObject && !IsLive)
                {
                    LiveGameObject lgo = so as LiveGameObject;
                    GameObject newGo = new GameObject(lgo, this);
                    m_scriptObjects.Add(newGo);
                }
                else if (so is MacroCall)
                {

                }
                else if (so is MacroRegistration)
                {

                }
                else if (so is FunctionCall)
                {

                }
                else if (so is Function)
                {

                }
            }
            updateUi();
            Dirty = true;
        }