void Start()
    {
        healthSpawnScript = GetComponentInChildren <SpawnHealth>();
        enemySpawnScript  = GetComponentInChildren <EnemySpawner>();
        audio             = GetComponentInChildren <AudioSource>(); //get the audiosource on the enemyspawner script

        EnemiesOnScreen = 0;                                        //starts off with no enemies on the screen
        comboCount      = 0;

        StartCoroutine(StartGame());//start the spawning loop
    }
Esempio n. 2
0
    void Awake()
    {
        enemyMovement   = GetComponent <EnemyMovement>();
        thisRigidbody2D = GetComponent <Rigidbody2D>();
        damageObject    = GetComponent <DamageObject>();
        spawnHealth     = GetComponent <SpawnHealth>();
        spawnForceField = GetComponent <SpawnForceField>();

        damageTimeout = 0.4f;
        blobState     = State.Roaming;
        startPosition = transform.position;
        thisEnemy     = gameObject;
    }
Esempio n. 3
0
    void Shoot()
    {
        timer = 0f;

        gunAudio.Play();
        gunParticles.Stop();
        gunParticles.Play();

        gunLine.enabled = true;
        gunLine.SetPosition(0, transform.position);
        shootRay = Camera.main.ScreenPointToRay(Input.mousePosition);
        //shootRay.origin = transform.position;
        //shootRay.direction = transform.forward;

        if (Physics.Raycast(shootRay, out shootHit, range, shootableMask))
        {
            AlienOneHealth alienHealth = shootHit.collider.GetComponent <AlienOneHealth> ();
            if (alienHealth != null)
            {
                alienHealth.TakeDamage(damagePerShot, shootHit.point);
            }

            ShortAlienHealth shortHealth = shootHit.collider.GetComponent <ShortAlienHealth>();
            if (shortHealth != null)
            {
                shortHealth.TakeDamage(damagePerShot, shootHit.point);
            }

            LogHealth logHealth = shootHit.collider.GetComponent <LogHealth>();
            if (logHealth != null)
            {
                logHealth.TakeDamage(damagePerShot, shootHit.point);
            }

            SpawnHealth spawnHealth = shootHit.collider.GetComponent <SpawnHealth>();
            if (spawnHealth != null)
            {
                spawnHealth.TakeDamage(damagePerShot, shootHit.point);
            }
            gunLine.SetPosition(1, shootHit.point);
        }
        else
        {
            gunLine.SetPosition(1, shootRay.origin + shootRay.direction * range);
        }
    }