This is the bullet class that outside assemblies will interact with. Just inherit from this class and override the abstract functions!
예제 #1
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 ParseTasks(Bullet bullet)
        {
            //set the number of times to repeat this action
            var actionNode = Node as ActionNode;
            Debug.Assert(null != actionNode);
            RepeatNumMax = actionNode.RepeatNum(this, bullet);

            //is this an actionref task?
            if (ENodeName.actionRef == Node.Name)
            {
                //add a sub task under this one for the referenced action
                ActionRefNode myActionRefNode = Node as ActionRefNode;

                //create the action task
                ActionTask actionTask = new ActionTask(myActionRefNode.ReferencedActionNode, this);

                //parse the children of the action node into the task
                actionTask.ParseTasks(bullet);

                //store the task
                ChildTasks.Add(actionTask);
            }

            //call the base class
            base.ParseTasks(bullet);
        }
예제 #2
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)
        {
            bullet.MyBulletManager.Trigger(bullet, Flag);

              TaskFinished = true;
              return ERunStatus.End;
        }
예제 #3
0
        /// <summary>
        /// Init this task and all its sub tasks.  
        /// This method should be called AFTER the nodes are parsed, but BEFORE run is called.
        /// </summary>
        /// <param name="bullet">the bullet this dude is controlling</param>
        public override void InitTask(Bullet bullet)
        {
            //Init task is being called on a RepeatTask, which means all the sequence nodes underneath this one need to be reset

            //Call the HardReset method of the base class
            HardReset(bullet);
        }
예제 #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)
 {
     //remove the bullet via the bullet manager interface
     IBulletManager manager = bullet.MyBulletManager;
     Debug.Assert(null != manager);
     manager.RemoveBullet(bullet);
     return ERunStatus.End;
 }
예제 #5
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)
 {
     if (_soundName.Contains("+"))
     {
         SoundEngine.PlayRandomClip(_soundName.Split('+'));
     }
     else
     {
         SoundEngine.PlayClip(_soundName);
     }
     return ERunStatus.End;
 }
예제 #6
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)
 {
     Duration -= 1.0f * bullet.TimeSpeed * TimeFix.Delta;
     if (Duration >= 0.0f && startDuration > 1f) // 1 frame duration should not be affected by delta time
     {
         return ERunStatus.Stop;
     }
     else
     {
         TaskFinished = true;
         return ERunStatus.End;
     }
 }
예제 #7
0
 /// <summary>
 /// Get the number of times this action should be repeated.
 /// </summary>
 /// <param name="myTask">the task to get the number of repeat times for</param>
 /// <returns>The number of times to repeat this node, as specified by a parent Repeat node.</returns>
 public int RepeatNum(ActionTask myTask, Bullet bullet)
 {
     if (null != ParentRepeatNode)
     {
         //Get the equation value of the repeat node
         return (int)ParentRepeatNode.GetChildValue(ENodeName.times, myTask, bullet);
     }
     else
     {
         //no repeat nodes, just repeat it once
         return 1;
     }
 }
예제 #8
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)
 {
     Duration -= 1.0f * bullet.TimeSpeed;
     if (Duration >= 0.0f)
     {
         return ERunStatus.Stop;
     }
     else
     {
         TaskFinished = true;
         return ERunStatus.End;
     }
 }
예제 #9
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)
        {
            bullet.Speed += SpeedChange;

              Duration -= 1.0f * bullet.TimeSpeed;
              if (Duration <= 0.0f || startDuration <= 1)
              {
            TaskFinished = true;
            return ERunStatus.End;
              }
              else
              {
            return ERunStatus.Continue;
              }
        }
