示例#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);
    }
示例#2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Virus"))
        {
            if (VirusPlayerDataAdapter.GetShootCoin())
            {
                EventManager.TriggerEvent(new UIVirusAddLevelCoinEvent(transform.position));
                VirusGameDataAdapter.AddLevelCoin(1);
            }

            var baseVirus = collision.transform.GetComponent <BaseVirus>();
            if (!baseVirus.IsDeath)
            {
                baseVirus.Injured(_damageValue, true);
            }
            var obj = EffectPools.Instance.Spawn("HitEffect");
            obj.transform.position   = transform.position;
            obj.transform.localScale = Vector3.one * 1.5f;
            BulletPools.Instance.DeSpawn(gameObject);
        }
    }