Example #1
0
        /// <summary>
        /// Add a child node
        /// </summary>
        public void AddChild(NodeBase node)
        {
            if(childList == null)
                childList = new Collection<NodeBase>();

            node.Parent = this;

            childList.Add(node);
        }
Example #2
0
 /// <summary>
 /// it checks whether the node is a child node
 /// </summary>
 public bool IsChild(NodeBase node)
 {
     return childList.Contains(node);
 }
Example #3
0
 /// <summary>
 /// Copy all child nodes to array.
 /// </summary>
 public void GetChildArray(NodeBase[] array)
 {
     childList.CopyTo(array, 0);
 }
Example #4
0
        /// <summary>
        /// Insert a child node
        /// </summary>
        public void InsertChild(int index, NodeBase node)
        {
            node.Parent = this;

            childList.Insert(index, node);
        }
Example #5
0
        /// <summary>
        /// Remove a child node
        /// </summary>
        /// <param name="node">target node</param>
        /// <param name="isRecursive">
        /// whether to remove the child node which has been included in the target node
        /// </param>
        public void RemoveChild(NodeBase node, bool isRecursive)
        {
            if (childList != null)
            {
                if (isRecursive )
                {
                    node.RemoveAllChild(isRecursive);
                }

                childList.Remove(node);
                node.Parent = null;
            }
        }
Example #6
0
 /// <summary>
 /// Remove this node from parent
 /// </summary>
 public void RemoveFromParent()
 {
     if (parent != null)
     {
         parent.RemoveChild(this, false);
         parent = null;
     }
 }
Example #7
0
        /// <summary>
        /// Insert a child node
        /// </summary>
        public void InsertChild(int index, NodeBase node)
        {
            node.Parent = this;

            childList.Insert(index, node);
        }
Example #8
0
 /// <summary>
 /// it checks whether the node is a child node
 /// </summary>
 public bool IsChild(NodeBase node)
 {
     return(childList.Contains(node));
 }
Example #9
0
        /// <summary>
        /// drops weapon at specified position.
        /// </summary>
        /// <param name="position">new drop position</param>
        /// <param name="parent">new scene node</param>
        /// <param name="layer">new collision layer</param>
        public void Drop(Vector3 position, NodeBase parent, CollisionLayer layer)
        {
            //  Detached scene node from owner
            AttachOwner(parent);

            //  Add a collision
            if( layer != null)
                layer.AddCollide(this.Collide);

            DroppedModel.SetRootAxis(
                Matrix.CreateRotationX(MathHelper.ToRadians(-90.0f)));

            this.Position = position;
            this.isDropped = true;
            this.Enabled = true;
            this.Visible = true;
        }
Example #10
0
        /// <summary>
        /// owner acquires weapon.
        /// </summary>
        /// <param name="owner"></param>
        public void Pickup(NodeBase owner)
        {
            //  Attach node to new owner
            AttachOwner(owner);

            //  All weapon model is active
            for (int i = 0; i < modelWeapon.Length; i++)
            {
                this.modelWeapon[i].Enabled = true;
                this.modelWeapon[i].Visible = true;
                this.modelWeapon[i].WorldTransform = Matrix.Identity;
            }

            //  Collision is off
            this.Collide.RemoveInLayer();

            DroppedModel.SetRootAxis(Matrix.Identity);

            this.WorldTransform = Matrix.Identity;
            this.isDropped = false;
            this.Enabled = false;
            this.Visible = false;
        }
Example #11
0
        /// <summary>
        /// sticks to the owner as a child.
        /// Will depend on owner as a child.
        /// </summary>
        /// <param name="owner"></param>
        public void AttachOwner(NodeBase owner)
        {
            DetachOwner();

            if (specData.ModelAlone )
            {
                for (int i = 0; i < specData.ModelCount; i++)
                {
                    //  New parent is owner now
                    this.AddChild(modelWeapon[i]);

                    modelWeapon[i].SetRootAxis(Matrix.Identity);
                }
            }

            owner.AddChild(this);
        }