예제 #10
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)
        {
            bullet.Speed += GetSpeed(bullet);

            RunDelta += 1.0f * bullet.TimeSpeed;
            if (Duration <= RunDelta)
            {
                TaskFinished = true;
                return ERunStatus.End;
            }
            else
            {
                //since this task isn't finished, run it again next time
                return ERunStatus.Continue;
            }
        }
        public override ERunStatus Run(Bullet bullet)
        {
            //change the direction of the bullet by the correct amount
            bullet.Direction += DirectionChange;

            //decrement the amount if time left to run and return End when this task is finished
            Duration -= 1.0f * bullet.TimeSpeed;
            if (Duration <= 0.0f)
            {
                TaskFinished = true;
                return ERunStatus.End;
            }
            else
            {
                //since this task isn't finished, run it again next time
                return ERunStatus.Continue;
            }
        }
예제 #12
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)
        {
            //Add the acceleration to the bullet
              bullet.Acceleration += Acceleration;

              //decrement the amount if time left to run and return End when this task is finished
              Duration -= 1.0f * bullet.TimeSpeed * TimeFix.Delta;
              if (Duration <= 0.0f || startDuration <= 1)
              {
            TaskFinished = true;
            return ERunStatus.End;
              }
              else
              {
            //since this task isn't finished, run it again next time
            return ERunStatus.Continue;
              }
        }
예제 #13
0
파일: ActionTask.cs 프로젝트: JokieW/pewpew
        /// <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)
        {
            //run the action until we hit the limit
              while (RepeatNum < RepeatNumMax)
              {
            ERunStatus runStatus = base.Run(bullet);

            //What was the return value from running all teh child actions?
            switch (runStatus)
            {
              case ERunStatus.End:
            {
              //The actions completed successfully, initialize everything and run it again
              RepeatNum++;

              //reset all the child tasks
              foreach (BulletMLTask task in ChildTasks)
              {
                task.InitTask(bullet);
              }
            }
            break;

              case ERunStatus.Stop:
            {
              //Something in the child tasks paused this action
              return runStatus;
            }

              default:
            {
              //One of the child tasks needs to keep running next frame
              return ERunStatus.Continue;
            }
            }
              }

              //if it gets here, all the child tasks have been run the correct number of times
              TaskFinished = true;
              return ERunStatus.End;
        }
예제 #14
0
파일: ActionTask.cs 프로젝트: JokieW/pewpew
        /// <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 ParseTasks(Bullet bullet)
        {
            //is this an actionref task?
              if (ENodeName.actionRef == Node.Name)
              {
            //add a sub task under this one for the referenced action
            ActionRefNode myActionRefNode = Node as ActionRefNode;

            //create the action task
            ActionTask actionTask = new ActionTask(myActionRefNode.ReferencedActionNode, this);

            //parse the children of the action node into the task
            actionTask.ParseTasks(bullet);

            //store the task
            ChildTasks.Add(actionTask);
              }

              //call the base class
              base.ParseTasks(bullet);
        }
예제 #15
0
    void Start()
    {
        // Read pattern file
        // We can optimize this later, making it read
        // every pattern once and storing it somewhere
        pattern = new BulletPattern();
        //pattern.ParseXML(Application.dataPath + "/BulletPatterns/" + PatternFile.name + ".xml");
        //pattern.ParseXML(PatternFile.name + ".xml");
        pattern.ParseXML (patternFile);

        // Find the bullet manager
        // (we need this for the root bullet)
        BulletManagerScript bManager = FindObjectOfType<BulletManagerScript>();

        // Instantiate root bullet
        rootBullet = new BulletObject(bManager);
        // Set its initial position
        rootBullet.X = transform.position.x;
        rootBullet.Y = transform.position.y;
        // Assign its pattern
        rootBullet.InitTopNode(pattern.RootNode);
    }
