/// <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> /// Run this task and all subtasks against a bullet. /// This is called once per frame during runtime. /// </summary> /// <returns>TaskRunStatus: whether this task is done, paused, or still running.</returns> /// <param name="bullet">The bullet to update this task against.</param> public override TaskRunStatus Run(Bullet bullet) { _isRunning = true; // Create the new bullet var newBullet = bullet.BulletManager.CreateBullet(); newBullet.X = bullet.X; newBullet.Y = bullet.Y; // Set the new bullet's direction newBullet.Direction = FireDirection; // Set the new bullet's speed newBullet.Speed = FireSpeed; // Set the new bullet's speed newBullet.Scale = FireScale; // Set the new bullet's sprite index if (SpriteTask != null) { newBullet.SpriteIndex = (short)SpriteTask.GetNodeValue(bullet); } // Store the new bullet's direction and speed for the sequence type _lastFireDirection = FireDirection; _lastFireSpeed = FireSpeed; _lastFireScale = FireScale; // Initialize the bullet with the bullet node stored in the fire node var fireNode = Node as FireNode; Debug.Assert(null != fireNode); newBullet.InitNode(fireNode.BulletDescriptionNode); // Set the owner of all the top level tasks for the new bullet to this task foreach (var task in newBullet.Tasks) { task.Owner = this; } Finished = true; return(TaskRunStatus.End); }