BulletMLタスク 実際に弾を動かすクラス
Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BulletMLLib.FireTask"/> class.
        /// </summary>
        /// <param name="node">Node.</param>
        /// <param name="owner">Owner.</param>
        public FireTask(FireNode node, BulletMLTask owner) : base(node, owner)
        {
            System.Diagnostics.Debug.Assert(null != Node);
            System.Diagnostics.Debug.Assert(null != Owner);

            NumTimesInitialized = 0;
        }
Esempio 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)
        {
            if (null == taskToCheck)
            {
                return;
            }

            //check if the dude has a direction node
            DirectionNode dirNode = taskToCheck.Node.GetChild(ENodeName.direction) as DirectionNode;

            if (null != dirNode)
            {
                //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 as DirectionNode, taskToCheck);
                    }
                }
                else
                {
                    //else do we need an initial node?
                    if (null == InitialDirectionTask)
                    {
                        //store it in the initial direction node
                        InitialDirectionTask = new SetDirectionTask(dirNode as DirectionNode, taskToCheck);
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BulletMLLib.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;
        }
Esempio n. 4
0
        /// <summary>
        /// This bullet is fired from another bullet, initialize it from the node that fired it
        /// </summary>
        /// <param name="subNode">Sub node that defines this bullet</param>
        public void InitNode(BulletMLNode subNode)
        {
            Debug.Assert(null != subNode);

            //clear everything out
            Tasks.Clear();

            //Grab that top level node
            MyNode = subNode;

            //found a top num node, add a task for it
            BulletMLTask task = new BulletMLTask(subNode, null);

            //parse the nodes into the task list
            task.ParseTasks(this);

            //initialize all the tasks
            task.InitTask(this);

            Tasks.Add(task);

            //Check if we should change the start heading and speed to adjust for an initial velocity
            if (Vector2.Zero != InitialVelocity)
            {
                //now that the heading and speed have been set, adjust them according to the initial velocity.
                Vector2 final = (Direction.ToVector2() * Speed * Scale) + InitialVelocity;
                Direction = final.Angle();
                Speed     = final.Length() / Scale;
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLLib.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);
     X = 0f;
     Y = 0f;
 }
Esempio n. 6
0
        /// <summary>
        /// Given a node, pull the speed nodes out from underneath it and store them if necessary
        /// </summary>
        /// <param name="nodeToCheck">Node to check.</param>
        private void GetSpeedNodes(BulletMLTask taskToCheck)
        {
            if (null == taskToCheck)
            {
                return;
            }

            //check if the dude has a speed node
            SpeedNode spdNode = taskToCheck.Node.GetChild(ENodeName.speed) as SpeedNode;

            if (null != spdNode)
            {
                //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 as SpeedNode, taskToCheck);
                    }
                }
                else
                {
                    //else do we need an initial node?
                    if (null == InitialSpeedTask)
                    {
                        //store it in the initial speed node
                        InitialSpeedTask = new SetSpeedTask(spdNode as SpeedNode, taskToCheck);
                    }
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BulletMLLib.FireTask"/> class.
        /// </summary>
        /// <param name="node">Node.</param>
        /// <param name="owner">Owner.</param>
        public FireTask(FireNode node, BulletMLTask owner)
            : base(node, owner)
        {
            System.Diagnostics.Debug.Assert(null != Node);
            System.Diagnostics.Debug.Assert(null != Owner);

            NumTimesInitialized = 0;
        }
Esempio n. 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BulletMLLib.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;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BulletMLLib.ActionTask"/> class.
        /// </summary>
        /// <param name="repeatNumMax">Repeat number max.</param>
        /// <param name="node">Node.</param>
        /// <param name="owner">Owner.</param>
        public ActionTask(ActionNode node, BulletMLTask owner)
            : base(node, owner)
        {
            System.Diagnostics.Debug.Assert(null != Node);
            System.Diagnostics.Debug.Assert(null != Owner);

            //set the number of times to repeat this action
            RepeatNumMax = node.RepeatNum(this);
        }
Esempio n. 10
0
        //枝の途中からの初期化
        public void Init(BulletMLTree node)
        {
            BulletMLTask task = tasks[0];

            task.taskList.Clear();
            task.Parse(node, this);
            task.Init();
            this.tree = node;
        }
Esempio n. 11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BulletMLLib.ActionTask"/> class.
        /// </summary>
        /// <param name="repeatNumMax">Repeat number max.</param>
        /// <param name="node">Node.</param>
        /// <param name="owner">Owner.</param>
        public ActionTask(ActionNode node, BulletMLTask owner)
            : base(node, owner)
        {
            System.Diagnostics.Debug.Assert(null != Node);
              System.Diagnostics.Debug.Assert(null != Owner);

              //set the number of times to repeat this action
              RepeatNumMax = node.RepeatNum(this);
        }
Esempio n. 12
0
 public float GetChildValue(BLName name, BulletMLTask task)
 {
     foreach (BulletMLTree tree in Children)
     {
         if (tree.Name == name)
             return tree.GetValue(task);
     }
     return 0;
 }
Esempio n. 13
0
 /// <summary>
 /// Gets the value of a specific type of child node for a task
 /// </summary>
 /// <returns>The child value. return 0.0 if no node found</returns>
 /// <param name="name">type of child node we want.</param>
 /// <param name="task">Task to get a value for</param>
 public float GetChildValue(ENodeName name, BulletMLTask task, Bullet bullet)
 {
     foreach (BulletMLNode tree in ChildNodes)
     {
         if (tree.Name == name)
         {
             return(tree.GetValue(task, bullet));
         }
     }
     return(0.0f);
 }
Esempio n. 14
0
 public float GetChildValue(BLName name, BulletMLTask task)
 {
     foreach (BulletMLTree tree in Children)
     {
         if (tree.Name == name)
         {
             return(tree.GetValue(task));
         }
     }
     return(0);
 }
Esempio n. 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BulletMLLib.BulletMLTask"/> class.
        /// </summary>
        /// <param name="node">Node.</param>
        /// <param name="owner">Owner.</param>
        public BulletMLTask(BulletMLNode node, BulletMLTask owner)
        {
            if (null == node)
            {
                throw new NullReferenceException("node argument cannot be null");
            }

            ChildTasks = new List<BulletMLTask>();
            ParamList = new List<float>();
            TaskFinished = false;
            this.Owner = owner;
            this.Node = node;
        }
Esempio n. 16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BulletMLLib.BulletMLTask"/> class.
        /// </summary>
        /// <param name="node">Node.</param>
        /// <param name="owner">Owner.</param>
        public BulletMLTask(BulletMLNode node, BulletMLTask owner)
        {
            if (null == node)
            {
                throw new NullReferenceException("node argument cannot be null");
            }

            ChildTasks   = new List <BulletMLTask>();
            ParamList    = new List <float>();
            TaskFinished = false;
            this.Owner   = owner;
            this.Node    = node;
        }
Esempio n. 17
0
        /// <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="eName">the name of the node the task should be attached to</param>
        public BulletMLTask FindTaskByLabelAndName(string strLabel, ENodeName eName)
        {
            //check if any of teh child tasks have a task with that label
            foreach (BulletMLTask childTask in Tasks)
            {
                BulletMLTask foundTask = childTask.FindTaskByLabelAndName(strLabel, eName);
                if (null != foundTask)
                {
                    return(foundTask);
                }
            }

            return(null);
        }
Esempio n. 18
0
        /// <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="eName">the name of the node the task should be attached to</param>
        public BulletMLTask FindTaskByLabelAndName(string strLabel, ENodeName eName)
        {
            //check if this is the corretc task
            if ((strLabel == Node.Label) && (eName == 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, eName);
                if (null != foundTask)
                {
                    return(foundTask);
                }
            }

            return(null);
        }
Esempio n. 19
0
        /// <summary>
        /// Parse a specified node and bullet into this task
        /// </summary>
        /// <param name="myNode">the node for this dude</param>
        /// <param name="bullet">the bullet this dude is controlling</param>
        public override void ParseChildNode(BulletMLNode childNode, Bullet bullet)
        {
            System.Diagnostics.Debug.Assert(null != childNode);
            System.Diagnostics.Debug.Assert(null != bullet);

            switch (childNode.Name)
            {
            case ENodeName.bulletRef:
            {
                //Create a task for the bullet ref
                BulletRefNode refNode = childNode as BulletRefNode;
                BulletRefTask = new BulletMLTask(refNode.ReferencedBulletNode, this);

                //populate the params of the bullet ref
                for (int i = 0; i < childNode.ChildNodes.Count; i++)
                {
                    BulletRefTask.ParamList.Add(childNode.ChildNodes[i].GetValue(this));
                }

                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;
            }
        }
Esempio n. 20
0
        /// <summary>
        /// This bullet is fired from another bullet, initialize it from the node that fired it
        /// </summary>
        /// <param name="subNode">Sub node that defines this bullet</param>
        public void InitNode(BulletMLNode subNode)
        {
            Debug.Assert(null != subNode);

            //clear everything out
            Tasks.Clear();

            //Grab that top level node
            MyNode = subNode;

            //found a top num node, add a task for it
            BulletMLTask task = new BulletMLTask(subNode, null);

            //parse the nodes into the task list
            task.ParseTasks(this);

            //initialize all the tasks
            task.InitTask(this);

            Tasks.Add(task);
        }
Esempio n. 21
0
        //木構造のトップからの初期化
        public void InitTop(BulletMLTree node)
        {
            //トップノードからの初期化
            this.tree = node;
            //task.taskList.Clear();
            //task.Parse(tree);
            //task.Init();

            BulletMLTree tree = node.GetLabelNode("top", BLName.Action);

            if (tree != null)
            {
                BulletMLTask task = tasks[0];
                task.taskList.Clear();
                task.Parse(tree, this);
                task.Init();
            }
            else
            {
                for (int i = 1; i < 10; i++)
                {
                    BulletMLTree tree2 = node.GetLabelNode("top" + i, BLName.Action);
                    if (tree2 != null)
                    {
                        if (i > 1)
                        {
                            tasks.Add(new BulletMLTask());
                            fireData.Add(new FireData());
                        }

                        BulletMLTask task = tasks[i - 1];
                        task.taskList.Clear();
                        task.Parse(tree2, this);
                        task.Init();
                    }
                }
            }
        }
Esempio n. 22
0
        float GetNumValue(BulletValue v, BulletMLTask task)
        {
            if (v.ValueType == BLValueType.Number)
            {
                return(v.Value);
            }
            else if (v.ValueType == BLValueType.Rand)
            {
                return((float)BulletMLManager.GetRandom());
            }
            else if (v.ValueType == BLValueType.Rank)
            {
                return(BulletMLManager.GetRank());
            }
            else if (v.ValueType == BLValueType.Param)
            {
                BulletMLTask ownerTask = task;
                while (ownerTask.ParamList.Count == 0)
                {
                    ownerTask = ownerTask.Owner;
                }
                float val = ownerTask.ParamList[(int)v.Value - 1];

                //BulletMLTask ownerTask = task;
                //while (ownerTask.paramNode == null)
                //    ownerTask = ownerTask.owner;
                //float val = ownerTask.paramNode.children[(int)v.value - 1].GetValue(ownerTask.owner);

                //Debug.WriteLine(String.Format( "{2} param{0} = {1}", (int)v.value - 1, val, ownerTask));
                return(val);
            }
            else
            {
                //Debug.WriteLine("不正な値がパラメータになっています");
                return(0);
            }
        }
Esempio n. 23
0
 internal float GetParam(int p, BulletMLTask task)
 {
     return Children[p].GetValue(task); //<param>以外のタグは持っていないので
 }
Esempio n. 24
0
        float GetNumValue(BulletValue v, BulletMLTask task)
        {
            if (v.ValueType == BLValueType.Number)
            {
                return v.Value;
            }
            else if (v.ValueType == BLValueType.Rand)
            {
                return (float)BulletMLManager.GetRandom();
            }
            else if (v.ValueType == BLValueType.Rank)
            {
                return BulletMLManager.GetRank();
            }
            else if (v.ValueType == BLValueType.Param)
            {

                BulletMLTask ownerTask = task;
                while (ownerTask.ParamList.Count == 0)
                    ownerTask = ownerTask.Owner;
                float val = ownerTask.ParamList[(int)v.Value - 1];

                //BulletMLTask ownerTask = task;
                //while (ownerTask.paramNode == null)
                //    ownerTask = ownerTask.owner;
                //float val = ownerTask.paramNode.children[(int)v.value - 1].GetValue(ownerTask.owner);

                //Debug.WriteLine(String.Format( "{2} param{0} = {1}", (int)v.value - 1, val, ownerTask));
                return val;
            }
            else
            {
                //Debug.WriteLine("不正な値がパラメータになっています");
                return 0;
            }
        }
Esempio n. 25
0
 internal float GetParam(int p, BulletMLTask task)
 {
     return(Children[p].GetValue(task)); //<param>以外のタグは持っていないので
 }
Esempio n. 26
0
        public float GetValue(BulletMLTask task)
        {
            int startIndex = 0;

            return GetValue(0, ref startIndex, task);
        }
Esempio n. 27
0
        public float GetValue(BulletMLTask task)
        {
            int startIndex = 0;

            return(GetValue(0, ref startIndex, task));
        }
Esempio n. 28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLLib.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);
 }
Esempio n. 29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLLib.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);
 }
