示例#1
0
        public void BulletSpeedTaskValue3()
        {
            string filename = @"Content\BulletSpeed.xml";

            pattern.ParseXML(filename);
            Mover mover = (Mover)manager.CreateBullet();

            mover.InitTopNode(pattern.RootNode);
            BulletMLTask myTask    = mover.Tasks[0];
            FireTask     testTask  = myTask.ChildTasks[0] as FireTask;
            SetSpeedTask speedTask = testTask.InitialSpeedTask as SetSpeedTask;
            SpeedNode    speedNode = speedTask.Node as SpeedNode;

            Assert.AreEqual(10.0f, speedNode.GetValue(speedTask, mover));
        }
示例#2
0
        public void FireSpeedTaskValue3()
        {
            var filename = new Filename(@"FireSpeed.xml");

            pattern.ParseXML(filename.File);
            Mover mover = (Mover)manager.CreateBullet();

            mover.InitTopNode(pattern.RootNode);
            BulletMLTask myTask    = mover.Tasks[0];
            FireTask     testTask  = myTask.ChildTasks[0] as FireTask;
            SetSpeedTask speedTask = testTask.InitialSpeedTask as SetSpeedTask;
            SpeedNode    speedNode = speedTask.Node as SpeedNode;

            Assert.AreEqual(5.0f, speedNode.GetValue(speedTask, mover));
        }
示例#3
0
        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));
        }
示例#4
0
        /// <summary>
        /// Run this task and all subtasks against a bullet
        /// This is called once a frame during runtime.
        /// </summary>
        /// <returns>ERunStatus: whether this task is done, paused, or still running</returns>
        /// <param name="bullet">The bullet to update this task against.</param>
        public override ERunStatus Run(Bullet bullet)
        {
            //Find which direction to shoot the new bullet
            if (DirNode != null)
            {
                //get the direction continade in the node
                float newBulletDirection = (int)DirNode.GetValue(this) * (float)Math.PI / (float)180;
                switch (DirNode.NodeType)
                {
                case ENodeType.sequence:
                {
                    bullet.GetFireData().srcDir += newBulletDirection;
                }
                break;

                case ENodeType.absolute:
                {
                    bullet.GetFireData().srcDir = newBulletDirection;
                }
                break;

                case ENodeType.relative:
                {
                    bullet.GetFireData().srcDir = newBulletDirection + bullet.Direction;
                }
                break;

                default:
                {
                    bullet.GetFireData().srcDir = newBulletDirection + bullet.GetAimDir();
                }
                break;
                }
            }
            else
            {
                //otherwise if no direction node, aim the bullet at the bad guy
                bullet.GetFireData().srcDir = bullet.GetAimDir();
            }

            //Create the new bullet
            Bullet newBullet = bullet.MyBulletManager.CreateBullet();

            if (newBullet == null)
            {
                //wtf did you do???
                TaskFinished = true;
                return(ERunStatus.End);
            }

            //initialize the bullet from a reference node, or our bullet node
            if (RefNode != null)
            {
                //Add an empty task to the bullet and populate it with all the params
                BulletMLTask bulletBlankTask = newBullet.CreateTask();

                //Add all the params to the new task we just added to that bullet
                for (int i = 0; i < RefNode.ChildNodes.Count; i++)
                {
                    bulletBlankTask.ParamList.Add(RefNode.ChildNodes[i].GetValue(this));
                }

                //init the bullet now that all our stuff is prepopulated
                BulletMLNode subNode = bullet.MyNode.GetRootNode().FindLabelNode(RefNode.Label, ENodeName.bullet);
                newBullet.Init(subNode);
            }
            else
            {
                //if there is no ref node, there has to be  bullet node
                newBullet.Init(BulletNode);
            }

            //set the location of the new bullet
            newBullet.X = bullet.X;
            newBullet.Y = bullet.Y;

            //set the owner of the new bullet to this dude
            newBullet._tasks[0].Owner = this;

            //set the direction of the new bullet
            newBullet.Direction = bullet.GetFireData().srcDir;

            //Has the speed for new bullets been set in the source bullet yet?
            if (!bullet.GetFireData().speedInit&& newBullet.GetFireData().speedInit)
            {
                bullet.GetFireData().srcSpeed  = newBullet.Velocity;
                bullet.GetFireData().speedInit = true;
            }
            else
            {
                //find the speed for new bullets and store it in the source bullet
                if (SpeedNode != null)
                {
                    //Get the speed from a speed node
                    float newBulletSpeed = SpeedNode.GetValue(this);
                    if (SpeedNode.NodeType == ENodeType.sequence || SpeedNode.NodeType == ENodeType.relative)
                    {
                        bullet.GetFireData().srcSpeed += newBulletSpeed;
                    }
                    else
                    {
                        bullet.GetFireData().srcSpeed = newBulletSpeed;
                    }
                }
                else
                {
                    if (!newBullet.GetFireData().speedInit)
                    {
                        bullet.GetFireData().srcSpeed = 1;
                    }
                    else
                    {
                        bullet.GetFireData().srcSpeed = newBullet.Velocity;
                    }
                }
            }

            newBullet.GetFireData().speedInit = false;
            newBullet.Velocity = bullet.GetFireData().srcSpeed;

            TaskFinished = true;
            return(ERunStatus.End);
        }