public void AddRange(GameObjectCollection collection) { for (int i = 0; i < collection.Count; i++) { this.Add(collection[i]); } }
/// <summary> /// Initializes this object. /// </summary> public virtual void Initialize() { if (Body != null) { Body = null; } transform.GameObject = this; this.components = new List <ObjectComponent>(); for (int i = componentReferences.Count - 1; i >= 0; i--) { string name = componentReferences[i]; Type _type = SceneManager.ScriptsAssembly.GetType(name); if (_type == null) { #if WINDOWS _type = Assembly.GetExecutingAssembly().GetType(name); // system components #elif WINRT _type = typeof(GameObject).GetTypeInfo().Assembly.GetType(name); #endif //scriptsAssembly = false; } // still null? delete reference: //if (_type == null) //{ // componentReferences.RemoveAt(i); //} // The reference still exists? // (the user removed the component?) if (_type != null) { try { ObjectComponent oc; oc = (ObjectComponent)Activator.CreateInstance(_type); // não apagar: //if (scriptsAssembly) // oc = (ObjectComponent)SceneManager.ScriptsAssembly // .CreateInstance(name); //else // oc = (ObjectComponent)typeof(GameObject).GetTypeInfo().Assembly.CreateInstance(name); oc.Transform = this.Transform; LoadComponentValues(oc); this.components.Insert(0, oc); } catch (Exception ex) { Console.WriteLine( "Error trying to Activate " + name + " on " + Name + " : " + ex.Message + "\n" + ex.StackTrace.ToString()); } } } // initializes components foreach (var cmp in this.components) { if (!SceneManager.IsEditor || (SceneManager.IsEditor && cmp is ExtendedObjectComponent)) { cmp.Initialize(); } } if (children == null) { children = new GameObjectCollection(this); } // Initialize Children game objects foreach (GameObject gameObject in children) { gameObject.Initialize(); } collisionBoundryColor = Color.FromNonPremultiplied(255, 64, 0, 120); // initialize collision model //collisionModel.Initialize(this.transform); CheckAllAttributes(); }