Exemplo n.º 1
0
 public GameObject Spawn(GameObject obj, Vector3 pos, Quaternion q, Vector3 add_vel, Transform parent = null, float attach_duration = -1f, bool keep_y = false)
 {
     obj.transform.SetParent(parent, false);
     obj.transform.position = pos;
     obj.transform.rotation = q;
     ParticleSystem[] componentsInChildren = obj.GetComponentsInChildren <ParticleSystem>();
     if (add_vel.magnitude > 0f)
     {
         for (int i = 0; i < componentsInChildren.Length; i++)
         {
             int particleCount = componentsInChildren[i].particleCount;
             ParticleSystem.Particle[] array = new ParticleSystem.Particle[particleCount];
             componentsInChildren[i].GetParticles(array);
             for (int j = 0; j < particleCount; j++)
             {
                 ParticleSystem.Particle[] array2 = array;
                 int num = j;
                 array2[num].velocity = array2[num].velocity + add_vel;
             }
             componentsInChildren[i].SetParticles(array, particleCount);
         }
     }
     ParticlesManager.ParticlesData particlesData = new ParticlesManager.ParticlesData();
     particlesData.m_ParticleSystem = componentsInChildren;
     particlesData.m_AttachDuration = attach_duration;
     particlesData.m_AttachTime     = Time.time;
     particlesData.m_KeepY          = keep_y;
     particlesData.m_Y        = pos.y;
     particlesData.m_LocalPos = obj.transform.localPosition;
     particlesData.m_LocalRot = obj.transform.localRotation;
     this.m_PartcleSystems.Add(obj, particlesData);
     return(obj);
 }
Exemplo n.º 2
0
    public GameObject Spawn(string name, Vector3 pos, Quaternion q, Vector3 add_vel, Transform parent = null, float attach_duration = -1f, bool keep_y = false)
    {
        GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(GreenHellGame.Instance.GetPrefab(name), Vector3.zero, Quaternion.identity);

        gameObject.transform.SetParent(parent, false);
        gameObject.transform.position = pos;
        gameObject.transform.rotation = q;
        ParticleSystem[] componentsInChildren = gameObject.GetComponentsInChildren <ParticleSystem>();
        if (add_vel.magnitude > 0f)
        {
            for (int i = 0; i < componentsInChildren.Length; i++)
            {
                int particleCount = componentsInChildren[i].particleCount;
                ParticleSystem.Particle[] array = new ParticleSystem.Particle[particleCount];
                componentsInChildren[i].GetParticles(array);
                for (int j = 0; j < particleCount; j++)
                {
                    ParticleSystem.Particle[] array2 = array;
                    int num = j;
                    array2[num].velocity = array2[num].velocity + add_vel;
                }
                componentsInChildren[i].SetParticles(array, particleCount);
            }
        }
        ParticlesManager.ParticlesData particlesData = new ParticlesManager.ParticlesData();
        particlesData.m_ParticleSystem = componentsInChildren;
        particlesData.m_AttachDuration = attach_duration;
        particlesData.m_AttachTime     = Time.time;
        particlesData.m_KeepY          = keep_y;
        particlesData.m_Y        = pos.y;
        particlesData.m_LocalPos = gameObject.transform.localPosition;
        particlesData.m_LocalRot = gameObject.transform.localRotation;
        this.m_PartcleSystems.Add(gameObject, particlesData);
        return(gameObject);
    }