예제 #16
0
        /// <summary>
        /// this sets up the task to be run.
        /// </summary>
        /// <param name="bullet">Bullet.</param>
        protected override void SetupTask(Bullet bullet)
        {
            //set the length of time to run this dude
              startDuration = Node.GetChildValue(ENodeName.term, this);

              //check for divide by 0
              if (0.0f == startDuration)
              {
            startDuration = 1.0f;
              }

              float ratio = TimeFix.Framerate / 60f;
              startDuration *= ratio;

              Duration = startDuration;

              switch (Node.GetChild(ENodeName.speed).NodeType)
              {
            case ENodeType.sequence:
              {
            SpeedChange = Node.GetChildValue(ENodeName.speed, this);
              }
              break;

            case ENodeType.relative:
              {
            SpeedChange = Node.GetChildValue(ENodeName.speed, this) / Duration;
              }
              break;

            default:
              {
            SpeedChange = (Node.GetChildValue(ENodeName.speed, this) - bullet.Speed) / Duration;
              }
              break;
              }
        }
예제 #17
0
 /// <summary>
 /// this sets up the task to be run.
 /// </summary>
 /// <param name="bullet">Bullet.</param>
 protected override void SetupTask(Bullet bullet)
 {
     RepeatNum = 0;
 }
예제 #18
0
        /// <summary>
        /// this sets up the task to be run.
        /// </summary>
        /// <param name="bullet">Bullet.</param>
        protected override void SetupTask(Bullet bullet)
        {
            //set the accelerataion we are gonna add to the bullet
              startDuration = Node.GetChildValue(ENodeName.term, this);

              //check for divide by 0
              if (0.0f == startDuration)
              {
            startDuration = 1.0f;
              }
              Duration = startDuration;

              //Get the horizontal node
              HorizontalNode horiz = Node.GetChild(ENodeName.horizontal) as HorizontalNode;
              if (null != horiz)
              {
            //Set the x component of the acceleration
            switch (horiz.NodeType)
            {
              case ENodeType.sequence:
            {
              //Sequence in an acceleration node means "add this amount every frame"
              _acceleration.x = horiz.GetValue(this);
            }
            break;

              case ENodeType.relative:
            {
              //accelerate by a certain amount
              _acceleration.x = horiz.GetValue(this) / Duration;
            }
            break;

              default:
            {
              //accelerate to a specific value
              _acceleration.x = (horiz.GetValue(this) - bullet.Acceleration.x) / Duration;
            }
            break;
            }
              }

              //Get the vertical node
              VerticalNode vert = Node.GetChild(ENodeName.vertical) as VerticalNode;
              if (null != vert)
              {
            //set teh y component of the acceleration
            switch (vert.NodeType)
            {
              case ENodeType.sequence:
            {
              //Sequence in an acceleration node means "add this amount every frame"
              _acceleration.y = vert.GetValue(this);
            }
            break;

              case ENodeType.relative:
            {
              //accelerate by a certain amount
              _acceleration.y = vert.GetValue(this) / Duration;
            }
            break;

              default:
            {
              //accelerate to a specific value
              _acceleration.y = (vert.GetValue(this) - bullet.Acceleration.y) / Duration;
            }
            break;
            }
              }
        }
예제 #19
0
 protected override void SetupTask(Bullet bullet)
 {
     _soundName = Node.Text;
 }
예제 #20
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)
        {
            //Create the new bullet
            IBullet newBullet = bullet.MyBulletManager.CreateBullet();

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

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

            //set the direction of the new bullet
            newBullet.Direction = FireDirection;

            //set teh speed of the new bullet
            newBullet.Speed = FireSpeed;

            //initialize the bullet with the bullet node stored in the Fire node
            FireNode myFireNode = Node as FireNode;
            Debug.Assert(null != myFireNode);
            newBullet.InitNode(myFireNode.BulletDescriptionNode);

            //set the owner of all the top level tasks for the new bullet to this dude
            foreach (BulletMLTask task in newBullet.Tasks)
            {
                task.Owner = this;
            }

            TaskFinished = true;
            return ERunStatus.End;
        }
