public void SelectGameObject(LiveGameObject liveGameObject)
 {
     //// we need to create an internal copy so we can set the information like the TargetId (gameobject)
     //// of the selected object. This is needed to actually send messages to the correct gameobject
     //m_internalCopy = new LiveGameObject(liveGameObject);
     DataContext = liveGameObject;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Make a deep copy
 /// </summary>
 /// <param name="copy"></param>
 public GameObject(LiveGameObject copy, IObjectBuilder parent)
 {
     m_name = copy.Name;
     m_elements = new ObservableCollection<Element>();
     //App app = (App)App.Current;
     foreach (Element comp in copy.Elements)
     {
         Element newComp = new Element(comp);
         newComp.ParentGameObject = this;
         m_elements.Add(newComp);
         //app._3dEditorParameter(this, newComp);
     }
     m_dimension = copy.Dimension;
     m_autoId = true;
     m_parentObjectBuilder = parent;
     Point newPos = new Point(copy.Position.X + 5, copy.Position.Y + 5);
     m_position = newPos;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="go"></param>
 public void RemoveLiveGameObject(LiveGameObject go)
 {
     if (m_liveGameObjects != null)
         m_liveGameObjects.ScriptObjects.Remove(go);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gameobject"></param>
        /// <returns></returns>
        public LiveGameObject AddLiveGameObject(XmlNode gameobject)
        {
            // get name
            String gameObjectName = XmlHelper.getNodeAttributeValue(gameobject, "Name");

            LiveGameObject newGo = new LiveGameObject(gameObjectName);
            ObservableCollection<Element> comps = getAllComponents();

            // find elements child node
            XmlNode elementsNode = XmlHelper.getNodeByName(gameobject.ChildNodes, "Elements");

            if (elementsNode == null)
            {
                if (m_liveGameObjects != null)
                    m_liveGameObjects.ScriptObjects.Add(newGo);
                return newGo;
            }

            Exception e = null;
            List<string> errors = new List<string>();

            foreach (XmlNode compNode in elementsNode.ChildNodes)
            {
                String compName = XmlHelper.getNodeAttributeValue(compNode, "Name");

                // check existing components
                Element compInstance = null;
                foreach(Element comp in comps)
                {
                    if (compName.Length > 0 && compName.Equals(comp.Id))
                    {
                        compInstance = new Element(comp);
                        compInstance.ParentLiveGameObject = newGo;
                        newGo.Elements.Add(compInstance);
                        break;
                    }
                }
                if (compInstance != null)
                {
                    // check data
                    XmlNode dataNode = XmlHelper.getNodeByName(compNode.ChildNodes,"Data");
                    if (dataNode != null)
                    {
                        string[] values = new string[dataNode.ChildNodes.Count];
                        int index = 0;
                        foreach (XmlNode valueNode in dataNode.ChildNodes)
                        {
                            // <Value><text>actual value</text></Value>
                            if (valueNode.FirstChild != null)
                                values[index++] = valueNode.FirstChild.InnerText;
                        }

                        // is there data?
                        if (values.Length > 0)
                        {
                            int value = 0;
                            foreach (Parameter parameter in compInstance.Parameters)
                            {
                                if (parameter.Type == ParameterType.COMPOUNDPARAMETER || parameter.Type == ParameterType.SEQUENCEPARAMETER) // TODO this needs special treatment
                                {
                                    e = paraseCompoundParameterData(parameter, values, ref value, errors, compInstance);
                                    if (e != null)
                                        break;
                                    else
                                        continue;
                                }
                                StringBuilder sb = new StringBuilder();
                                // still enough left?
                                if (value + parameter.Count > values.Length)
                                {
                                    errors.Add("Error not enough ParameterData\nParameter " + parameter.Name + " in Element " + compInstance.Name);
                                    e = new Exception();
                                    break;
                                }
                                for (int i = 0; i < parameter.Count; ++i)
                                {
                                    if (values[value] != null)
                                        sb.Append(values[value++]);
                                    if (i < parameter.Count -1)
                                        sb.Append(",");
                                }
                                parameter.Values = sb.ToString();
                            }
                        }
                    }
                }
                else
                {
                    // TODO implement something
                }

            }
            if (m_liveGameObjects != null)
                m_liveGameObjects.ScriptObjects.Add(newGo);
            if (e != null)
            {
                StringBuilder sb = new StringBuilder();
                foreach (string err in errors)
                {
                    sb.AppendLine(err);
                }
                e = new Exception( sb.ToString() );
                throw e;
            }
            return newGo;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="name"></param>
        /// <param name="components"></param>
        /// <returns></returns>
        public LiveGameObject AddLiveGameObject(String name, String[] components)
        {
            LiveGameObject newGo = new LiveGameObject(name);
            ObservableCollection<Element> comps = getAllComponents();
            foreach (String comp in components)
            {
                Element component = comps.First();
                bool notFound = component != null;
                bool unknown = true;
                while (notFound)
                {
                    if (comp.Equals(component.Id))
                    {
                        newGo.Elements.Add(component);
                        notFound = false;
                        unknown = true;
                    }
                }
                if (unknown)
                {
                    // TODO add default component

                }
            }
            if (m_liveGameObjects != null)
                m_liveGameObjects.ScriptObjects.Add(newGo);
            return newGo;
        }
 private void LiveGameObjectProperty(LiveGameObject gameobject)
 {
     if (gameobject != null)
     {
         GameObjectMessageControl control = ShowGameObjectMessageWindowinternal(null, EventArgs.Empty);
         if (control != null)
         {
             control.SelectGameObject(gameobject);
         }
     }
 }
Ejemplo n.º 7
0
 public LiveGameObject(LiveGameObject copy)
 {
     m_name = copy.Name;
     foreach (Element comp in copy.Elements)
     {
         m_elements.Add(comp);
     }
 }