예제 #1
0
    IEnumerator InstantlyDestroy()
    {
        if (Type == ObjectType.MISSILE)
        {
            body.simulated = false;
        }
        else
        {
            var sprite = hpGauge.GetComponent<SpriteRenderer>();
            sprite.color = new Color(0, 1.0f, 0, sprite.color.a);
            hpGauge.localScale = Vector3.one;
            hpBar.SetActive(false);

            yield return new WaitForEndOfFrame();

            if (Owner == PlayerStatus.PlayerType.PLAYER)
                GameManager.instance.playerObjList.Remove(gameObject);
            else
                GameManager.instance.enemyObjList.Remove(gameObject);
        }
        if (Type == ObjectType.CASTLE)
        {
            gameObject.SetActive(false);
        }
        Owner = PlayerStatus.PlayerType.NONE;
        ObjectManager.instance.Free(gameObject);
    }
예제 #2
0
    //-----------------------------------------------------------------------------------
    // coroutine functions
    IEnumerator Destroy()
    {
        if (Type == ObjectType.MISSILE)
        {
            body.simulated = false;
        }
        else
        {
            var sprite = hpGauge.GetComponent<SpriteRenderer>();
            sprite.color = new Color(0, 1.0f, 0, sprite.color.a);
            hpGauge.localScale = Vector3.one;
            hpBar.SetActive(false);

            yield return new WaitForEndOfFrame();

            if (Owner == PlayerStatus.PlayerType.PLAYER)
                GameManager.instance.playerObjList.Remove(gameObject);
            else
                GameManager.instance.enemyObjList.Remove(gameObject);
        }
        yield return new WaitForSeconds(DeathTime);

        float time = 0.5f;
        while (time > 0)
        {
            time -= Time.deltaTime;
            if (Type == ObjectType.BARRIER)
            {
                var color = mash.material.GetColor("_TintColor");
                mash.material.SetColor("_TintColor", new Color(color.r, color.g, color.b, time * 2));
            }
            else
            {
                for (int i = 0; i < sprites.Count; ++i)
                {
                    var color = sprites[i].color;
                    sprites[i].color = new Color(color.r, color.g, color.b, time * 2);
                }
            }
            yield return new WaitForEndOfFrame();
        }

        if (Type == ObjectType.CASTLE)
        {
            gameObject.SetActive(false);
        }
        Owner = PlayerStatus.PlayerType.NONE;
        ObjectManager.instance.Free(gameObject);
    }