예제 #21
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 virtual ERunStatus Run(Bullet bullet)
        {
            //run all the child tasks
            TaskFinished = true;
            for (int i = 0; i < ChildTasks.Count; i++)
            {
                //is the child task finished running?
                if (!ChildTasks[i].TaskFinished)
                {
                    //Run the child task...
                    ERunStatus childStaus = ChildTasks[i].Run(bullet);
                    if (childStaus == ERunStatus.Stop)
                    {
                        //The child task is paused, so it is not finished
                        TaskFinished = false;
                        return childStaus;
                    }
                    else if (childStaus == ERunStatus.Continue)
                    {
                        //child task needs to do some more work
                        TaskFinished = false;
                    }
                }
            }

            return (TaskFinished ?  ERunStatus.End : ERunStatus.Continue);
        }
예제 #22
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 virtual void ParseTasks(Bullet bullet)
        {
            if (null == bullet)
            {
                throw new NullReferenceException("bullet argument cannot be null");
            }

            foreach (BulletMLNode childNode in Node.ChildNodes)
            {
                ParseChildNode(childNode, bullet);
            }
        }
예제 #23
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 virtual void ParseChildNode(BulletMLNode childNode, Bullet bullet)
        {
            Debug.Assert(null != childNode);
            Debug.Assert(null != bullet);

            //construct the correct type of node
            switch (childNode.Name)
            {
                case ENodeName.repeat:
                {
                    //convert the node to an repeatnode
                    RepeatNode myRepeatNode = childNode as RepeatNode;

                    //create a placeholder bulletmltask for the repeat node
                    RepeatTask repeatTask = new RepeatTask(myRepeatNode, this);

                    //parse the child nodes into the repeat task
                    repeatTask.ParseTasks(bullet);

                    //store the task
                    ChildTasks.Add(repeatTask);
                }
                break;

                case ENodeName.action:
                {
                    //convert the node to an ActionNode
                    ActionNode myActionNode = childNode as ActionNode;

                    //create the action task
                    ActionTask actionTask = new ActionTask(myActionNode, this);

                    //parse the children of the action node into the task
                    actionTask.ParseTasks(bullet);

                    //store the task
                    ChildTasks.Add(actionTask);
                }
                break;

                case ENodeName.actionRef:
                {
                    //convert the node to an ActionNode
                    ActionRefNode myActionNode = childNode as ActionRefNode;

                    //create the action task
                    ActionTask actionTask = new ActionTask(myActionNode, this);

                    //add the params to the action task
                    for (int i = 0; i < childNode.ChildNodes.Count; i++)
                    {
                        actionTask.ParamList.Add(childNode.ChildNodes[i].GetValue(this, bullet));
                    }

                    //parse the children of the action node into the task
                    actionTask.ParseTasks(bullet);

                    //store the task
                    ChildTasks.Add(actionTask);
                }
                break;

                case ENodeName.changeSpeed:
                {
                    ChildTasks.Add(new ChangeSpeedTask(childNode as ChangeSpeedNode, this));
                }
                break;

                case ENodeName.changeDirection:
                {
                    ChildTasks.Add(new ChangeDirectionTask(childNode as ChangeDirectionNode, this));
                }
                break;

                case ENodeName.fire:
                {
                    //convert the node to a fire node
                    FireNode myFireNode = childNode as FireNode;

                    //create the fire task
                    FireTask fireTask = new FireTask(myFireNode, this);

                    //parse the children of the fire node into the task
                    fireTask.ParseTasks(bullet);

                    //store the task
                    ChildTasks.Add(fireTask);
                }
                break;

                case ENodeName.fireRef:
                {
                    //convert the node to a fireref node
                    FireRefNode myFireNode = childNode as FireRefNode;

                    //create the fire task
                    FireTask fireTask = new FireTask(myFireNode.ReferencedFireNode, this);

                    //add the params to the fire task
                    for (int i = 0; i < childNode.ChildNodes.Count; i++)
                    {
                        fireTask.ParamList.Add(childNode.ChildNodes[i].GetValue(this, bullet));
                    }

                    //parse the children of the action node into the task
                    fireTask.ParseTasks(bullet);

                    //store the task
                    ChildTasks.Add(fireTask);
                }
                break;

                case ENodeName.wait:
                {
                    ChildTasks.Add(new WaitTask(childNode as WaitNode, this));
                }
                break;

                case ENodeName.vanish:
                {
                    ChildTasks.Add(new VanishTask(childNode as VanishNode, this));
                }
                break;

                case ENodeName.accel:
                {
                    ChildTasks.Add(new AccelTask(childNode as AccelNode, this));
                }
                break;
            }
        }
