Esempio n. 1
0
    private void Update()
    {
        transform.forward = targetPoint - transform.position;
        if (fired && delayTimer.expired)
        {
            delayTimer = null;
            fired      = false;

            var proj = Instantiate(subProjectile, transform.position, subProjectile.transform.rotation);
            if (parent)
            {
                proj.transform.parent = transform;
            }

            if (fireAtTarget)
            {
                proj.Fire(targetPoint - transform.position);
            }
            else
            {
                proj.Fire();
            }

            shootSound?.PlayAtPoint(transform.position);

            if (destroyAfterFiring)
            {
                Destroy(gameObject, linger);
            }
        }
    }
    // Update is called once per frame
    protected override void Update()
    {
        base.Update();

        float start = startAngle;

        if (startAngleRelative)
        {
            start += transform.eulerAngles.y;
        }

        if (timer.expired && fired)
        {
            float angleStep = 360.0f / spawnCount;
            for (int i = 0; i < spawnCount; i++)
            {
                Quaternion rot = Quaternion.Euler(0, start + angleStep * i, 0);
                Instantiate(subProjectile, transform.position, rot).Fire();
                if (sound)
                {
                    sound.PlayAtPoint(transform.position);
                }
            }
            Destroy(gameObject);
        }
    }
Esempio n. 3
0
    protected override void DoOutput(FighterChannels channels)
    {
        if (channels.attack1 && shootTimer.canUse && (magazine?.Fire() != false))
        {
            shootTimer.Use();
            shootSound?.PlayAtPoint(transform.position);

            if (gunMode == SpawnMode.All)
            {
                for (int i = 0; i < guns.Length; i++)
                {
                    FireGun(i);
                }
            }
            else if (gunMode == SpawnMode.Cycle)
            {
                FireGun(currentGun);
                currentGun = (currentGun + 1) % guns.Length;
            }
            else
            {
                FireGun(Random.Range(0, guns.Length));
            }
        }
    }
Esempio n. 4
0
    private void OnZeroHealth()
    {
        Destroy(gameObject);
        Instantiate(explosionPrefab, transform.position, Quaternion.identity);
        deathSound?.PlayAtPoint(transform.position);

        GameStateManager.inst.LoseGame();
    }
Esempio n. 5
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.transform.root.CompareTag("Player"))
     {
         TakeEffect(other.GetComponentInParent <PlayerShip>());
         Destroy(gameObject);
         sound?.PlayAtPoint(transform.position);
     }
 }
Esempio n. 6
0
    private void OnDamage(Damage dmg)
    {
        impactSound?.PlayAtPoint(transform.position);
        GameStateManager.inst.damageTaken += dmg.amount;

        if (impactVfx && impactSites?.childCount > 0)
        {
            var gameObj = Instantiate(impactVfx, transform);
            var ind     = Random.Range(0, impactSites.childCount);
            gameObj.transform.localPosition = impactSites.GetChild(ind).localPosition;
        }
    }
Esempio n. 7
0
 // Use this for initialization
 void Awake()
 {
     werewolfAudio.PlayAtPoint(transform.position);
 }
Esempio n. 8
0
 private void OnDamage(Damage dmg)
 {
     impactSound?.PlayAtPoint(transform.position);
     GameStateManager.inst.damageTaken += dmg.amount;
 }