Ejemplo n.º 1
0
        /// <summary>
        /// Given a node, pull the speed nodes out from underneath it and store them if necessary
        /// </summary>
        /// <param name="taskToCheck">Node to check.</param>
        private void GetSpeedNodes(BulletMLTask taskToCheck)
        {
            //check if the dude has a speed node
            if (!(taskToCheck?.Node.GetChild(ENodeName.speed) is SpeedNode spdNode))
            {
                return;
            }

            //check if it is a sequence type of node
            if (ENodeType.sequence == spdNode.NodeType)
            {
                //do we need a sequence node?
                if (null == SequenceSpeedTask)
                {
                    //store it in the sequence speed node
                    SequenceSpeedTask = new SetSpeedTask(spdNode, taskToCheck);
                }
            }
            else
            {
                //else do we need an initial node?
                if (null == InitialSpeedTask)
                {
                    //store it in the initial speed node
                    InitialSpeedTask = new SetSpeedTask(spdNode, taskToCheck);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Given a node, pull the direction nodes out from underneath it and store them if necessary
        /// </summary>
        /// <param name="taskToCheck">task to check if has a child direction node.</param>
        private void GetDirectionTasks(BulletMLTask taskToCheck)
        {
            //check if the dude has a direction node
            if (!(taskToCheck?.Node.GetChild(ENodeName.direction) is DirectionNode dirNode))
            {
                return;
            }

            //check if it is a sequence type of node
            if (ENodeType.sequence == dirNode.NodeType)
            {
                //do we need a sequence node?
                if (null == SequenceDirectionTask)
                {
                    //store it in the sequence direction node
                    SequenceDirectionTask = new SetDirectionTask(dirNode, taskToCheck);
                }
            }
            else
            {
                //else do we need an initial node?
                if (null == InitialDirectionTask)
                {
                    //store it in the initial direction node
                    InitialDirectionTask = new SetDirectionTask(dirNode, taskToCheck);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FireTask"/> class.
        /// </summary>
        /// <param name="node">Node.</param>
        /// <param name="owner">Owner.</param>
        public FireTask(FireNode node, BulletMLTask owner) : base(node, owner)
        {
            Debug.Assert(null != Node);
            Debug.Assert(null != Owner);

            NumTimesInitialized = 0;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLTask"/> class.
 /// </summary>
 /// <param name="node">Node.</param>
 /// <param name="owner">Owner.</param>
 public BulletMLTask(BulletMLNode node, BulletMLTask owner)
 {
     ChildTasks   = new List <BulletMLTask>();
     ParamList    = new List <float>();
     TaskFinished = false;
     this.Owner   = owner;
     this.Node    = node ?? throw new NullReferenceException("node argument cannot be null");
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Parse a specified node and bullet into this task
        /// </summary>
        /// <param name="childNode">the node for this dude</param>
        /// <param name="bullet">the bullet this dude is controlling</param>
        protected 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
                if (childNode is BulletRefNode refNode)
                {
                    BulletRefTask = new BulletMLTask(refNode.ReferencedBulletNode, this);
                }

                //populate the params of the bullet ref
                foreach (var node in childNode.ChildNodes)
                {
                    BulletRefTask.ParamList.Add(node.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;
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLTask"/> class.
 /// </summary>
 /// <param name="node">Node.</param>
 /// <param name="owner">Owner.</param>
 public AccelTask(AccelNode node, BulletMLTask owner) : base(node, owner)
 {
     Debug.Assert(null != Node);
     Debug.Assert(null != Owner);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLTask"/> class.
 /// </summary>
 /// <param name="node">Node.</param>
 /// <param name="owner">Owner.</param>
 public ChangeDirectionTask(ChangeDirectionNode node, BulletMLTask owner) : base(node, owner)
 {
     Debug.Assert(null != Node);
     Debug.Assert(null != Owner);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLTask"/> class.
 /// </summary>
 /// <param name="node">Node.</param>
 /// <param name="owner">Owner.</param>
 public SetSpeedTask(SpeedNode node, BulletMLTask owner) : base(node, owner)
 {
     Debug.Assert(null != Node);
     Debug.Assert(null != Owner);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLTask"/> class.
 /// </summary>
 /// <param name="node">Node.</param>
 /// <param name="owner">Owner.</param>
 public VanishTask(VanishNode node, BulletMLTask owner) : base(node, owner)
 {
     Debug.Assert(null != Node);
     Debug.Assert(null != Owner);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLTask"/> class.
 /// </summary>
 /// <param name="node">Node.</param>
 /// <param name="owner">Owner.</param>
 public RepeatTask(RepeatNode node, BulletMLTask owner) : base(node, owner)
 {
     Debug.Assert(null != Node);
     Debug.Assert(null != Owner);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLTask"/> class.
 /// </summary>
 /// <param name="node">Node.</param>
 /// <param name="owner">Owner.</param>
 public WaitTask(WaitNode node, BulletMLTask owner) : base(node, owner)
 {
     Debug.Assert(null != Node);
     Debug.Assert(null != Owner);
 }