예제 #24
0
        /// <summary>
        /// Init this task and all its sub tasks.  
        /// This method should be called AFTER the nodes are parsed, but BEFORE run is called.
        /// </summary>
        /// <param name="bullet">the bullet this dude is controlling</param>
        public virtual void InitTask(Bullet bullet)
        {
            TaskFinished = false;

            foreach (BulletMLTask task in ChildTasks)
            {
                task.InitTask(bullet);
            }

            SetupTask(bullet);
        }
        /// <summary>
        /// this sets up the task to be run.
        /// </summary>
        /// <param name="bullet">Bullet.</param>
        protected override void SetupTask(Bullet bullet)
        {
            //set the time length to run this dude
            Duration = Node.GetChildValue(ENodeName.term, this);

            //check for divide by 0
            if (0.0f == Duration)
            {
                Duration = 1.0f;
            }

            //Get the amount to change direction from the nodes
            DirectionNode dirNode = Node.GetChild(ENodeName.direction) as DirectionNode;
            float value = dirNode.GetValue(this) * (float)Mathf.PI / 180.0f; //also make sure to convert to radians

            //How do we want to change direction?
            ENodeType changeType = dirNode.NodeType;
            switch (changeType)
            {
                case ENodeType.sequence:
                {
                    //We are going to add this amount to the direction every frame
                    DirectionChange = value;
                }
                break;

                case ENodeType.absolute:
                {
                    //We are going to go in the direction we are given, regardless of where we are pointing right now
                    DirectionChange = value - bullet.Direction;
                }
                break;

                case ENodeType.relative:
                {
                    //The direction change will be relative to our current direction
                    DirectionChange = value;
                }
                break;

                default:
                {
                    //the direction change is to aim at the enemy
                    DirectionChange = ((value + bullet.GetAimDir()) - bullet.Direction);
                }
                break;
            }

            //keep the direction between 0 and 360
            if (DirectionChange > Mathf.PI)
            {
                DirectionChange -= 2 * (float)Mathf.PI;
            }
            else if (DirectionChange < -Mathf.PI)
            {
                DirectionChange += 2 * (float)Mathf.PI;
            }

            //The sequence type of change direction is unaffected by the duration
            if (changeType != ENodeType.sequence)
            {
                //Divide by the duration so we ease into the direction change
                DirectionChange /= Duration;
            }
        }
