// helper methods
    private void InitializeEnemy()
    {
        // Simple
        m_name                = enemyDefinitions.name;
        m_maxHealth           = enemyDefinitions.maxHealth;
        m_invincibleWhileIdle = enemyDefinitions.invincibleWhileIdle;
        m_aggroDistance       = enemyDefinitions.aggroDistance;
        m_walkSpeed           = enemyDefinitions.walkSpeed;
        m_runSpeed            = enemyDefinitions.runSpeed;
        m_damage              = enemyDefinitions.damagePerBullet;
        // Complex
        this.GetComponent <SpriteRenderer>().sprite = enemyDefinitions.sprite;
        m_projectilePrefab = enemyDefinitions.bulletPrefab;
        m_BulletPattern    = enemyDefinitions.bulletPattern;
        m_idleAI           = enemyDefinitions.idleAI;
        m_aggroAI          = enemyDefinitions.aggroAI;
        m_possibleDrops    = enemyDefinitions.possibleDrops;
        m_dropPercentages  = enemyDefinitions.dropPercentages;

        // Check if bullet pattern SO is valid.
        // TODO: automatic way to do this?
        // TODO: move to bulletcontroller?
        if (m_BulletPattern.numberOfBullets != m_BulletPattern.listOfAngles.Count ||
            m_BulletPattern.listOfAngles.Count != 1 + m_BulletPattern.delayBetweenBullets.Count)
        {
            Debug.Log("ERROR with Bullet Pattern counts for enemy: " + m_name);
        }
        // Check if drop table is valid
        if (m_possibleDrops.Count != m_dropPercentages.Count)
        {
            Debug.Log("ERROR with counts for drop table for enemy: " + m_name);
        }
    }
Exemplo n.º 2
0
 public void setupHarness()
 {
     Filename.SetCurrentDirectory(@"C:\Projects\BulletMLLib\BulletMLLib\BulletMLLib.Tests\bin\Debug");
     dude    = new Myship();
     manager = new MoverManager(dude.Position);
     pattern = new BulletPattern();
 }
        /// <summary>
        /// Load the pattern if necessary and store it in cache
        /// </summary>
        public static BulletPattern LoadPattern(TextAsset xmlFile, bool reloadCacheToo)
        {
            BulletPattern loadedPattern = null;

            // Cache the pattern to avoid reparsing everytime
            if (reloadCacheToo || patternCache.TryGetValue(xmlFile, out loadedPattern) == false)
            {
                System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(new System.IO.StringReader(xmlFile.text));
                reader.Normalization = false;
                reader.XmlResolver   = null;

                loadedPattern = new BulletMLLib.BulletPattern();
                loadedPattern.ParseXML(xmlFile.name, reader);

                if (patternCache.ContainsKey(xmlFile))
                {
                    patternCache[xmlFile] = loadedPattern;
                }
                else
                {
                    patternCache.Add(xmlFile, loadedPattern);
                }
            }

            return(loadedPattern);
        }
Exemplo n.º 4
0
        public void FireDirectionSequence()
        {
            var filename = TestUtils.GetFilePath(@"Content\FireDirectionSequence2.xml");
            var pattern  = new BulletPattern();

            pattern.Parse(filename);

            var mover = (Mover)TestUtils.Manager.CreateBullet();

            mover.InitTopNode(pattern.RootNode);

            Assert.AreEqual(1, mover.Tasks.Count);
            Assert.AreEqual(2, mover.Tasks[0].ChildTasks.Count);

            TestUtils.Manager.Update();

            Assert.AreEqual(3, TestUtils.Manager.Movers.Count);

            var bullet1 = TestUtils.Manager.Movers[1] as Bullet;
            var bullet2 = TestUtils.Manager.Movers[2] as Bullet;

            Assert.IsNotNull(bullet1);
            Assert.IsNotNull(bullet2);

            Assert.AreEqual(90f, MathHelper.ToDegrees(bullet1.Direction));
            Assert.AreEqual(MathHelper.ToDegrees(bullet1.Direction) + 10f, MathHelper.ToDegrees(bullet2.Direction));
        }
