コード例 #1
0
ファイル: NodeBase.cs プロジェクト: GodLesZ/svn-dump
        /// <summary>
        /// Add a child node
        /// </summary>
        public void AddChild(NodeBase node)
        {
            if(childList == null)
                childList = new Collection<NodeBase>();

            node.Parent = this;

            childList.Add(node);
        }
コード例 #2
0
ファイル: NodeBase.cs プロジェクト: GodLesZ/svn-dump
 /// <summary>
 /// it checks whether the node is a child node
 /// </summary>
 public bool IsChild(NodeBase node)
 {
     return childList.Contains(node);
 }
コード例 #3
0
ファイル: NodeBase.cs プロジェクト: GodLesZ/svn-dump
 /// <summary>
 /// Copy all child nodes to array.
 /// </summary>
 public void GetChildArray(NodeBase[] array)
 {
     childList.CopyTo(array, 0);
 }
コード例 #4
0
ファイル: NodeBase.cs プロジェクト: GodLesZ/svn-dump
        /// <summary>
        /// Insert a child node
        /// </summary>
        public void InsertChild(int index, NodeBase node)
        {
            node.Parent = this;

            childList.Insert(index, node);
        }
コード例 #5
0
ファイル: NodeBase.cs プロジェクト: GodLesZ/svn-dump
        /// <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;
            }
        }
コード例 #6
0
ファイル: NodeBase.cs プロジェクト: GodLesZ/svn-dump
 /// <summary>
 /// Remove this node from parent
 /// </summary>
 public void RemoveFromParent()
 {
     if (parent != null)
     {
         parent.RemoveChild(this, false);
         parent = null;
     }
 }
コード例 #7
0
        /// <summary>
        /// Insert a child node
        /// </summary>
        public void InsertChild(int index, NodeBase node)
        {
            node.Parent = this;

            childList.Insert(index, node);
        }
コード例 #8
0
 /// <summary>
 /// it checks whether the node is a child node
 /// </summary>
 public bool IsChild(NodeBase node)
 {
     return(childList.Contains(node));
 }
コード例 #9
0
ファイル: GameWeapon.cs プロジェクト: GodLesZ/svn-dump
        /// <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;
        }
コード例 #10
0
ファイル: GameWeapon.cs プロジェクト: GodLesZ/svn-dump
        /// <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;
        }
コード例 #11
0
ファイル: GameWeapon.cs プロジェクト: GodLesZ/svn-dump
        /// <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);
        }