public LineSegment(Vec2 pStart, Vec2 pEnd, GameObject owner, uint pColor = 0xffffffff, uint pLineWidth = 1, bool pGlobalCoords = false) { _owner = owner; Start = pStart; End = pEnd; Color = pColor; LineWidth = pLineWidth; UseGlobalCoords = pGlobalCoords; }
//------------------------------------------------------------------------------------------------------------------------ // Remove() //------------------------------------------------------------------------------------------------------------------------ internal void Remove(GameObject gameObject) { if (_gameObjectsContained.Contains (gameObject)) { _updateManager.Remove (gameObject); _collisionManager.Remove (gameObject); _gameObjectsContained.Remove (gameObject); } }
//------------------------------------------------------------------------------------------------------------------------ // GetGameObjectCollisions() //------------------------------------------------------------------------------------------------------------------------ internal GameObject[] GetGameObjectCollisions(GameObject gameObject) { return _collisionManager.GetCurrentCollisions(gameObject); }
//------------------------------------------------------------------------------------------------------------------------ // Add() //------------------------------------------------------------------------------------------------------------------------ internal void Add(GameObject gameObject) { if (!_gameObjectsContained.Contains (gameObject)) { _updateManager.Add (gameObject); _collisionManager.Add (gameObject); _gameObjectsContained.Add (gameObject); } }
//------------------------------------------------------------------------------------------------------------------------ // Contains() //------------------------------------------------------------------------------------------------------------------------ public Boolean Contains(GameObject gameObject) { return _gameObjectsContained.Contains(gameObject); }
//------------------------------------------------------------------------------------------------------------------------ // removeChild() //------------------------------------------------------------------------------------------------------------------------ private void removeChild(GameObject child) { _children.Remove(child); }
//------------------------------------------------------------------------------------------------------------------------ // addChild() //------------------------------------------------------------------------------------------------------------------------ private void addChild(GameObject child) { if (child.HasChild(this)) return; //no recursive adding _children.Add(child); return; }
//------------------------------------------------------------------------------------------------------------------------ // SetChildIndex() //------------------------------------------------------------------------------------------------------------------------ /// <summary> /// Inserts the specified object in this object's child list at given location. /// This will alter the position of other objects as well. /// You can use this to determine the layer order (z-order) of child objects. /// </summary> /// <param name='child'> /// Child. /// </param> /// <param name='index'> /// Index. /// </param> public void SetChildIndex(GameObject child, int index) { if (child.parent != this) AddChild(child); if (index < 0) index = 0; if (index >= _children.Count) index = _children.Count - 1; _children.Remove(child); _children.Insert(index, child); }
//------------------------------------------------------------------------------------------------------------------------ // RemoveChild() //------------------------------------------------------------------------------------------------------------------------ /// <summary> /// Removes the specified child GameObject from this object. /// </summary> /// <param name='child'> /// Child object to remove. /// </param> public void RemoveChild(GameObject child) { if (child.parent == this) { child.parent = null; } }
//------------------------------------------------------------------------------------------------------------------------ // HitTest() //------------------------------------------------------------------------------------------------------------------------ /// <summary> /// Tests if this object overlaps the one specified. /// </summary> /// <returns> /// <c>true</c>, if test was hit, <c>false</c> otherwise. /// </returns> /// <param name='other'> /// Other. /// </param> public virtual bool HitTest(GameObject other) { return _collider != null && other._collider != null && _collider.HitTest (other._collider); }
//------------------------------------------------------------------------------------------------------------------------ // HasChild() //------------------------------------------------------------------------------------------------------------------------ /// <summary> /// Returns 'true' if the specified object is a child of this object. /// </summary> /// <param name='gameObject'> /// The GameObject that should be tested. /// </param> public bool HasChild(GameObject gameObject) { GameObject par = gameObject; while (par != null) { if (par == this) return true; par = par.parent; } return false; }
//------------------------------------------------------------------------------------------------------------------------ // AddChild() //------------------------------------------------------------------------------------------------------------------------ /// <summary> /// Adds the specified GameObject as a child to this one. /// </summary> /// <param name='child'> /// Child object to add. /// </param> public void AddChild(GameObject child) { child.parent = this; }