Beispiel #1
0
    public virtual void Death(bool isEffect, bool isDivide, bool isCoin, bool isProp)
    {
        IsDeath = true;
        int level = VirusGameDataAdapter.GetLevel();
        int coin  = VirusTool.GetVirusDeathCoin(level);

        if (isEffect)
        {
            float scale     = transform.localScale.x;
            int   index     = Random.Range(1, 5);
            var   explosion = EffectPools.Instance.Spawn("Explosion" + index);
            explosion.transform.localScale = new Vector3(scale * 2f, scale * 2f, 1);
            explosion.transform.position   = transform.position;
            explosion.GetComponent <VirusFragmentMrg>().Initi(index - 1, Random.Range(5, 10));
            VirusSoundMrg.Instance.PlaySound(VirusSoundType.VirusDeath);
            VirusCameraShake.Instance.Shake();
        }

        if (isCoin)
        {
            if (coin > 0)
            {
                VirusGameDataAdapter.AddLevelCoin(coin);
                int count = Random.Range(1, 4);
                for (int i = 0; i < count; i++)
                {
                    EventManager.TriggerEvent(new UIVirusAddLevelCoinEvent(transform.position));
                }
            }
        }

        if (isProp)
        {
            string propName = VirusTool.GetPropName(level);
            if (!propName.Equals("None") && SplitLevel > SplitLevel.Level1)
            {
                var prop = PropPools.Instance.Spawn(propName + "Prop");
                prop.transform.position = transform.position;
                prop.GetComponent <VirusPropMove>().Initi();
                ScenePropMrg.Instance.Add(prop);
            }
        }
        VirusMrg.Instance.Remove(gameObject);
    }