Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="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;
        }
Exemplo n.º 2
0
        public void GotActionRefNode1()
        {
            string        filename = @"Content\ActionRefEmpty.xml";
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename);

            ActionNode testActionNode = pattern.RootNode.GetChild(ENodeName.action) as ActionNode;
            FireNode   testFireNode   = testActionNode.GetChild(ENodeName.fire) as FireNode;

            Assert.IsNotNull(testFireNode);
        }
Exemplo n.º 3
0
        public void GotBulletNode()
        {
            var           filename = new Filename(@"FireEmpty.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);

            ActionNode testActionNode = pattern.RootNode.GetChild(ENodeName.action) as ActionNode;
            FireNode   testFireNode   = testActionNode.GetChild(ENodeName.fire) as FireNode;

            Assert.IsNotNull(testFireNode.BulletDescriptionNode);
        }
Exemplo n.º 4
0
        public void CreatedSpeedNode2()
        {
            string        filename = @"Content\FireSpeed.xml";
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename);

            ActionNode testActionNode = pattern.RootNode.GetChild(ENodeName.action) as ActionNode;
            FireNode   testFireNode   = testActionNode.GetChild(ENodeName.fire) as FireNode;

            Assert.IsNotNull(testFireNode.GetChild(ENodeName.speed));
        }
Exemplo n.º 5
0
        public void CreatedSpeedNode3()
        {
            var           filename = new Filename(@"FireSpeed.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);

            ActionNode testActionNode = pattern.RootNode.GetChild(ENodeName.action) as ActionNode;
            FireNode   testFireNode   = testActionNode.GetChild(ENodeName.fire) as FireNode;

            Assert.IsNotNull(testFireNode.GetChild(ENodeName.speed) as SpeedNode);
        }
Exemplo n.º 6
0
        public void CreatedBulletRefNode2()
        {
            var           filename = new Filename(@"BulletRef.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);

            ActionNode testActionNode = pattern.RootNode.GetChild(ENodeName.action) as ActionNode;
            FireNode   testFireNode   = testActionNode.GetChild(ENodeName.fire) as FireNode;

            Assert.IsNotNull(testFireNode.GetChild(ENodeName.bulletRef));
        }
Exemplo n.º 7
0
        public void SpeedNodeAbsolute()
        {
            string        filename = @"Content\FireSpeedAbsolute.xml";
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename);

            ActionNode testActionNode = pattern.RootNode.GetChild(ENodeName.action) as ActionNode;
            FireNode   testFireNode   = testActionNode.GetChild(ENodeName.fire) as FireNode;
            SpeedNode  testSpeedNode  = testFireNode.GetChild(ENodeName.speed) as SpeedNode;

            Assert.AreEqual(ENodeType.absolute, testSpeedNode.NodeType);
        }
Exemplo n.º 8
0
        public void CreatedBulletRefNode3()
        {
            string        filename = @"Content\BulletRef.xml";
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename);

            ActionNode testActionNode = pattern.RootNode.GetChild(ENodeName.action) as ActionNode;
            FireNode   testFireNode   = testActionNode.GetChild(ENodeName.fire) as FireNode;

            Assert.IsNotNull(testFireNode.GetChild(ENodeName.bulletRef));
            Assert.IsNotNull(testFireNode.GetChild(ENodeName.bulletRef) as BulletRefNode);
        }
Exemplo n.º 9
0
        public void GotParamNode2()
        {
            var           filename = TestUtils.GetFilePath(@"Content\BulletRefParam.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.Parse(filename);

            ActionNode    testActionNode = pattern.RootNode.GetChild(NodeName.action) as ActionNode;
            FireNode      testFireNode   = testActionNode.GetChild(NodeName.fire) as FireNode;
            BulletRefNode refNode        = testFireNode.GetChild(NodeName.bulletRef) as BulletRefNode;

            Assert.IsNotNull(refNode.GetChild(NodeName.param) as ParamNode);
        }
Exemplo n.º 10
0
        public void DirectionNodeSequence()
        {
            string        filename = @"Content\FireDirectionSequence.xml";
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename);

            ActionNode    testActionNode    = pattern.RootNode.GetChild(ENodeName.action) as ActionNode;
            FireNode      testFireNode      = testActionNode.GetChild(ENodeName.fire) as FireNode;
            DirectionNode testDirectionNode = testFireNode.GetChild(ENodeName.direction) as DirectionNode;

            Assert.AreEqual(ENodeType.sequence, testDirectionNode.NodeType);
        }
Exemplo n.º 11
0
        public void GotParamNode2()
        {
            string        filename = @"Content\BulletRefParam.xml";
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename);

            ActionNode    testActionNode = pattern.RootNode.GetChild(ENodeName.action) as ActionNode;
            FireNode      testFireNode   = testActionNode.GetChild(ENodeName.fire) as FireNode;
            BulletRefNode refNode        = testFireNode.GetChild(ENodeName.bulletRef) as BulletRefNode;

            Assert.IsNotNull(refNode.GetChild(ENodeName.param) as ParamNode);
        }
