Пример #1
0
        /// <summary>
        /// This bullet is fired from another bullet, initialize it from the node that fired it
        /// </summary>
        /// <param name="subNode">Sub node that defines this bullet</param>
        public void InitNode(BulletMLNode subNode)
        {
            Debug.Assert(null != subNode);

            //clear everything out
            Tasks.Clear();

            //Grab that top level node
            MyNode = subNode;

            //found a top num node, add a task for it
            BulletMLTask task = new BulletMLTask(subNode, null);

            //parse the nodes into the task list
            task.ParseTasks(this);

            //initialize all the tasks
            task.InitTask(this);

            Tasks.Add(task);

            //Check if we should change the start heading and speed to adjust for an initial velocity
            if (Vector2.Zero != InitialVelocity)
            {
                //now that the heading and speed have been set, adjust them according to the initial velocity.
                Vector2 final = (Direction.ToVector2() * Speed * Scale) + InitialVelocity;
                Direction = final.Angle();
                Speed     = final.Length() / Scale;
            }
        }
Пример #2
0
        /// <summary>
        /// Parse a specified node and bullet into this task
        /// </summary>
        /// <param name="myNode">the node for this dude</param>
        /// <param name="bullet">the bullet this dude is controlling</param>
        public override void ParseChildNode(BulletMLNode childNode, Bullet bullet)
        {
            System.Diagnostics.Debug.Assert(null != childNode);
            System.Diagnostics.Debug.Assert(null != bullet);

            switch (childNode.Name)
            {
            case ENodeName.bulletRef:
            {
                //Create a task for the bullet ref
                BulletRefNode refNode = childNode as BulletRefNode;
                BulletRefTask = new BulletMLTask(refNode.ReferencedBulletNode, this);

                //populate the params of the bullet ref
                for (int i = 0; i < childNode.ChildNodes.Count; i++)
                {
                    BulletRefTask.ParamList.Add(childNode.ChildNodes[i].GetValue(this));
                }

                BulletRefTask.ParseTasks(bullet);
                ChildTasks.Add(BulletRefTask);
            }
            break;

            case ENodeName.bullet:
            {
                //Create a task for the bullet ref
                BulletRefTask = new BulletMLTask(childNode, this);
                BulletRefTask.ParseTasks(bullet);
                ChildTasks.Add(BulletRefTask);
            }
            break;

            default:
            {
                //run the node through the base class if we don't want it
                base.ParseChildNode(childNode, bullet);
            }
            break;
            }
        }
Пример #3
0
        /// <summary>
        /// This bullet is fired from another bullet, initialize it from the node that fired it
        /// </summary>
        /// <param name="subNode">Sub node that defines this bullet</param>
        public void InitNode(BulletMLNode subNode)
        {
            Debug.Assert(null != subNode);

            //clear everything out
            Tasks.Clear();

            //Grab that top level node
            MyNode = subNode;

            //found a top num node, add a task for it
            BulletMLTask task = new BulletMLTask(subNode, null);

            //parse the nodes into the task list
            task.ParseTasks(this);

            //initialize all the tasks
            task.InitTask(this);

            Tasks.Add(task);
        }
Пример #4
0
        /// <summary>
        /// This bullet is fired from another bullet, initialize it from the node that fired it
        /// </summary>
        /// <param name="subNode">Sub node that defines this bullet</param>
        public void InitNode(BulletMLNode subNode)
        {
            System.Diagnostics.Debug.Assert(null != subNode);

              //clear everything out
              Tasks.Clear();

              //Grab that top level node
              MyNode = subNode;

              //found a top num node, add a task for it
              BulletMLTask task = new BulletMLTask(subNode, null);

              //parse the nodes into the task list
              task.ParseTasks(this);

              //initialize all the tasks
              task.InitTask(this);

              Tasks.Add(task);
        }
Пример #5
0
        /// <summary>
        /// Parse a specified node and bullet into this task
        /// </summary>
        /// <param name="myNode">the node for this dude</param>
        /// <param name="bullet">the bullet this dude is controlling</param>
        public override void ParseChildNode(BulletMLNode childNode, Bullet bullet)
        {
            Debug.Assert(null != childNode);
            Debug.Assert(null != bullet);

            switch (childNode.Name)
            {
                case ENodeName.bulletRef:
                {
                    //Create a task for the bullet ref
                    BulletRefNode refNode = childNode as BulletRefNode;
                    BulletRefTask = new BulletMLTask(refNode.ReferencedBulletNode, this);

                    //populate the params of the bullet ref
                    for (int i = 0; i < childNode.ChildNodes.Count; i++)
                    {
                        BulletRefTask.ParamList.Add(childNode.ChildNodes[i].GetValue(this, bullet));
                    }

                    BulletRefTask.ParseTasks(bullet);
                    ChildTasks.Add(BulletRefTask);
                }
                break;

                case ENodeName.bullet:
                {
                    //Create a task for the bullet ref
                    BulletRefTask = new BulletMLTask(childNode, this);
                    BulletRefTask.ParseTasks(bullet);
                    ChildTasks.Add(BulletRefTask);
                }
                break;

                default:
                {
                    //run the node through the base class if we don't want it
                    base.ParseChildNode(childNode, bullet);
                }
                break;
            }
        }