/// <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); _lastFireDirection = 0f; _lastFireSpeed = 0f; _lastFireScale = 0f; _lastSetupDirection = 0f; _lastSetupSpeed = 0f; _lastSetupScale = 0f; _isRunning = false; }
/// <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) { if (node == null) { throw new NullReferenceException("Node argument cannot be null."); } Node = node; Owner = owner; ChildTasks = new List <BulletMLTask>(); Params = new List <float>(); Finished = false; }
/// <summary> /// Given a node, pull the sprite nodes out from underneath it and store them if necessary. /// </summary> /// <param name="taskToCheck">Node to check.</param> private void GetSpriteNodes(BulletMLTask taskToCheck) { // Check if this fire task has a sprite node var spriteNode = taskToCheck?.Node.GetChild(NodeName.sprite) as SpriteNode; if (spriteNode == null) { return; } if (SpriteTask == null) { SpriteTask = new SpriteTask(spriteNode, taskToCheck); } }
/// <summary> /// Given a node, pull the scale nodes out from underneath it and store them if necessary. /// </summary> /// <param name="taskToCheck">Node to check.</param> private void GetScaleNodes(BulletMLTask taskToCheck) { // Check if this fire task has a scale node var scaleNode = taskToCheck?.Node.GetChild(NodeName.scale) as ScaleNode; if (scaleNode == null) { return; } if (ScaleTask == null) { ScaleTask = new ScaleTask(scaleNode, taskToCheck); } }
/// <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 this fire task has a direction node var directionNode = taskToCheck?.Node.GetChild(NodeName.direction) as DirectionNode; if (directionNode == null) { return; } if (DirectionTask == null) { DirectionTask = new DirectionTask(directionNode, taskToCheck); } }
/// <summary> /// given a label and name, find the task that matches /// </summary> /// <returns>The task by label and name.</returns> /// <param name="strLabel">String label of the task</param> /// <param name="name">the name of the node the task should be attached to</param> public BulletMLTask FindTaskByLabelAndName(string strLabel, NodeName name) { //check if this is the corretc task if ((strLabel == Node.Label) && (name == Node.Name)) { return(this); } //check if any of teh child tasks have a task with that label foreach (BulletMLTask childTask in ChildTasks) { BulletMLTask foundTask = childTask.FindTaskByLabelAndName(strLabel, name); if (null != foundTask) { return(foundTask); } } return(null); }
/// <summary> /// Retrieve the bullet or bulletRef nodes from a fire task. /// </summary> /// <param name="task">Task to check if has a child bullet or bulletRef node.</param> /// <param name="bullet">Associated bullet.</param> private void GetBulletNode(BulletMLTask task, Bullet bullet) { if (task == null) { return; } // Check if there is a bullet or a bulletRef node var bulletNode = task.Node.GetChild(NodeName.bullet) as BulletNode; var bulletRefNode = task.Node.GetChild(NodeName.bulletRef) as BulletRefNode; if (bulletNode != null) { // Create a task for the bullet ref BulletTask = new BulletMLTask(bulletNode, this); BulletTask.ParseTasks(bullet); ChildTasks.Add(BulletTask); } else if (bulletRefNode != null) { // Create a task for the bullet ref BulletTask = new BulletMLTask(bulletRefNode.ReferencedBulletNode, this); // Populate the params of the bullet ref foreach (var node in bulletRefNode.ChildNodes) { BulletTask.Params.Add(node.GetValue(this)); } BulletTask.ParseTasks(bullet); ChildTasks.Add(BulletTask); } else { throw new InvalidDataException("A <fire> node must contain a <bullet> or a <bulletRef> node."); } }
/// <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="ChangeColorTask"/> class. /// </summary> /// <param name="node">Node.</param> /// <param name="owner">Owner.</param> public ChangeColorTask(ChangeColorNode node, BulletMLTask owner) : base(node, owner) { Debug.Assert(null != Node); Debug.Assert(null != Owner); }
/// <summary> /// Initializes a new instance of the <see cref="DirectionTask"/> class. /// </summary> /// <param name="node">Node.</param> /// <param name="owner">Owner.</param> public DirectionTask(DirectionNode 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 WaitTask(WaitNode node, BulletMLTask owner) : base(node, owner) { Debug.Assert(Node != null); Debug.Assert(Owner != null); }
/// <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); }
/// <summary> /// Initializes a new instance of the <see cref="BulletMLTask"/> class. /// </summary> /// <param name="node">Node.</param> /// <param name="owner">Owner.</param> public ScaleTask(ScaleNode 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 SpeedTask(SpeedNode node, BulletMLTask owner) : base(node, owner) { Debug.Assert(null != Node); Debug.Assert(null != Owner); }
/// <summary> /// Initializes a new instance of the <see cref="VanishTask"/> 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); }