Esempio n. 1
0
 private void Instantiate(GameObject enemyBullet)
 {
     movement = new BulletMovementPattern(movement);
     bullet   = (Object.Instantiate(enemyBullet, newPosition, bulletRotation) as GameObject);
     bullet.transform.SetParent(GameObject.FindWithTag("BulletsRepo").transform);
     bullet.GetComponent <EnemyBulletMovement> ().SetUpBulletMovement(movement);
     bullet.GetComponent <SpriteRenderer> ().sprite = sprite;
     enemy.bulletsShot.Add(bullet);
 }
Esempio n. 2
0
 public BulletMovementPattern(BulletMovementPattern b)
 {
     isHoming        = b.isHoming;
     property        = b.property;
     movementSpeed   = b.movementSpeed;
     isMoving        = true;
     layer           = b.layer;
     p               = b.p;
     count           = p.bulletCount;
     rotateOnAxis    = false;
     properties      = new ArrayList();
     targetMagnitude = (float)b.targetMagnitude;
     scale           = new Vector3(2, 2, 2);
 }
Esempio n. 3
0
    public IEnumerator Execute(GameObject enemyBullet, Vector3 pos, Quaternion rot, EnemyShoot _enemy)
    {
        enemy          = _enemy;
        phase          = enemy.phase;
        newPosition    = pos;
        bulletRotation = rot;

        switch (name)
        {
        case "Circle":
            GameController.gameControl.sound.PlaySound("Enemy", "Shoot", true);
            for (int i = 0; i < bulletCount; i++)
            {
                newPosition = SpawnInCircle(pos, 0f, GetAng(i, 360));
                Instantiate(enemyBullet);
            }
            break;

        case "Laser":
            if (bulletCount > 1)
            {
                for (int i = 0; i < bulletCount; i++)
                {
                    float ang = (i * (360 / bulletCount) + (360 / bulletCount)) * 0.7f;
                    if (i >= 3)
                    {
                        ang += 60;
                    }

                    newPosition = SpawnInCircle(pos + new Vector3(0, 1f, 0), 1.5f, ang);

                    movement            = new BulletMovementPattern(false, "ExpandToLaser", 0f, this, 0, tempMagnitude);
                    movement.laserIndex = laserIndex;
                    laserIndex++;

                    Instantiate(enemyBullet);

                    bullet.GetComponent <SpriteRenderer> ().sprite = sprite;
                    if (laserIndex == 0)
                    {
                        laserIndex++;
                    }
                    else
                    {
                        laserIndex = 0;
                    }
                }
            }
            else
            {
                sprite      = Resources.Load <Sprite> ("enemyLaser");
                newPosition = pos - new Vector3(0f, .2f, 0f);

                movement            = new BulletMovementPattern(false, "PendulumLaser", 0f, this, 0, tempMagnitude);
                movement.laserIndex = laserIndex;

                Instantiate(enemyBullet);
            }

            break;

        case "Maelstrom":
            stop = false;

            while (!stop)
            {
                GameController.gameControl.sound.PlaySound("Enemy", "Shoot", true);
                for (int i = 0; i < bulletCount; i++)
                {
                    newPosition       = SpawnInCircle(pos, 1.5f, GetAng(i, 360) + startingRotation);
                    bulletRotation    = SpawnInCircle(i, startingRotation);
                    startingRotation += 0.5f * rotationDirection;
                    Instantiate(enemyBullet);
                }
                yield return(new WaitForSeconds(coolDown));
            }
            break;

        case "Cluster":
            int dir = 1;
            for (int i = 0; i < bulletCount; i++)
            {
                newPosition    = enemy.GetLocalPosition() + new Vector3(Random.Range(-.8f, .8f), 1.5f * dir, 0);
                bulletRotation = bulletRotation * Quaternion.Euler(0, 0, 180f + (Random.Range(-10, 10)));
                movement       = new BulletMovementPattern(false, "Aurora", 10f, this, tempLayer, tempMagnitude);
                Instantiate(enemyBullet);
                dir = -dir;

                yield return(new WaitForSeconds(coolDown));

                CheckSoundPlay(i, 5);
                //if(i % 2 == 0) SetSprite ("Arrow", "Glow", "Red");
                //if(i % 3 == 0) SetSprite ("Arrow", "Glow", "Honey");
                //if(i % 4 == 0) SetSprite ("Arrow", "Glow", "Purple");
                //if(i % 5 == 0) SetSprite ("Arrow", "Glow", "Green");
            }
            allBulletsSpawned = true;
            break;

        case "Curtain":
            for (int i = 0; i < bulletCount; i++)
            {
                if (lineDirection == 1)
                {
                    newPosition = SpawnInLine(-15, 20, lineDirection, i);
                }
                else
                {
                    newPosition = SpawnInLine(2, 20, lineDirection, i);
                }
                movement = new BulletMovementPattern(movement);

                Instantiate(enemyBullet);
                bullet.GetComponent <SpriteRenderer> ().sprite = sprite;

                yield return(new WaitForSeconds(coolDown));

                GameController.gameControl.sound.PlaySound("Enemy", "Shoot", false);
            }
            lineDirection = -lineDirection;
            break;

        case "Spiral":
            if (loopCircles == 0)
            {
                loopCircles = 360;
            }
            Vector3 centerPos = pos;
            allBulletsSpawned = false;
            for (int i = 0; i < bulletCount; i++)
            {
                newPosition = SpawnInCircle(pos, 1f + (i * 0.1f), GetAng(i, loopCircles));
                Instantiate(enemyBullet);
                yield return(new WaitForSeconds(coolDown));

                GameController.gameControl.sound.PlaySound("Enemy", "Shoot", false);
            }

            allBulletsSpawned = true;
            break;

        case "SingleHoming":
            GameController.gameControl.sound.PlaySound("Enemy", "Shoot", false);
            Instantiate(enemyBullet);
            break;

        case "PacMan":

            for (int i = 0; i < bulletCount; i++)
            {
                sprite         = Resources.Load <Sprite> ("enemyProjectile2");
                newPosition    = pos + new Vector3(0f, 0f, 0f);
                bulletRotation = Quaternion.Euler(0f, 0f, startingRotation + (float)i * rotationMultiplier);
                movement       = new BulletMovementPattern(false, null, 0.5f, this, 0, tempMagnitude);
                bullet.GetComponent <SpriteRenderer> ().sprite = sprite;
                startingRotation += 0.1f;
                Instantiate(enemyBullet);
            }
            break;

        case "SpiderWeb":
            bullets = new ArrayList();
            for (int i = 0; i < bulletCount; i++)
            {
                newPosition    = pos + new Vector3(0f, 0f, 0f);
                bulletRotation = rot;
                animating      = false;
                animation      = (Resources.Load("Images/Animations/Animation") as GameObject);
                movement       = new BulletMovementPattern(movement);

                Instantiate(enemyBullet);
                bullet.GetComponent <SpriteRenderer> ().sprite = spriteLib.SetBulletSprite("Circle", "Glow", "Red");
            }
            break;

        case "GiantWeb":
            bullets = new ArrayList();
            yield return(new WaitForSeconds(2f));

            pos = enemy.GetLocalPosition();
            if (tempMagnitude > 0)
            {
                float b = bulletCount / 2 + tempMagnitude;
                for (int i = 0; i < Mathf.RoundToInt(b); i++)
                {
                    newPosition    = pos + new Vector3(0f, 0f, 0f);
                    bulletRotation = Quaternion.Euler(0f, 0f, i * (360 / b));
                    animation      = (Resources.Load("Images/Animations/Animation") as GameObject);
                    movement       = new BulletMovementPattern(false, "StopAndRotate", 20f, this, tempLayer, tempMagnitude);
                    Instantiate(enemyBullet);
                    bullet.GetComponent <SpriteRenderer> ().sprite = spriteLib.SetBulletSprite("Circle", "Big", "Red");
                    bullets.Add(enemyBullet);
                }
                tempMagnitude -= 3;
                tempLayer++;
                tempLayer = UpdateLayer(tempLayer);
            }
            else
            {
                tempMagnitude = originMagnitude;
            }
            yield return(new WaitForSeconds(coolDown));

            animating = false;
            break;
        }
    }
Esempio n. 4
0
 public void Customize(BulletMovementPattern _movement)
 {
     movement = new BulletMovementPattern(_movement);
 }
 public void SetUpBulletMovement(BulletMovementPattern b)
 {
     movement = b;
     StartCoroutine(b.Execute(this.gameObject));
 }