Exemplo n.º 12
0
        public void CreatedTopLevelFireNode()
        {
            var           filename = new Filename(@"FireEmpty.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);

            FireNode testFireNode = pattern.RootNode.GetChild(ENodeName.fire) as FireNode;

            Assert.IsNotNull(testFireNode);
            Assert.IsNotNull(testFireNode.BulletDescriptionNode);
            Assert.AreEqual("test", testFireNode.Label);
        }
Exemplo n.º 13
0
        public void SpeedNodeSequence()
        {
            var           filename = new Filename(@"FireSpeedSequence.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);

            ActionNode testActionNode = pattern.RootNode.GetChild(ENodeName.action) as ActionNode;
            FireNode   testFireNode   = testActionNode.GetChild(ENodeName.fire) as FireNode;
            SpeedNode  testSpeedNode  = testFireNode.GetChild(ENodeName.speed) as SpeedNode;

            Assert.AreEqual(ENodeType.sequence, testSpeedNode.NodeType);
        }
Exemplo n.º 14
0
        public void GotCorrectFireNode()
        {
            var           filename = new Filename(@"FireRef.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);

            ActionNode  testActionNode = pattern.RootNode.GetChild(ENodeName.action) as ActionNode;
            FireRefNode testFireNode   = testActionNode.GetChild(ENodeName.fireRef) as FireRefNode;
            FireNode    fireNode       = testFireNode.ReferencedFireNode as FireNode;

            Assert.AreEqual("test", fireNode.Label);
        }
Exemplo n.º 15
0
        public void GotActionRefNode3()
        {
            var           filename = new Filename(@"ActionRefEmpty.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);

            ActionNode testActionNode = pattern.RootNode.GetChild(ENodeName.action) as ActionNode;
            FireNode   testFireNode   = testActionNode.GetChild(ENodeName.fire) as FireNode;
            BulletNode testBulletNode = testFireNode.GetChild(ENodeName.bullet) as BulletNode;

            Assert.IsNotNull(testBulletNode.GetChild(ENodeName.actionRef));
        }
Exemplo n.º 16
0
        public void DirectionNodeAbsolute()
        {
            var           filename = new Filename(@"FireDirectionAbsolute.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);

            ActionNode    testActionNode    = pattern.RootNode.GetChild(ENodeName.action) as ActionNode;
            FireNode      testFireNode      = testActionNode.GetChild(ENodeName.fire) as FireNode;
            DirectionNode testDirectionNode = testFireNode.GetChild(ENodeName.direction) as DirectionNode;

            Assert.AreEqual(ENodeType.absolute, testDirectionNode.NodeType);
        }
Exemplo n.º 17
0
        public void FoundBulletNode1()
        {
            var           filename = new Filename(@"BulletRef.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);

            ActionNode    testActionNode = pattern.RootNode.GetChild(ENodeName.action) as ActionNode;
            FireNode      testFireNode   = testActionNode.GetChild(ENodeName.fire) as FireNode;
            BulletRefNode refNode        = testFireNode.GetChild(ENodeName.bulletRef) as BulletRefNode;

            Assert.IsNotNull(refNode.ReferencedBulletNode as BulletNode);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="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);

            _lastFireDirection  = 0f;
            _lastFireSpeed      = 0f;
            _lastFireScale      = 0f;
            _lastSetupDirection = 0f;
            _lastSetupSpeed     = 0f;
            _lastSetupScale     = 0f;
            _isRunning          = false;
        }
Exemplo n.º 19
0
        public void FoundCorrectBulletNode()
        {
            string        filename = @"Content\BulletRefTwoBullets.xml";
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename);

            ActionNode    testActionNode = pattern.RootNode.GetChild(ENodeName.action) as ActionNode;
            FireNode      testFireNode   = testActionNode.GetChild(ENodeName.fire) as FireNode;
            BulletRefNode refNode        = testFireNode.GetChild(ENodeName.bulletRef) as BulletRefNode;
            BulletNode    testBulletNode = refNode.ReferencedBulletNode as BulletNode;

            Assert.AreEqual("test2", testBulletNode.Label);
        }
Exemplo n.º 20
0
        public void FoundActionNode2()
        {
            string        filename = @"Content\ActionRefEmpty.xml";
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename);

            ActionNode    testActionNode    = pattern.RootNode.GetChild(ENodeName.action) as ActionNode;
            FireNode      testFireNode      = testActionNode.GetChild(ENodeName.fire) as FireNode;
            BulletNode    testBulletNode    = testFireNode.GetChild(ENodeName.bullet) as BulletNode;
            ActionRefNode testActionRefNode = testBulletNode.GetChild(ENodeName.actionRef) as ActionRefNode;
            ActionNode    refNode           = testActionRefNode.ReferencedActionNode as ActionNode;

            Assert.AreEqual(refNode.Label, "test");
        }
Exemplo n.º 21
0
        public void FoundCorrectActionNode()
        {
            var           filename = new Filename(@"ActionRefParam.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);

            ActionNode    testActionNode    = pattern.RootNode.GetChild(ENodeName.action) as ActionNode;
            FireNode      testFireNode      = testActionNode.GetChild(ENodeName.fire) as FireNode;
            BulletNode    testBulletNode    = testFireNode.GetChild(ENodeName.bullet) as BulletNode;
            ActionRefNode testActionRefNode = testBulletNode.GetChild(ENodeName.actionRef) as ActionRefNode;
            ActionNode    refNode           = testActionRefNode.ReferencedActionNode as ActionNode;

            Assert.AreEqual(refNode.Label, "test2");
        }
Exemplo n.º 22
0
        private void CreateNewNode(Vector2 thePosition, int NewNodes)
        {
            if (NewNodes == 0)
            {
                return;
            }
            FireNode newNode = new FireNode();

            newNode.m_FireObject        = new StaticObject(thePosition, m_sprite);
            newNode.m_fLifeLeft         = (float)Firecracker.random.NextDouble();
            newNode.m_fSpeed            = (float)Firecracker.random.NextDouble() * 100.0f;
            newNode.m_vTargetLocation.X = thePosition.X + Firecracker.theRandom.Next(-450, 450);
            newNode.m_vTargetLocation.Y = thePosition.Y + Firecracker.theRandom.Next(-450, 450);
            newNode.m_vCurrentLocation  = thePosition;
            newNode.m_iNodesRemaining   = NewNodes;
            m_lFireObjects.Add(newNode);
        }
Exemplo n.º 23
0
        public override void update(GameTime gameTime)
        {
            for (int i = 0; i < m_lFireObjects.Count(); i++)
            {
                FireNode theNode = m_lFireObjects[i];
                Vector2  newPos  = theNode.m_vTargetLocation - m_lFireObjects[i].m_vCurrentLocation;
                newPos.Normalize();
                newPos *= (float)(m_lFireObjects[i].m_fSpeed * gameTime.ElapsedGameTime.TotalSeconds);
                theNode.m_vCurrentLocation    = m_lFireObjects[i].m_vCurrentLocation + newPos;
                theNode.m_fLifeLeft          -= (float)gameTime.ElapsedGameTime.TotalSeconds;
                theNode.m_FireObject.position = theNode.m_vCurrentLocation;

                m_lFireObjects[i] = theNode;

                if (m_lFireObjects[i].m_fLifeLeft <= 0)
                {
                    CreateNewNode(m_lFireObjects[i].m_vCurrentLocation, m_lFireObjects[i].m_iNodesRemaining - 1);
                    CreateNewNode(m_lFireObjects[i].m_vCurrentLocation, m_lFireObjects[i].m_iNodesRemaining - 1);
                    m_lFireObjects.RemoveAt(i);
                    i--;
                    continue;
                }


                // check the collisions.
                for (int j = 0; j < Firecracker.level.numberOfObjects(); j++)
                {
                    GameObject theObj = Firecracker.level.objectAt(j);
                    if (theObj.GetType() == typeof(NPCObject))
                    {
                        if ((theObj.position - m_lFireObjects[i].m_vCurrentLocation).Length() < 10)
                        {
                            // kill this guy.
                            theObj.toBeDeleted = true;
                            Explosion  newDeath = new Explosion(theObj.position);
                            HumanDeath ashDeath = new HumanDeath(theObj.position);
                            Firecracker.level.addObject(newDeath);
                            Firecracker.level.addObject(ashDeath);
                        }
                    }
                }
            }
            base.update(gameTime);
        }
Exemplo n.º 24
0
        public void FoundCorrectActionNode()
        {
            var           filename = TestUtils.GetFilePath(@"Content\ActionRefParam.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.Parse(filename);

            ActionNode testActionNode = pattern.RootNode.GetChild(NodeName.action) as ActionNode;

            Assert.IsNotNull(testActionNode);
            FireNode testFireNode = testActionNode.GetChild(NodeName.fire) as FireNode;

            Assert.IsNotNull(testFireNode);
            BulletNode testBulletNode = testFireNode.GetChild(NodeName.bullet) as BulletNode;

            Assert.IsNotNull(testBulletNode);
            ActionRefNode testActionRefNode = testBulletNode.GetChild(NodeName.actionRef) as ActionRefNode;

            Assert.IsNotNull(testActionRefNode);
            ActionNode refNode = testActionRefNode.ReferencedActionNode;

            Assert.IsNotNull(testActionNode);
            Assert.AreEqual("test2", refNode.Label);
        }
Exemplo n.º 25
0
 private void AddNeighborOnce(FireNode neighbor)
 {
     _neighbors.Add(neighbor);
 }
Exemplo n.º 26
0
 public void AddNeighbor(FireNode neighbor)
 {
     _neighbors.Add(neighbor);
     neighbor.AddNeighborOnce(this);
 }