Esempio n. 30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLLib.BulletMLTask"/> class.
 /// </summary>
 /// <param name="node">Node.</param>
 /// <param name="owner">Owner.</param>
 public AccelTask(AccelNode node, BulletMLTask owner)
     : base(node, owner)
 {
     System.Diagnostics.Debug.Assert(null != Node);
       System.Diagnostics.Debug.Assert(null != Owner);
 }
Esempio n. 31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLLib.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);
 }
Esempio n. 32
0
 /// <summary>
 /// Gets the value of this node for a specific instance of a task.
 /// </summary>
 /// <returns>The value.</returns>
 /// <param name="task">Task.</param>
 public float GetValue(BulletMLTask task)
 {
     //send to the equation for an answer
       return NodeEquation.Solve(task.GetParamValue);
 }
Esempio n. 33
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLLib.BulletMLTask"/> class.
 /// </summary>
 /// <param name="node">Node.</param>
 /// <param name="owner">Owner.</param>
 public SetDirectionTask(DirectionNode node, BulletMLTask owner)
     : base(node, owner)
 {
     System.Diagnostics.Debug.Assert(null != Node);
     System.Diagnostics.Debug.Assert(null != Owner);
 }
Esempio n. 34
0
 /// <summary>
 /// Gets the value of a specific type of child node for a task
 /// </summary>
 /// <returns>The child value. return 0.0 if no node found</returns>
 /// <param name="name">type of child node we want.</param>
 /// <param name="task">Task to get a value for</param>
 public float GetChildValue(ENodeName name, BulletMLTask task, Bullet bullet)
 {
     foreach (BulletMLNode tree in ChildNodes)
     {
         if (tree.Name == name)
         {
             return tree.GetValue(task, bullet);
         }
     }
     return 0.0f;
 }