Exemplo n.º 5
0
        public void DirectionNodeSequence2()
        {
            var filename = TestUtils.GetFilePath(@"Content\FireDirectionSequence2.xml");
            var pattern  = new BulletPattern();

            pattern.Parse(filename);

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

            Assert.IsNotNull(actionNode);
            Assert.AreEqual(2, actionNode.ChildNodes.Count);

            var fireNode1 = actionNode.ChildNodes[0] as FireNode;
            var fireNode2 = actionNode.ChildNodes[1] as FireNode;

            Assert.IsNotNull(fireNode1);
            Assert.IsNotNull(fireNode2);

            var directionNode1 = fireNode1.GetChild(NodeName.direction) as DirectionNode;
            var directionNode2 = fireNode2.GetChild(NodeName.direction) as DirectionNode;

            Assert.IsNotNull(directionNode1);
            Assert.IsNotNull(directionNode2);
            Assert.AreEqual(NodeType.absolute, directionNode1.NodeType);
            Assert.AreEqual(NodeType.sequence, directionNode2.NodeType);
        }
Exemplo n.º 6
0
    //START
    void Start()
    {
        //Boss
        Boss = GameObject.FindGameObjectWithTag("Boss");

        //Bullet pattern
        bulletPattern = GameObject.FindGameObjectWithTag("BossAbilities").GetComponent <BulletPattern>();

        //Player
        GameObject[] playerTagged = GameObject.FindGameObjectsWithTag("Player");
        foreach (var foundObject in playerTagged)
        {
            switch (foundObject.name)
            {
            case "Player":
                playerScript = foundObject.GetComponent <PF_Player>();
                break;

            case "Player Model":
                playerModel = foundObject;
                break;

            default:
                break;
            }
        }
    }
Exemplo n.º 7
0
    void CircleRainMainFunction()
    {
        for (int i = 0; i < 27; i++)
        {
            GameObject redBullet = ObjectPooler.Instance.getPooledObject("Rhythm Bullet");
            bulletPattern = (BulletPattern)redBullet.GetComponent(typeof(BulletPattern));

            if (redBullet != null)
            {
                redBullet.transform.position       = transform.position;
                redBullet.transform.rotation       = transform.rotation;
                redBullet.transform.rotation      *= Quaternion.Euler(0, i * (360f / 27f), 0);
                bulletPattern.bulletSpeed          = 10f;
                bulletPattern.selfDestructTimer    = 10f;
                bulletPattern.rainFallStopTimer    = 1.75f - (0.25f * circleRainWaveCount);
                bulletPattern.rainFallTimer        = 2.25f;
                bulletPattern.currentBulletPattern = BulletPattern.BulletPatternType.RAIN;
                redBullet.SetActive(true);

                if (i == 0)
                {
                    redBullet.GetComponent <BulletPattern>().isCircleRainTriggerSound = true;
                    SoundManagerScript.mInstance.PlaySFX(AudioClipID.SFX_BULLET_BOMBING_RUN_TOUCHDOWN);
                }
            }
        }

        circleRainWaveCount++;
    }
Exemplo n.º 8
0
    void ConeShotMainFunction()
    {
        for (int i = 0; i < 15; i++)
        {
            GameObject redBullet = ObjectPooler.Instance.getPooledObject("Rhythm Bullet");
            bulletPattern = (BulletPattern)redBullet.GetComponent(typeof(BulletPattern));

            if (redBullet != null)
            {
                redBullet.transform.position       = transform.position;
                redBullet.transform.rotation       = transform.rotation;
                redBullet.transform.rotation      *= Quaternion.Euler(i * 24, 0, 0);
                bulletPattern.bulletSpeed          = 10f;
                bulletPattern.selfDestructTimer    = 10f;
                bulletPattern.aimPlayerTimer       = 1f;
                bulletPattern.currentBulletPattern = BulletPattern.BulletPatternType.AIM_PLAYER;
                redBullet.SetActive(true);

                if (i == 9)
                {
                    redBullet.GetComponent <BulletPattern>().isConeShotTrigger = true;
                }
            }
        }

        SoundManagerScript.mInstance.PlaySFX(AudioClipID.SFX_BULLET_BOMBING_RUN_TOUCHDOWN);
        coneShotWaveCount++;
    }
