Esempio n. 1
0
    private void oneshot()
    {
        LPRayCastHit[] hits = caster.RaycastWorld();
        if (hits.Length > 0)
        {
            hits = hits.OrderBy(d => d.Fraction).ToArray();



            IntPtr partsysptr       = lpman.ParticleSystems[ParticleSystemImIn].GetPtr();
            IntPtr particlesPointer = LPAPIParticleSystems.GetParticlesInShape(partsysptr
                                                                               , shape, hits[0].Position.x, hits[0].Position.y
                                                                               , transform.rotation.eulerAngles.z);

            int[] particlesArray = new int[1];
            Marshal.Copy(particlesPointer, particlesArray, 0, 1);
            int foundNum = particlesArray[0];


            if (foundNum > 0)
            {
                int[] Indices = new int[foundNum + 1];
                Marshal.Copy(particlesPointer, Indices, 0, foundNum + 1);

                LPAPIParticles.SetSelectedParticleFlags(partsysptr, Indices, DebrisMaterial.GetInt());
                LPAPIParticles.SetSelectedParticleUserData(partsysptr, Indices, 2);
                LPAPIParticles.ExplodeSelectedParticles(partsysptr, Indices, hits[0].Position.x, hits[0].Position.y, ExplosionStrenght);
            }
        }
    }
Esempio n. 2
0
    void FixedUpdate()
    {
        List <LPSystemFixPartContact> conts = partsys.GetBodyContacts();

        if (conts.Count > 0)
        {
            Debug.Log(" particle index " + conts[0].ParticleIndex
                      + " particle userdata " + conts[0].ParticleUserData
                      + " body " + conts[0].BodyIndex
                      + " fix " + conts[0].FixtureIndex
                      + " weight " + conts[0].Weight
                      + " normalx " + conts[0].Normal.x
                      + " normaly " + conts[0].Normal.y
                      );

            List <int> todo = new List <int>();

            foreach (LPSystemFixPartContact cont in conts)
            {
                if (cont.BodyIndex == bod.myIndex && !todo.Contains(cont.ParticleIndex))
                {
                    todo.Add(cont.ParticleIndex);
                }
            }

            if (todo.Count > 0)
            {
                todo.Insert(0, todo.Count);
                LPAPIParticles.ExplodeSelectedParticles(partsys.GetPtr(), todo.ToArray(), transform.position.x, transform.position.y, 600f);
            }
        }
    }
Esempio n. 3
0
    private void oneshot2(Vector3 pos)
    {
        IntPtr partsysptr       = lpman.ParticleSystems[ParticleSystemImIn].GetPtr();
        IntPtr particlesPointer = LPAPIParticleSystems.GetParticlesInShape(partsysptr
                                                                           , shape, pos.x, pos.y
                                                                           , transform.rotation.eulerAngles.z);

        int[] particlesArray = new int[1];
        Marshal.Copy(particlesPointer, particlesArray, 0, 1);
        int foundNum = particlesArray[0];


        if (foundNum > 0)
        {
            int[] Indices = new int[foundNum + 1];
            Marshal.Copy(particlesPointer, Indices, 0, foundNum + 1);

            LPAPIParticles.SetSelectedParticleFlags(partsysptr, Indices, DebrisMaterial.GetInt());
            LPAPIParticles.SetSelectedParticleUserData(partsysptr, Indices, 2);
            LPAPIParticles.ExplodeSelectedParticles(partsysptr, Indices, pos.x, pos.y, ExplosionStrenght);
        }
    }
Esempio n. 4
0
    public void Splode()
    {
        IntPtr partsysptr       = lpman.ParticleSystems[ParticleSystemImIn].GetPtr();
        IntPtr particlesPointer = LPAPIParticleSystems.GetParticlesInShape(partsysptr
                                                                           , shape, transform.position.x, transform.position.y
                                                                           , transform.rotation.eulerAngles.z);

        int[] particlesArray = new int[1];
        Marshal.Copy(particlesPointer, particlesArray, 0, 1);
        int foundNum = particlesArray[0];


        if (foundNum > 0)
        {
            int[] Indices = new int[foundNum + 1];
            Marshal.Copy(particlesPointer, Indices, 0, foundNum + 1);

            LPAPIParticles.ExplodeSelectedParticles(partsysptr, Indices, transform.position.x, transform.position.y, ExplosionStrenght);
        }
        GetComponent <LPBody>().Delete();
        Destroy(gameObject);
    }
Esempio n. 5
0
    void Splode(Vector3 splodepos)
    {
        Vector3 pos = Camera.main.ScreenToWorldPoint(splodepos);

        IntPtr partsysptr       = lpman.ParticleSystems[ParticleSystemImIn].GetPtr();
        IntPtr worldPtr         = lpman.GetPtr();
        IntPtr particlesPointer = LPAPIParticleSystems.GetParticlesInShape(worldPtr, partsysptr
                                                                           , shape, pos.x, pos.y
                                                                           , 0f);

        int[] particlesArray = new int[1];
        Marshal.Copy(particlesPointer, particlesArray, 0, 1);
        int foundNum = particlesArray[0];


        if (foundNum > 0)
        {
            int[] Indices = new int[foundNum + 1];
            Marshal.Copy(particlesPointer, Indices, 0, foundNum + 1);

            LPAPIParticles.ExplodeSelectedParticles(partsysptr, Indices, pos.x, pos.y, ExplosionStrenght);
        }
    }