Ejemplo n.º 1
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;

            System.Diagnostics.Debug.Assert(null != manager);
            manager.RemoveBullet(bullet);
            return(ERunStatus.End);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initialize this bullet with a top level node.
        /// </summary>
        /// <param name="rootNode">
        /// This is a top level node.
        /// Find the first "top" node and use it to define this bullet.
        /// </param>
        public void InitTopNode(BulletMLNode rootNode)
        {
            Debug.Assert(rootNode != null);

            // Find the item labelled "top", it's our entry point
            var validBullet = false;
            var topNode     = rootNode.FindLabelNode("top", NodeName.action);

            if (topNode != null)
            {
                // Initialize with the top node we found!
                InitNode(topNode);
                validBullet = true;
            }
            else
            {
                // There is no "top" node, so that means we have a list of "top#" nodes
                for (int i = 1; i < 10; i++)
                {
                    topNode = rootNode.FindLabelNode("top" + i, NodeName.action);

                    if (topNode != null)
                    {
                        if (!validBullet)
                        {
                            // Use this bullet!
                            InitNode(topNode);
                            validBullet = true;
                        }
                        else
                        {
                            // Create a new bullet
                            var bullet = _bulletManager.CreateBullet(true);

                            // Set the position to this dude's position
                            bullet.X = this.X;
                            bullet.Y = this.Y;

                            // Initialize with the node we found
                            bullet.InitNode(topNode);
                        }
                    }
                }
            }

            if (!validBullet)
            {
                // We didn't find a "top" node, we remove this bullet from the game.
                _bulletManager.RemoveBullet(this);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initialize this bullet with a top level node
        /// </summary>
        /// <param name="rootNode">This is a top level node... find the first "top" node and use it to define this bullet</param>
        public void InitTopNode(BulletMLNode rootNode)
        {
            Debug.Assert(null != rootNode);

            //okay find the item labelled 'top'
            bool         bValidBullet = false;
            BulletMLNode topNode      = rootNode.FindLabelNode("top", ENodeName.action);

            if (topNode != null)
            {
                //initialize with the top node we found!
                InitNode(topNode);
                bValidBullet = true;
            }
            else
            {
                //ok there is no 'top' node, so that means we have a list of 'top#' nodes
                for (int i = 1; i < 10; i++)
                {
                    topNode = rootNode.FindLabelNode("top" + i, ENodeName.action);
                    if (topNode != null)
                    {
                        if (!bValidBullet)
                        {
                            //Use this bullet!
                            InitNode(topNode);
                            bValidBullet = true;
                        }
                        else
                        {
                            //Create a new bullet
                            IBullet newDude = _bulletManager.CreateTopBullet();

                            //set the position to this dude's position
                            newDude.X = this.X;
                            newDude.Y = this.Y;

                            //initialize with the node we found
                            newDude.InitNode(topNode);
                        }
                    }
                }
            }

            if (!bValidBullet)
            {
                //We didnt find a "top" node for this dude, remove him from the game.
                _bulletManager.RemoveBullet(this);
            }
        }