示例#1
0
    void SelectPresetBehavior()
    {
        // random selection of behavior presets

        float max_array = Convert.ToSingle(
            behaviorPresets.behaviorArray.Length) - float.Epsilon;
        int randRange = (int)Random.Range(0, max_array);

        BossBehaviorPresets.BossBehavior behaviorData = behaviorPresets.behaviorArray[randRange];

        StopCoroutine("shoot");
        StartCoroutine("shoot", behaviorData);
        StartCoroutine(move(behaviorData.bossSpeed));



        // default behavior for testing presets

        /*
         * BossBehaviorPresets.BossBehavior behaviorTest = new BossBehaviorPresets.BossBehavior(
         *  15f, 5f, 0.2f, 1.5f
         * );
         * StopCoroutine("shoot");
         * StartCoroutine("shoot", behaviorTest);
         * StartCoroutine(move(behaviorTest.bossSpeed));
         */
    }
示例#2
0
 // bullet angle needs to be between 1 and 2.
 IEnumerator shoot(BossBehaviorPresets.BossBehavior behaviorData)
 {
     while (true)
     {
         // TODO ping pong and change the value of bullet ange
         // at each co routine
         Bullet bullet = Instantiate(bulletPrefab) as Bullet;
         bullet.speed       = behaviorData.bulletSpeed;
         bullet.angleFactor = behaviorData.bulletAngle;
         yield return(new WaitForSeconds(behaviorData.shootingFrequency));
     }
 }