Exemple #1
0
    private void BlowUp()
    {
        CheckForResourceDrop(true);

        if (explosionPrefab != null)
        {
            GameObject obj = Instantiate(explosionPrefab, transform.position, Quaternion.identity);
            if (explosionSFXOverride != null)
            {
                obj.GetComponent <AudioSource>().clip   = explosionSFXOverride;
                obj.GetComponent <AudioSource>().volume = explosionVolume;
                obj.GetComponent <AudioSource>().Play();
            }
        }

        //List<GameObject> spawnedAsteroids = new List<GameObject>();
        foreach (var childAsteroidPrefab in childAsteroidPrefabs)
        {
            Vector2    spawnPos = transform.position + new Vector3(Random.Range(-0.05f, 0.05f), Random.Range(-0.05f, 0.05f), 0f);
            GameObject gObj     = Instantiate(childAsteroidPrefab, spawnPos, Quaternion.Euler(0, 0, Random.Range(-45, 45)));
            if (shrapnelForce > 0f)
            {
                Vector3 dir = (gObj.transform.position - transform.position).normalized;
                gObj.GetComponent <Rigidbody2D>().AddForce(dir * shrapnelForce);

                //gObj.GetComponent<MovementBehaviour>().direction = dir;
            }
        }

        BlownUpEvent.Invoke(gameObject);

        ScoreManager.scoreManager.AsteroidDestroyed(scoreValue);
        Remove();
    }
Exemple #2
0
 protected void OnTriggerExit(Collider other)
 {
     if (OnTriggerEnterExit != null)
     {
         OnTriggerEnterExit.Invoke(other.gameObject);
     }
 }
Exemple #3
0
 private void OnParticleCollision(GameObject other)
 {
     if (other == target.gameObject)
     {
         onTargetCollision.Invoke(other);
     }
 }
 public void DestroyEnemy()
 {
     particlesPool.Spawn(explosionParticles, transform.position, Quaternion.identity);
     wavesManager.EnemyDestroyed();
     onDestroy?.Invoke(gameObject);
     gameObject.SetActive(false);
 }
    public void BlowUp(bool canDropResource = true)
    {
        //ScoreManager.scoreManager.EnemyDestroyed(scoreValue);
        BlownUpEvent.Invoke(gameObject);

        if (explosionPrefab != null)
        {
            Instantiate(explosionPrefab, transform.position, Quaternion.identity);
        }

        CheckForResourceDrop(true);

        Remove();
    }
    private void OnEnemyDestroyedOrRemoved(GameObject enemy)
    {
        _enemySpawns.Remove(enemy);

        Enemy    eComp = enemy.GetComponent <Enemy>();
        Asteroid aComp = enemy.GetComponent <Asteroid>();

        if (eComp)
        {
            eComp.EnemyDestroyedOrRemovedEvent.RemoveListener(OnEnemyDestroyedOrRemoved);
        }
        else if (aComp)
        {
            aComp.EnemyDestroyedOrRemovedEvent.RemoveListener(OnEnemyDestroyedOrRemoved);
        }

        //Debug.Log("Removed! Num Spawns = " + _enemySpawns.Count);
        EnemyDestroyedOrRemovedEvent.Invoke(enemy);
    }
    public void TakeHit(GameObject damager) //int damage, InteriorProblemOdds problemOdds = null)
    {
        int damage = 1;                     // min damage

        DamageDealer damageDealer = damager.GetComponent <DamageDealer>();

        if (damageDealer)
        {
            damage = damageDealer.GetDamage();
        }

        if (!invincible && barrelRollTimer <= 0f)
        {
            if (shields > 0 && ShieldsEnabled)
            {
                shields = Mathf.Max(shields - 1, 0); // could change to damage, if wanted that. But currently just negates a hit
                UpdateShieldsSprite();
            }
            else
            {
                currentHitPoints = Mathf.Max(currentHitPoints - damage, 0);
                UpdateDamageSprite();

                if (currentHitPoints <= 0)
                {
                    if (explosionPrefab != null)
                    {
                        Instantiate(explosionPrefab, transform.position, Quaternion.identity);
                    }
                    exteriorManager.HandleShipDestroyed(this); // TODO: extend into an event so ExteriorShip can be independent.
                    Destroy(gameObject);
                }
            }
        }

        shipHitEvent.Invoke(damager);
        //interiorManager.HandleShipDamage(problemOdds); // TODO: extend into an event so ExteriorShip can be independent.
    }
Exemple #8
0
 public void RaiseEvent()
 {
     broadcastGameObjectEvent.Invoke(gameObject);
 }
Exemple #9
0
 /// <summary>
 /// Called when this event was fired
 /// </summary>
 public void OnEventFired(GameObject go)
 {
     UnityEventHandler.Invoke(go);
 }
Exemple #10
0
 public void Remove()
 {
     EnemyDestroyedOrRemovedEvent.Invoke(gameObject);
     Destroy(gameObject);
 }
 private void OnEnemyBlownUp(GameObject enemy)
 {
     EnemyBlownUpEvent.Invoke(enemy);
 }
 public void Remove()
 {
     EnemyDestroyedOrRemovedEvent.Invoke(gameObject);
     EnemyDestroyedOrRemovedEvent.RemoveAllListeners();
     Destroy(gameObject);
 }
Exemple #13
0
 public void OnEventOccurs(GameObject go)
 {
     response.Invoke(go);
 }
Exemple #14
0
 public void OnEventOcurred(GameObject gameObject)
 {
     response.Invoke(gameObject);
 }
Exemple #15
0
 public void OnEventRaised(GameObject go)
 {
     Response.Invoke(go);
 }
Exemple #16
0
 private void OnTriggerExit2D(Collider2D collision)
 {
     _notify?.Invoke(collision.gameObject);
 }
 private void OnMouseDown()
 {
     _notify?.Invoke(gameObject);
 }
Exemple #18
0
 public void OnEvenOccurs(GameObject gameObject)
 {
     response.Invoke(gameObject);
 }
Exemple #19
0
 public void HandleDestroyedOrRemoved()
 {
     ProblemDestroyedOrRemovedEvent.Invoke(gameObject);
 }