Exemplo n.º 9
0
    //START
    private void Start()
    {
        BlockLearn = new NaiveBayesLearning();
        //Get scripts
        bossStats = GetComponent <Stats>();
        //Bullet pattern
        bulletPattern = GameObject.FindGameObjectWithTag("BossAbilities").GetComponent <BulletPattern>();

        //Populate dictionary
        GameObject[] positions = GameObject.FindGameObjectsWithTag("Orientation");
        foreach (var position in positions)
        {
            switch (position.name)
            {
            case "Top":
                orientationDictionary.Add(Orientation.Top, position.transform);
                break;

            case "Left":
                orientationDictionary.Add(Orientation.Left, position.transform);
                break;

            case "Right":
                orientationDictionary.Add(Orientation.Right, position.transform);
                break;
            }
        }
    }
Exemplo n.º 10
0
    void BombingRunMainFunction()
    {
        float      randomAngle = Random.Range(-180, 180);
        GameObject blueBullet  = ObjectPooler.Instance.getPooledObject("Rhythm Bullet"); // Non-Rhythm Bullet (Non-Rhythm Bullet - Actual)

        bulletPattern = (BulletPattern)blueBullet.GetComponent(typeof(BulletPattern));

        if (blueBullet != null)
        {
            blueBullet.transform.position      = transform.position;
            blueBullet.transform.rotation      = transform.rotation;
            blueBullet.transform.rotation     *= Quaternion.Euler(0, randomAngle, 0);
            bulletPattern.isBomb               = true;
            bulletPattern.turningAngle         = Random.Range(80, 100);
            bulletPattern.smoothing            = 2f;
            bulletPattern.selfDestructTimer    = 10f;
            bulletPattern.currentBulletPattern = BulletPattern.BulletPatternType.STRAIGHT;
            blueBullet.SetActive(true);

            blueBullet.GetComponent <BulletPattern>().playBulletDroppingSound = true;

            if (bossAIScript.playBossAttackingAnimation == true)
            {
                bossAIScript.bossAnimator.Play("BossAttackAnimation", -1, 0.0f);

                bossAIScript.playBossAttackingAnimation = false;
            }
        }
    }