Esempio n. 35
0
        public float GetValue(float v, ref int i, BulletMLTask task)
        {
            for (; i < Values.Count; i++)
            {

                if (Values[i].ValueType == BLValueType.Operator)
                {
                    if (Values[i].Value == '+')
                    {
                        i++;
                        if (IsNextNum(i))
                            v += GetNumValue(Values[i], task);
                        else
                            v += GetValue(v, ref i, task);
                    }
                    else if (Values[i].Value == '-')
                    {
                        i++;
                        if (IsNextNum(i))
                            v -= GetNumValue(Values[i], task);
                        else
                            v -= GetValue(v, ref i, task);
                    }
                    else if (Values[i].Value == '*')
                    {
                        i++;
                        if (IsNextNum(i))
                            v *= GetNumValue(Values[i], task);
                        else
                            v *= GetValue(v, ref i, task);
                    }
                    else if (Values[i].Value == '/')
                    {
                        i++;
                        if (IsNextNum(i))
                            v /= GetNumValue(Values[i], task);
                        else
                            v /= GetValue(v, ref i, task);
                    }
                    else if (Values[i].Value == '(')
                    {
                        i++;
                        float res = GetValue(v, ref i, task);
                        if ((i < Values.Count - 1 && Values[i + 1].ValueType == BLValueType.Operator)
                               && (Values[i + 1].Value == '*' || Values[i + 1].Value == '/'))
                            return GetValue(res, ref i, task);
                        else
                            return res;
                    }
                    else if (Values[i].Value == ')')
                    {
                        //Debug.WriteLine(" )の戻り値:" + v);
                        return v;
                    }
                }
                else if (i < Values.Count - 1 && Values[i + 1].ValueType == BLValueType.Operator && Values[i + 1].Value == '*')
                {
                    // 次が掛け算のとき
                    float val = GetNumValue(Values[i], task);
                    i += 2;
                    if (IsNextNum(i))
                        return val * GetNumValue(Values[i], task);
                    else
                        return val * GetValue(v, ref i, task);
                }
                else if (i < Values.Count - 1 && Values[i + 1].ValueType == BLValueType.Operator && Values[i + 1].Value == '/')
                {
                    // 次が割り算のとき
                    float val = GetNumValue(Values[i], task);
                    i += 2;
                    if (IsNextNum(i))
                        return val / GetNumValue(Values[i], task);
                    else
                        return val / GetValue(v, ref i, task);
                }
                else
                    v = GetNumValue(Values[i], task);

            }

            return v;
        }
