IEnumerator SpawnParticle(GameObject enemy, Vector3 SP)
    {
        //spawn particle
        //float delay = enemy.GetComponent<EnemyAI>().spawnParticleDelay;
        ParticleSystem temp = new ParticleSystem();

        if (enemy.tag != "Untagged")
        {
            particleControl p = enemy.GetComponent <EnemyAI>().spawnParticle;
            if (p != null)
            {
                if (!p.gameObject.activeInHierarchy)
                {
                    p.gameObject.SetActive(true);
                }
                Instantiate(p, SP, Quaternion.identity);
            }
            else
            {
                temp = Instantiate(defalseSpawnParticle.particle, SP, Quaternion.identity);
            }
        }
        //yield return new WaitForSeconds((delay == 0 ? defaultDelay : delay));
        yield return(new WaitForSeconds(defaultDelay));

        //spawn monster
        enemy.gameObject.SetActive(true);
        if (temp != null)
        {
            Destroy(temp.gameObject);
        }
    }
Пример #2
0
    public void showParticleEffect(particleControl DamParticle)
    {
        if (DamParticle == null)
        {
            return;
        }
        particleControl newParticle = Instantiate(DamParticle);

        newParticle.transform.SetParent(transform);
        newParticle.setParticle(transform);
    }
    void Start()
    {
        enemySpawnSystem = EnemySpawnSystem.Instance;
        if (enemySpawnSystem == null)
        {
            throw new System.Exception("no enemySpawnSystem in scene");
        }

        col = GetComponent <Collider>();
        if (col != null)
        {
            col.isTrigger = true;
        }
        defalseSpawnParticle = enemySpawnSystem.defalseSpawnParticle;
        defalseSpawnParticle.gameObject.SetActive(true);
    }