Exemplo n.º 11
0
 public void ValidRepeats()
 {
     BulletPattern.FromString(@"
     <bulletml>
       <action label=""top"">
         <repeat>
           <times>1</times>
           <action/>
         </repeat>
       </action>
     </bulletml>
     ");
     BulletPattern.FromString(@"
     <bulletml>
       <action label=""top"">
         <repeat>
           <times>$rank*(1+2)</times>
           <action/>
         </repeat>
       </action>
     </bulletml>
     ");
     BulletPattern.FromString(@"
     <bulletml>
       <action label=""top"">
         <repeat>
           <times>1</times>
           <actionRef label=""test""/>
         </repeat>
       </action>
       <action label=""test""/>
     </bulletml>
     ");
 }
Exemplo n.º 12
0
        public void InvalidAccels()
        {
            var thrown = Assert.Throws <InvalidBulletPatternException>(delegate
            {
                BulletPattern.FromString(@"
                <bulletml>
                  <action label=""top"">
                    <accel>
                      <horizontal>0</horizontal>
                      <vertical>0</vertical>
                    </accel>
                  </action>
                </bulletml>
                ");
            });

            var thrown2 = Assert.Throws <InvalidBulletPatternException>(delegate
            {
                BulletPattern.FromString(@"
                <bulletml>
                  <action label=""top"">
                    <accel><term>0</term><horizontal type=""hi"">0</horizontal></accel>
                  </action>
                </bulletml>
                ");
            });

            Assert.IsInstanceOf <XmlSchemaValidationException>(thrown.InnerException);
            Assert.IsInstanceOf <XmlSchemaValidationException>(thrown2.InnerException);
        }
Exemplo n.º 13
0
        public void RejectsNonEmptyVanishElements()
        {
            var thrown = Assert.Throws <InvalidBulletPatternException>(delegate
            {
                BulletPattern.FromString(@"
                <bulletml>
                  <action label=""top"">
                    <vanish>hi</vanish>
                  </action>
                </bulletml>
                ");
            });

            var thrown2 = Assert.Throws <InvalidBulletPatternException>(delegate
            {
                BulletPattern.FromString(@"
                <bulletml>
                  <action label=""top"">
                    <vanish><bullet/></vanish>
                  </action>
                </bulletml>
                ");
            });

            Assert.IsInstanceOf <XmlSchemaValidationException>(thrown.InnerException);
            Assert.IsInstanceOf <XmlSchemaValidationException>(thrown2.InnerException);
        }
Exemplo n.º 14
0
        public void AccelNodeTermOnly()
        {
            var filename = TestUtils.GetFilePath(@"Content\Test\Accel\Invalid\AccelNodeTermOnly.xml");
            var pattern  = new BulletPattern();

            Assert.Throws <InvalidDataException>(() => pattern.Parse(filename));
        }
Exemplo n.º 15
0
        public void AccelNodeVerticalHorizontal()
        {
            var filename = TestUtils.GetFilePath(@"Content\Test\Accel\Valid\AccelNodeVerticalHorizontal.xml");
            var pattern  = new BulletPattern();

            pattern.Parse(filename);

            var topNode = pattern.RootNode.FindLabelNode("top", NodeName.action) as ActionNode;

            Assert.IsNotNull(topNode);
            Assert.AreEqual(1, topNode.ChildNodes.Count);

            var accelNode = topNode.ChildNodes[0] as AccelNode;

            Assert.IsNotNull(accelNode);
            Assert.AreEqual(3, accelNode.ChildNodes.Count);

            var verticalNode   = accelNode.ChildNodes[0] as VerticalNode;
            var horizontalNode = accelNode.ChildNodes[1] as HorizontalNode;
            var termNode       = accelNode.ChildNodes[2] as TermNode;

            Assert.IsNotNull(verticalNode);
            Assert.IsNotNull(horizontalNode);
            Assert.IsNotNull(termNode);
        }
Exemplo n.º 16
0
        public void CreatedSpeedNode()
        {
            var filename = TestUtils.GetFilePath(@"Content\FireSpeed.xml");
            var pattern = new BulletPattern();
            pattern.Parse(filename);

            Assert.IsNotNull(pattern.RootNode);
        }
Exemplo n.º 17
0
        public void CreatedBulletNode()
        {
            string        filename = @"Content\BulletEmpty.xml";
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename);

            Assert.IsNotNull(pattern.RootNode);
        }
Exemplo n.º 18
0
    void SuperMegaUltraDeathBombMainFunction()
    {
        if (!dropSuperMegaUltraDeathBomb)
        {
            float      randomAngle = Random.Range(-180, 180);
            GameObject blueBullet  = ObjectPooler.Instance.getPooledObject("Rhythm Bullet"); //Non rhythm Bullet Please

            bulletPattern = (BulletPattern)blueBullet.GetComponent(typeof(BulletPattern));

            if (blueBullet != null)
            {
                blueBullet.transform.position      = transform.position;
                blueBullet.transform.rotation      = transform.rotation;
                blueBullet.transform.rotation     *= Quaternion.Euler(0, randomAngle, 0);
                bulletPattern.isBomb               = true;
                bulletPattern.turningAngle         = Random.Range(80, 100);
                bulletPattern.smoothing            = 2f;
                bulletPattern.selfDestructTimer    = 10f;
                bulletPattern.currentBulletPattern = BulletPattern.BulletPatternType.STRAIGHT;
                blueBullet.SetActive(true);

                blueBullet.GetComponent <BulletPattern>().playBulletDroppingSound = true;

                if (bossAIScript.playBossAttackingAnimation == true)
                {
                    bossAIScript.bossAnimator.Play("BossAttackAnimation", -1, 0.0f);

                    bossAIScript.playBossAttackingAnimation = false;
                }
            }
        }
        else
        {
            GameObject redBullet = ObjectPooler.Instance.getPooledObject("Rhythm Bullet"); //Non rhythm Bullet Please
            bulletPattern = (BulletPattern)redBullet.GetComponent(typeof(BulletPattern));

            if (redBullet != null)
            {
                redBullet.transform.position            = transform.position;
                redBullet.transform.localRotation       = Quaternion.Euler(90, 0, 0);
                bulletPattern.isSuperUltraMegaDeathBomb = true;
                bulletPattern.bulletSpeed          = 10f;
                bulletPattern.selfDestructTimer    = 10f;
                bulletPattern.currentBulletPattern = BulletPattern.BulletPatternType.STRAIGHT;
                redBullet.SetActive(true);

                redBullet.GetComponent <BulletPattern>().playBulletDroppingSound = true;

                if (bossAIScript.playBossAttackingAnimation == true)
                {
                    bossAIScript.bossAnimator.Play("BossAttackAnimation", -1, 0.0f);

                    bossAIScript.playBossAttackingAnimation = false;
                }
            }
        }
    }
Exemplo n.º 19
0
        public void TestIsParent()
        {
            var           filename = new Filename(@"Empty.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);

            Assert.AreEqual(pattern.RootNode, pattern.RootNode.GetRootNode());
        }
Exemplo n.º 20
0
        public void ValidXml()
        {
            var filename = TestUtils.GetFilePath(@"Content\BulletRef.xml");
            var pattern  = new BulletPattern();

            pattern.Parse(filename);

            Assert.IsNotNull(pattern.RootNode);
        }
Exemplo n.º 21
0
        public void TestIsParent()
        {
            var filename = TestUtils.GetFilePath(@"Content\Empty.xml");
            var pattern  = new BulletPattern();

            pattern.Parse(filename);

            Assert.AreEqual(pattern.RootNode.GetRootNode(), pattern.RootNode);
        }
Exemplo n.º 22
0
 private void PerformAttack(int attackNumber)
 {
     if (attackNumber < attackType.Count)
     {
         BulletPattern attack = Instantiate(attackType[attackNumber], transform.position, transform.rotation);
         attack.tag = transform.root.tag;
         attack.SetOwner(owner);
     }
 }
Exemplo n.º 23
0
        public void TestIsParent()
        {
            string        filename = @"Content\Empty.xml";
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename);

            Assert.AreEqual(pattern.RootNode, pattern.RootNode.GetRootNode());
        }
Exemplo n.º 24
0
        public void CreatedDirectionNode()
        {
            string        filename = @"Content\FireDirection.xml";
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename);

            Assert.IsNotNull(pattern.RootNode);
        }
Exemplo n.º 25
0
        public void CreatedSpeedNode()
        {
            var           filename = new Filename(@"FireSpeed.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);

            Assert.IsNotNull(pattern.RootNode);
        }
Exemplo n.º 26
0
    public void ChangeWeapon(BulletPattern weapon)
    {
        if (weapon == null)
        {
            return;
        }

        Spawner.Pattern = weapon;
    }
Exemplo n.º 27
0
        public void ValidXML()
        {
            string        filename = @"Content\ActionRefEmpty.xml";
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename);

            Assert.IsNotNull(pattern.RootNode);
        }
Exemplo n.º 28
0
        public void ValidXML()
        {
            var           filename = new Filename(@"ActionRefEmpty.xml");
            BulletPattern pattern  = new BulletPattern();

            pattern.ParseXML(filename.File);

            Assert.IsNotNull(pattern.RootNode);
        }
Exemplo n.º 29
0
        public void CreatedBulletNode()
        {
            var filename = TestUtils.GetFilePath(@"Content\EmptyBullet.xml");
            var pattern  = new BulletPattern();

            pattern.Parse(filename);

            Assert.IsNotNull(pattern.RootNode);
            Assert.AreEqual(1, pattern.RootNode.ChildNodes.Count);
        }
Exemplo n.º 30
0
        public void TestEmptyFromString()
        {
            BulletPattern pattern = BulletPattern.FromString("<bulletml/>");

            Assert.AreEqual(EPatternType.none, pattern.Orientation);

            Assert.IsNotNull(pattern.RootNode);
            Assert.AreEqual(pattern.RootNode.Name, ENodeName.bulletml);
            Assert.AreEqual(pattern.RootNode.NodeType, ENodeType.none);
        }
Exemplo n.º 31
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);
    }
Exemplo n.º 32
0
 // Must be called before start.
 public void SetBulletPattern(BulletPattern pattern)
 {
     this.bulletPattern = pattern;
 }
 void OnEnable()
 {
     bp = target as BulletPattern;
     bm = GameObject.Find("BulletManager").GetComponent<BulletManager>();
 }