Esempio n. 36
0
        public float GetValue(float v, ref int i, BulletMLTask task)
        {
            for (; i < Values.Count; i++)
            {
                if (Values[i].ValueType == BLValueType.Operator)
                {
                    if (Values[i].Value == '+')
                    {
                        i++;
                        if (IsNextNum(i))
                        {
                            v += GetNumValue(Values[i], task);
                        }
                        else
                        {
                            v += GetValue(v, ref i, task);
                        }
                    }
                    else if (Values[i].Value == '-')
                    {
                        i++;
                        if (IsNextNum(i))
                        {
                            v -= GetNumValue(Values[i], task);
                        }
                        else
                        {
                            v -= GetValue(v, ref i, task);
                        }
                    }
                    else if (Values[i].Value == '*')
                    {
                        i++;
                        if (IsNextNum(i))
                        {
                            v *= GetNumValue(Values[i], task);
                        }
                        else
                        {
                            v *= GetValue(v, ref i, task);
                        }
                    }
                    else if (Values[i].Value == '/')
                    {
                        i++;
                        if (IsNextNum(i))
                        {
                            v /= GetNumValue(Values[i], task);
                        }
                        else
                        {
                            v /= GetValue(v, ref i, task);
                        }
                    }
                    else if (Values[i].Value == '(')
                    {
                        i++;
                        float res = GetValue(v, ref i, task);
                        if ((i < Values.Count - 1 && Values[i + 1].ValueType == BLValueType.Operator) &&
                            (Values[i + 1].Value == '*' || Values[i + 1].Value == '/'))
                        {
                            return(GetValue(res, ref i, task));
                        }
                        else
                        {
                            return(res);
                        }
                    }
                    else if (Values[i].Value == ')')
                    {
                        //Debug.WriteLine(" )の戻り値:" + v);
                        return(v);
                    }
                }
                else if (i < Values.Count - 1 && Values[i + 1].ValueType == BLValueType.Operator && Values[i + 1].Value == '*')
                {
                    // 次が掛け算のとき
                    float val = GetNumValue(Values[i], task);
                    i += 2;
                    if (IsNextNum(i))
                    {
                        return(val * GetNumValue(Values[i], task));
                    }
                    else
                    {
                        return(val * GetValue(v, ref i, task));
                    }
                }
                else if (i < Values.Count - 1 && Values[i + 1].ValueType == BLValueType.Operator && Values[i + 1].Value == '/')
                {
                    // 次が割り算のとき
                    float val = GetNumValue(Values[i], task);
                    i += 2;
                    if (IsNextNum(i))
                    {
                        return(val / GetNumValue(Values[i], task));
                    }
                    else
                    {
                        return(val / GetValue(v, ref i, task));
                    }
                }
                else
                {
                    v = GetNumValue(Values[i], task);
                }
            }

            return(v);
        }
