public void NoSubTasks() { var filename = TestUtils.GetFilePath(@"Content\FireSpeed.xml"); TestUtils.Pattern.Parse(filename); Mover mover = (Mover)TestUtils.Manager.CreateBullet(); mover.InitTopNode(TestUtils.Pattern.RootNode); BulletMLTask myTask = mover.Tasks[0]; BulletML.Tasks.FireTask testTask = myTask.ChildTasks[0] as BulletML.Tasks.FireTask; Assert.AreEqual(1, testTask.ChildTasks.Count); }
public void BulletSpeedInitInitCorrect1() { var filename = TestUtils.GetFilePath(@"Content\BulletSpeed.xml"); TestUtils.Pattern.Parse(filename); Mover mover = (Mover)TestUtils.Manager.CreateBullet(); mover.InitTopNode(TestUtils.Pattern.RootNode); BulletMLTask myTask = mover.Tasks[0]; BulletML.Tasks.FireTask testTask = myTask.ChildTasks[0] as BulletML.Tasks.FireTask; Assert.IsTrue(testTask.SpeedTask is SpeedTask); }
public void CorrectAction2() { var filename = TestUtils.GetFilePath(@"Content\FireSpeed.xml"); TestUtils.Pattern.Parse(filename); Mover mover = (Mover)TestUtils.Manager.CreateBullet(); mover.InitTopNode(TestUtils.Pattern.RootNode); BulletMLTask myTask = mover.Tasks[0]; BulletML.Tasks.FireTask testTask = myTask.ChildTasks[0] as BulletML.Tasks.FireTask; Assert.IsNotNull(testTask.Node); Assert.IsTrue(testTask.Node.Name == NodeName.fire); }
public void FireSpeedTaskValue1() { var filename = TestUtils.GetFilePath(@"Content\FireSpeed.xml"); TestUtils.Pattern.Parse(filename); Mover mover = (Mover)TestUtils.Manager.CreateBullet(); mover.InitTopNode(TestUtils.Pattern.RootNode); BulletMLTask myTask = mover.Tasks[0]; BulletML.Tasks.FireTask testTask = myTask.ChildTasks[0] as BulletML.Tasks.FireTask; SpeedTask speedTask = testTask.SpeedTask as SpeedTask; Assert.IsTrue(speedTask.Node is SpeedNode); }
public void BulletSpeedTaskValue3() { var filename = TestUtils.GetFilePath(@"Content\BulletSpeed.xml"); TestUtils.Pattern.Parse(filename); Mover mover = (Mover)TestUtils.Manager.CreateBullet(); mover.InitTopNode(TestUtils.Pattern.RootNode); BulletMLTask myTask = mover.Tasks[0]; BulletML.Tasks.FireTask testTask = myTask.ChildTasks[0] as BulletML.Tasks.FireTask; SpeedTask speedTask = testTask.SpeedTask as SpeedTask; SpeedNode speedNode = speedTask.Node as SpeedNode; Assert.AreEqual(10.0f, speedNode.GetValue(speedTask)); }
/// <summary> /// Parse a specified node and bullet into this task. /// </summary> /// <param name="childNode">The node for this task.</param> /// <param name="bullet">The bullet this task is controlling.</param> private void ParseChildNode(BulletMLNode childNode, Bullet bullet) { Debug.Assert(null != childNode); Debug.Assert(null != bullet); // Construct the correct type of node switch (childNode.Name) { case NodeName.repeat: { // Convert the node to an repeatnode var repeatNode = childNode as RepeatNode; // Create a placeholder BulletMLTask for the repeat node var repeatTask = new RepeatTask(repeatNode, this); // Parse the child nodes into the repeat task repeatTask.ParseTasks(bullet); // Store the task ChildTasks.Add(repeatTask); } break; case NodeName.action: { // Convert the node to an ActionNode var actionNode = childNode as ActionNode; // Create the action task var actionTask = new ActionTask(actionNode, this); // Parse the children of the action node into the task actionTask.ParseTasks(bullet); // Store the task ChildTasks.Add(actionTask); } break; case NodeName.actionRef: { // Convert the node to an ActionNode var actionRefNode = childNode as ActionRefNode; // Create the action task var actionTask = new ActionTask(actionRefNode, this); // Add the params to the action task for (int i = 0; i < childNode.ChildNodes.Count; i++) { actionTask.Params.Add(childNode.ChildNodes[i].GetValue(this)); } // Parse the children of the action node into the task actionTask.ParseTasks(bullet); // Store the task ChildTasks.Add(actionTask); } break; case NodeName.fire: { // Convert the node to a fire node var fireNode = childNode as FireNode; // Create the fire task var fireTask = new FireTask(fireNode, this); // Parse the children of the fire node into the task fireTask.ParseTasks(bullet); // Store the task ChildTasks.Add(fireTask); } break; case NodeName.fireRef: { // Convert the node to a fireRef node var fireRefNode = childNode as FireRefNode; // Create the fire task if (fireRefNode != null) { var fireTask = new FireTask(fireRefNode.ReferencedFireNode, this); // Add the params to the fire task for (int i = 0; i < childNode.ChildNodes.Count; i++) { fireTask.Params.Add(childNode.ChildNodes[i].GetValue(this)); } // Parse the children of the action node into the task fireTask.ParseTasks(bullet); // Store the task ChildTasks.Add(fireTask); } } break; case NodeName.changeSpeed: { ChildTasks.Add(new ChangeSpeedTask(childNode as ChangeSpeedNode, this)); } break; case NodeName.changeDirection: { ChildTasks.Add(new ChangeDirectionTask(childNode as ChangeDirectionNode, this)); } break; case NodeName.wait: { ChildTasks.Add(new WaitTask(childNode as WaitNode, this)); } break; case NodeName.vanish: { ChildTasks.Add(new VanishTask(childNode as VanishNode, this)); } break; case NodeName.accel: { ChildTasks.Add(new AccelTask(childNode as AccelNode, this)); } break; case NodeName.color: { ChildTasks.Add(new ColorTask(childNode as ColorNode, this)); } break; case NodeName.changeColor: { ChildTasks.Add(new ChangeColorTask(childNode as ChangeColorNode, this)); } break; case NodeName.changeScale: { ChildTasks.Add(new ChangeScaleTask(childNode as ChangeScaleNode, this)); } break; } }