Example #1
0
    // Direct hit
    public void DirectHit(float missileHitDamage, Vector3 hitPosition)
    {
        GameObject explosionItem = explosionManager.GetItem();

        explosionItem.transform.position = hitPosition;
        explosionItem.SetActive(true);
        explosionItem.GetComponent <ParticleSystem>().Play();
        explosionManager.RecycleItemAfterSecs(explosionItem, 3.0f);

        SoundManager.Instance.PlaySound(SndId.SND_EXPLOSION_OBSTACLE);

        prop.health = Mathf.Clamp(prop.health - missileHitDamage, 0.0f, float.MaxValue);

        if (prop.health == 0.0f)
        {
            GameObject flameItem = flameManager.GetItem();
            flameItem.transform.position = new Vector3(transform.position.x, 1.7f, transform.position.z);
            flameItem.SetActive(true);
            flameItem.GetComponent <ParticleSystem>().Play();
            flameManager.RecycleItemAfterSecs(flameItem, 3.0f);

            // Destroy the object in 3 seconds
            destroyTimer = 3.0f;
        }
    }
Example #2
0
    // Unity Update Method
    void Update()
    {
        hull.Update();
        turret.Update();

        if (destroyTimer > 0.0f)
        {
            destroyTimer -= Time.deltaTime;

            if (destroyTimer <= 0.0f)
            {
                GameObject detonationItem = detonationManager.GetItem();
                detonationItem.transform.position = new Vector3(transform.position.x, 1.7f, transform.position.z);
                detonationItem.SetActive(true);
                detonationManager.RecycleItemAfterSecs(detonationItem, 3.0f);

                UnityEngine.Object.Destroy(this.gameObject);
            }
        }
    }