Esempio n. 37
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)
        {
            if (null == taskToCheck)
            {
                return;
            }

            //check if the dude has a direction node
            DirectionNode dirNode = taskToCheck.Node.GetChild(ENodeName.direction) as DirectionNode;
            if (null != dirNode)
            {
                //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 as DirectionNode, taskToCheck);
                    }
                }
                else
                {
                    //else do we need an initial node?
                    if (null == InitialDirectionTask)
                    {
                        //store it in the initial direction node
                        InitialDirectionTask = new SetDirectionTask(dirNode as DirectionNode, taskToCheck);
                    }
                }
            }
        }
Esempio n. 38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLLib.BulletMLTask"/> class.
 /// </summary>
 /// <param name="node">Node.</param>
 /// <param name="owner">Owner.</param>
 public VanishTask(VanishNode node, BulletMLTask owner) : base(node, owner)
 {
     System.Diagnostics.Debug.Assert(null != Node);
     System.Diagnostics.Debug.Assert(null != Owner);
 }
Esempio n. 39
0
        /// <summary>
        /// Given a node, pull the speed nodes out from underneath it and store them if necessary
        /// </summary>
        /// <param name="nodeToCheck">Node to check.</param>
        private void GetSpeedNodes(BulletMLTask taskToCheck)
        {
            if (null == taskToCheck)
            {
                return;
            }

            //check if the dude has a speed node
            SpeedNode spdNode = taskToCheck.Node.GetChild(ENodeName.speed) as SpeedNode;
            if (null != spdNode)
            {
                //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 as SpeedNode, taskToCheck);
                    }
                }
                else
                {
                    //else do we need an initial node?
                    if (null == InitialSpeedTask)
                    {
                        //store it in the initial speed node
                        InitialSpeedTask = new SetSpeedTask(spdNode as SpeedNode, taskToCheck);
                    }
                }
            }
        }