예제 #26
0
        /// <summary>
        /// this sets up the task to be run.
        /// </summary>
        /// <param name="bullet">Bullet.</param>
        protected override void SetupTask(Bullet bullet)
        {
            //get the direction to shoot the bullet

            //is this the first time it has ran?  If there isn't a sequence node, we don't care!
            if (InitialRun || (null == SequenceDirectionTask))
            {
                //do we have an initial direction node?
                if (null != InitialDirectionTask)
                {
                    //Set the fire direction to the "initial" value
                    float newBulletDirection = InitialDirectionTask.GetNodeValue(bullet) * (float)Math.PI / 180.0f;
                    switch (InitialDirectionTask.Node.NodeType)
                    {
                        case ENodeType.absolute:
                        {
                            //the new bullet points right at a particular direction
                            FireDirection = newBulletDirection;
                        }
                        break;

                        case ENodeType.relative:
                        {
                            //the new bullet direction will be relative to the old bullet
                            FireDirection = newBulletDirection + bullet.Direction;
                        }
                        break;

                        default:
                        {
                            //aim the bullet at the player
                            FireDirection = newBulletDirection + bullet.GetAimDir();
                        }
                        break;
                    }
                }
                else
                {
                    //There isn't an initial direction task, so just aim at the bad guy.
                    //aim the bullet at the player
                    FireDirection = bullet.GetAimDir();
                }
            }
            else if (null != SequenceDirectionTask)
            {
                //else if there is a sequence node, add the value to the "shoot direction"
                FireDirection += SequenceDirectionTask.GetNodeValue(bullet) * (float)Math.PI / 180.0f;
            }

            //Set the speed to shoot the bullet

            //is this the first time it has ran?  If there isn't a sequence node, we don't care!
            if (InitialRun || (null == SequenceSpeedTask))
            {
                //do we have an initial speed node?
                if (null != InitialSpeedTask)
                {
                    //set the shoot speed to the "initial" value.
                    float newBulletSpeed = InitialSpeedTask.GetNodeValue(bullet);
                    switch (InitialSpeedTask.Node.NodeType)
                    {
                        case ENodeType.relative:
                        {
                            //the new bullet speed will be relative to the old bullet
                            FireSpeed = newBulletSpeed + bullet.Speed;
                        }
                        break;

                        default:
                        {
                            //the new bullet shoots at a predeterminde speed
                            FireSpeed = newBulletSpeed;
                        }
                        break;
                    }
                }
                else
                {
                    //there is no initial speed task, use the old dude's speed
                    FireSpeed = bullet.Speed;
                }
            }
            else if (null != SequenceSpeedTask)
            {
                //else if there is a sequence node, add the value to the "shoot direction"
                FireSpeed += SequenceSpeedTask.GetNodeValue(bullet);
            }

            //make sure the direction is between 0 and 359
            while (FireDirection > Math.PI)
            {
                FireDirection -= (2.0f * (float)Math.PI);
            }
            while (-Math.PI > FireDirection)
            {
                FireDirection += (2.0f * (float)Math.PI);
            }

            //make sure we don't overwrite the initial values if we aren't supposed to
            NumTimesInitialized++;
        }
예제 #27
0
 /// <summary>
 /// this sets up the task to be run.
 /// </summary>
 /// <param name="bullet">Bullet.</param>
 protected virtual void SetupTask(Bullet bullet)
 {
     //overload in child classes
 }
예제 #28
0
 /// <summary>
 /// Gets the node value.
 /// </summary>
 /// <returns>The node value.</returns>
 public float GetNodeValue(Bullet bullet)
 {
     return Node.GetValue(this, bullet);
 }
예제 #29
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 ParseTasks(Bullet bullet)
        {
            if (null == bullet)
            {
                throw new NullReferenceException("bullet argument cannot be null");
            }

            foreach (BulletMLNode childNode in Node.ChildNodes)
            {
                ParseChildNode(childNode, bullet);
            }

            //Setup all the direction nodes
            GetDirectionTasks(this);
            GetDirectionTasks(BulletRefTask);

            //setup all the speed nodes
            GetSpeedNodes(this);
            GetSpeedNodes(BulletRefTask);
        }
예제 #30
0
        /// <summary>
        /// This gets called when nested repeat nodes get initialized.
        /// </summary>
        /// <param name="bullet">Bullet.</param>
        public virtual void HardReset(Bullet bullet)
        {
            TaskFinished = false;

            foreach (BulletMLTask task in ChildTasks)
            {
                task.HardReset(bullet);
            }

            SetupTask(bullet);
        }
예제 #31
0
 /// <summary>
 /// this sets up the task to be run.
 /// </summary>
 /// <param name="bullet">Bullet.</param>
 protected override void SetupTask(Bullet bullet)
 {
     Duration = Node.GetValue(this, bullet.MyBulletManager);
 }