Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        ammoExhaustedSoFar = 1;
        _ammoSpawnerState  = AmmoSpawnerState.NotReadyForSpawn;

        GameObject tempProjectileObject = GameObject.Instantiate(ammoPrefab, this.gameObject.transform.position, this.gameObject.transform.rotation);

        tempProjectileObject.name = "Projectile_" + ammoExhaustedSoFar;
        //arrayOfProjectileNamesExhaustedSoFar.Add(tempProjectileObject.name);
    }
Exemplo n.º 2
0
    private void OnTriggerExit2D(Collider2D collision)
    {
        if ((collision.gameObject.tag.Equals("Projectile")) &&
            (collision.gameObject.layer == 13) &&
            (arrayOfProjectileNamesExhaustedSoFar.Contains(collision.gameObject.name) == false))
        {
            collision.gameObject.layer = 12; //Layer no. 12 is "Interactible". This has been done so that as soon as it has been fired, it should be affected by other activities such as explosions etc.
            this.ammoFiredEvent.Invoke();
            _ammoSpawnerState = AmmoSpawnerState.ReadyForNextSpawn;
        }

        if ((collision.gameObject.tag.Equals("Projectile")) &&
            (collision.gameObject.layer == 13))
        {
            arrayOfProjectileNamesExhaustedSoFar.Add(collision.gameObject.name);
        }
    }
Exemplo n.º 3
0
    public void createNewAmmo()
    {
        if ((ammoExhaustedSoFar < maxAmmo) && (_ammoSpawnerState == AmmoSpawnerState.ReadyForNextSpawn))
        {
            //First, release all the rockets
            if (this.numberOfRockets > 0)
            {
                GameObject tempProjectileObject = GameObject.Instantiate(rocketPrefab, this.gameObject.transform.position, this.gameObject.transform.rotation);
                ammoExhaustedSoFar       += 1;
                numberOfRockets          -= 1;
                tempProjectileObject.name = "Projectile_" + ammoExhaustedSoFar;

                _ammoSpawnerState = AmmoSpawnerState.NotReadyForSpawn;
            }
            else
            {
                GameObject tempProjectileObject = GameObject.Instantiate(ammoPrefab, this.gameObject.transform.position, this.gameObject.transform.rotation);
                ammoExhaustedSoFar       += 1;
                tempProjectileObject.name = "Projectile_" + ammoExhaustedSoFar;

                _ammoSpawnerState = AmmoSpawnerState.NotReadyForSpawn;
            }
        }
    }