Esempio n. 40
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLLib.ActionTask"/> class.
 /// </summary>
 /// <param name="repeatNumMax">Repeat number max.</param>
 /// <param name="node">Node.</param>
 /// <param name="owner">Owner.</param>
 public ActionTask(ActionNode node, BulletMLTask owner)
     : base(node, owner)
 {
     Debug.Assert(null != Node);
     Debug.Assert(null != Owner);
 }
Esempio n. 41
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLLib.BulletMLTask"/> class.
 /// </summary>
 /// <param name="node">Node.</param>
 /// <param name="owner">Owner.</param>
 public TriggerTask(TriggerNode node, BulletMLTask owner)
     : base(node, owner)
 {
     System.Diagnostics.Debug.Assert(null != Node);
     System.Diagnostics.Debug.Assert(null != Owner);
 }
Esempio n. 42
0
 /// <summary>
 /// Gets the value of this node for a specific instance of a task.
 /// </summary>
 /// <returns>The value.</returns>
 /// <param name="task">Task.</param>
 public float GetValue(BulletMLTask task, Bullet bullet)
 {
     //send to the equation for an answer
     return(NodeEquation.Solve(task.GetParamValue, bullet.MyBulletManager.Tier));
 }
Esempio n. 43
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLLib.BulletMLTask"/> class.
 /// </summary>
 /// <param name="node">Node.</param>
 /// <param name="owner">Owner.</param>
 public AccelTask(AccelNode node, BulletMLTask owner) : base(node, owner)
 {
     System.Diagnostics.Debug.Assert(null != Node);
     System.Diagnostics.Debug.Assert(null != Owner);
 }
Esempio n. 44
0
        /// <summary>
        /// This bullet is fired from another bullet, initialize it from the node that fired it
        /// </summary>
        /// <param name="subNode">Sub node that defines this bullet</param>
        public void InitNode(BulletMLNode subNode)
        {
            System.Diagnostics.Debug.Assert(null != subNode);

              //clear everything out
              Tasks.Clear();

              //Grab that top level node
              MyNode = subNode;

              //found a top num node, add a task for it
              BulletMLTask task = new BulletMLTask(subNode, null);

              //parse the nodes into the task list
              task.ParseTasks(this);

              //initialize all the tasks
              task.InitTask(this);

              Tasks.Add(task);
        }
