Ejemplo n.º 1
0
    void Fire()
    {
        Vector3    offsetPosition = new Vector3(0, _laserOffset, 0);
        bool       tsActive       = _powerUpStatus.tripleShot > 0;
        bool       rsActive       = _powerUpStatus.rotateShot > 0;
        bool       hsActive       = _powerUpStatus.homingShot > 0;
        bool       gsActive       = _powerUpStatus.glitchShot > 0;
        GameObject nmPfb          = armory.normalPrefab;
        GameObject tsPfb          = armory.tripleShotPrefab;
        GameObject rsPfb          = armory.rotateShotPrefab;
        GameObject hsPfb          = armory.homingShotPrefab;
        GameObject gsPfb          = armory.glitchShotPrefab;
        float      fireRate       = _fireRate.normal;
        float      tripleFR       = _fireRate.triple;
        float      rotateFR       = _fireRate.rotate;
        float      homingFR       = _fireRate.homing;
        float      glitchFR       = _fireRate.glitch;

        GameObject readyShot        = gsActive ? gsPfb : hsActive ? hsPfb : (rsActive ? rsPfb : (tsActive ? tsPfb : nmPfb));
        GameObject laser            = _boundManager.bsInstantiate(readyShot, transform.position, (rsActive && !hsActive) ? rotateAim.transform.rotation : Quaternion.identity);
        float      modifierFireRate = gsActive ? glitchFR : (hsActive ? homingFR : (rsActive ? rotateFR : (tsActive ? tripleFR : 0f)));

        if (laser && hsActive || gsActive)
        {
            chooseTarget(laser);
        }

        _audioPlayer.clip = laserFire;
        _audioPlayer.Play();
        _fireRate.cooldown = Time.time + fireRate + modifierFireRate;
    }
Ejemplo n.º 2
0
    IEnumerator fireRoutine()
    {
        while (!_destroyed && !_helpMenu)
        {
            float minTime   = Mathf.Max(0, Mathf.Min(fireTimeRange[0], fireTimeRange[1]));
            float maxTime   = Mathf.Max(1, Mathf.Max(fireTimeRange[0], fireTimeRange[1]));
            float spawnTime = Random.Range(minTime, maxTime);
            yield return(new WaitForSeconds(spawnTime));

            bool isPaused = _pausible && _pausible.isPaused();
            if (!_destroyed && !isPaused && _activated)
            {
                GameObject laser = _projectile.Get();
                chooseTarget(laser);
                bool    isRotateShot       = armory.rotateShotPrefab.name == laser.name;
                bool    isPortal           = armory.glitchShotPrefab.name == laser.name;
                Vector3 lastPlayerPosition = player != null ? player.position : transform.position;
                bool    isPlayerBehind     = (transform.position - lastPlayerPosition).y < 0;
                //Vector3 debugPositioning = transform.position - lastPlayerPosition;
                //Debug.Log(debugPositioning);
                int flipModifier = ((isPlayerBehind && enemyType == type.White) ? 1 : 0);
                //Quaternion stdRotation = Quaternion.Euler(flipModifier * 180 * Vector3.forward);
                Vector3 eulerRot = transform.rotation.eulerAngles;
                eulerRot.z += flipModifier * 180;
                Quaternion stdRotation        = Quaternion.Euler(eulerRot);
                Quaternion projectileRotation = (isRotateShot) ? _rotateAim.rotation : stdRotation;
                if (isPortal)
                {
                    if (_portalContainer.transform.childCount > _portalLimit)
                    {
                        continue;
                    }
                }
                GameObject firedProjectile = _boundManager.bsInstantiate(laser, transform.position, projectileRotation);
                if (isPortal && firedProjectile)
                {
                    Vector3 eangles = firedProjectile.transform.eulerAngles;
                    firedProjectile.transform.Translate(Vector3.down * _portalOffset);
                    firedProjectile.transform.eulerAngles = new Vector3(eangles.x, eangles.y, eangles.z + 90);
                    firedProjectile.transform.parent      = _portalContainer.transform;
                }
                _audioPlayer.Play();
            }
        }
    }
Ejemplo n.º 3
0
    public void classicStory(Enemy.type type)
    {
        Dictionary <Enemy.type, int> killed = _enemyTriggers.killed;

        Spawnable[] items = _spawnManager.getItems();
        if (killed[type] == 1 && type != Enemy.type.Normal)
        {
            items[enemySpawnableIndex].setActive(true);
        }
        if (killed[type] == _killTriggers[type])
        {
            //Generally, the stage will be change to a specific number for a killed type
            //However, enemy types are spawned sequentially, so it shouldn't be possible to hit gates out of order
            _stage++;
            switch (_stage)
            {
            case 1:
                break;

            case 2:
                items[enemySpawnableIndex].setActive(false);
                _spawnManager.specialSpawn(hyperEnemy, _enemyContainer);
                break;

            case 3:
                items[enemySpawnableIndex].setActive(false);
                _spawnManager.specialSpawn(ultraEnemy, _enemyContainer);
                break;

            case 4:
                // Boss is spawned directly because special spawn doesn't take position coordinates
                items[enemySpawnableIndex].setActive(false);
                GameObject tohou = _boundManager.bsInstantiate(tohouEnemy, new Vector3(0, 4), Quaternion.identity);

                SpawnManager.setPausible(tohou, managers);
                tohou.GetComponent <Enemy>().managers = managers;
                tohou.GetComponent <Enemy>().player   = _playerPosition;
                tohou.transform.parent = _enemyContainer;
                tohou.GetComponent <Enemy>().setPortalContainer(_portalContainer);
                tohou.GetComponent <Enemy>().setPowerupContainer(_powerupContainer.gameObject);
                break;

            case 5:
                items[enemySpawnableIndex].setActive(false);
                break;
            }
        }
        if (_gameManager.getMode() == GameManager.mode.endless)
        {
            // In endless mode, enemies spawn with subbosses/bosses
            items[enemySpawnableIndex].setActive(true);
        }
    }