Esempio n. 45
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLLib.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);
 }
Esempio n. 46
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLLib.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);
 }
Esempio n. 47
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLLib.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);
 }
Esempio n. 48
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLLib.BulletMLTask"/> class.
 /// </summary>
 /// <param name="node">Node.</param>
 /// <param name="owner">Owner.</param>
 public SetDirectionTask(DirectionNode node, BulletMLTask owner) : base(node, owner)
 {
     System.Diagnostics.Debug.Assert(null != Node);
     System.Diagnostics.Debug.Assert(null != Owner);
 }
Esempio n. 49
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLLib.BulletMLTask"/> class.
 /// </summary>
 /// <param name="node">Node.</param>
 /// <param name="owner">Owner.</param>
 public PlaySoundTask(PlaySoundNode node, BulletMLTask owner)
     : base(node, owner)
 {
     System.Diagnostics.Debug.Assert(null != Node);
     System.Diagnostics.Debug.Assert(null != Owner);
 }
Esempio n. 50
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLLib.BulletMLTask"/> class.
 /// </summary>
 /// <param name="node">Node.</param>
 /// <param name="owner">Owner.</param>
 public SetSpeedTask(SpeedNode node, BulletMLTask owner)
     : base(node, owner)
 {
     System.Diagnostics.Debug.Assert(null != Node);
     System.Diagnostics.Debug.Assert(null != Owner);
 }
Esempio n. 51
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLLib.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);
 }
Esempio n. 52
0
 /// <summary>
 /// Gets the value of this node for a specific instance of a task.
 /// </summary>
 /// <returns>The value.</returns>
 /// <param name="task">Task.</param>
 /// <param name="bullet">The bullet to get the value for</param>
 public float GetValue(BulletMLTask task, Bullet bullet)
 {
     //send to the equation for an answer
     return (float)NodeEquation.Solve(task.GetParamValue, bullet.MyBulletManager.Tier);
 }
Esempio n. 53
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLLib.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);
 }
Esempio n. 54
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLLib.BulletMLTask"/> class.
 /// </summary>
 /// <param name="node">Node.</param>
 /// <param name="owner">Owner.</param>
 public TriggerTask(TriggerNode node, BulletMLTask owner)
     : base(node, owner)
 {
     System.Diagnostics.Debug.Assert(null != Node);
       System.Diagnostics.Debug.Assert(null != Owner);
 }
Esempio n. 55
0
        /// <summary>
        /// Parse a specified node and bullet into this task
        /// </summary>
        /// <param name="myNode">the node for this dude</param>
        /// <param name="bullet">the bullet this dude is controlling</param>
        public 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
                    BulletRefNode refNode = childNode as BulletRefNode;
                    BulletRefTask = new BulletMLTask(refNode.ReferencedBulletNode, this);

                    //populate the params of the bullet ref
                    for (int i = 0; i < childNode.ChildNodes.Count; i++)
                    {
                        BulletRefTask.ParamList.Add(childNode.ChildNodes[i].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;
            }
        }
Esempio n. 56
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLLib.BulletMLTask"/> class.
 /// </summary>
 /// <param name="node">Node.</param>
 /// <param name="owner">Owner.</param>
 public ChangeSpeedTask(ChangeSpeedNode node, BulletMLTask owner) : base(node, owner)
 {
     System.Diagnostics.Debug.Assert(null != Node);
     System.Diagnostics.Debug.Assert(null != Owner);
 }
Esempio n. 57
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BulletMLLib.BulletMLTask"/> class.
 /// </summary>
 /// <param name="node">Node.</param>
 /// <param name="owner">Owner.</param>
 public RepeatTask(RepeatNode node, BulletMLTask owner)
     : base(node, owner)
 {
     System.Diagnostics.Debug.Assert(null != Node);
     System.Diagnostics.Debug.Assert(null != Owner);
 }