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()
    {
        int oil   = 1;
        int water = 0;

        List <int> upindices   = new List <int>();
        List <int> downindices = new List <int>();

        foreach (LPSystemPartPartContact cont in sys.GetParticleContacts())
        {
            if (cont.ParticleAUserData == oil && cont.ParticleBUserData == water)
            {
                if (!upindices.Contains(cont.ParticleAIndex))
                {
                    upindices.Add(cont.ParticleAIndex);
                }
                if (!downindices.Contains(cont.ParticleBIndex))
                {
                    downindices.Add(cont.ParticleBIndex);
                }
            }
        }

        if (upindices.Count > 0)
        {
            upindices.Insert(0, upindices.Count);
            LPAPIParticles.ApplyForceToSelectedParticles(sys.GetPtr(), upindices.ToArray(), 0f, UpwardsForce);
        }
        if (downindices.Count > 0)
        {
            downindices.Insert(0, downindices.Count);
            LPAPIParticles.ApplyForceToSelectedParticles(sys.GetPtr(), downindices.ToArray(), 0f, -UpwardsForce * Mult);
        }
    }
Esempio n. 3
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. 4
0
    void FixedUpdate()
    {
        List <LPSystemPartPartContact> contactslist = sys.GetParticleContacts();
        List <int> indices = new List <int>();

        int acid  = 2;
        int stone = 1;

        foreach (var contact in contactslist)
        {
            if (contact.ParticleAUserData == acid && contact.ParticleBUserData == stone)
            {
                if (!indices.Contains(contact.ParticleBIndex))
                {
                    indices.Add(contact.ParticleBIndex);
                }
            }
        }

        if (indices.Count > 0)
        {
            indices.Insert(0, indices.Count);
            LPAPIParticles.SetSelectedParticleFlags(sys.GetPtr(), indices.ToArray(), sludge.GetInt());
            LPAPIParticles.SetSelectedParticleUserData(sys.GetPtr(), indices.ToArray(), 0);
        }
    }
Esempio n. 5
0
    void FixedUpdate()
    {
        if (Active)
        {
            int[] partsinshape = lpman.ParticleSystems[ParticleSystemImIn].GetParticlesInShape(shape, transform);


            if (partsinshape.Length > 1)
            {
                Vector3 diff = getdiff() * Strenght;

                LPAPIParticles.ApplyForceToSelectedParticles(lpman.ParticleSystems[ParticleSystemImIn].GetPtr(), partsinshape, diff.x, diff.y);
            }
        }
    }
Esempio n. 6
0
    // Update is called once per frame
    void FixedUpdate()
    {
        List <int> indices2 = new List <int>();

        if (sys.Particles != null)
        {
            for (int i = 0; i < sys.Particles.Length; i++)
            {
                if (sys.Particles[i].UserData == 0)
                {
                    indices2.Add(i);
                }
            }
        }
        if (indices2.Count > 0)
        {
            indices2.Insert(0, indices2.Count);
            LPAPIParticles.ApplyForceToSelectedParticles(sys.GetPtr(), indices2.ToArray(), 0f, -UpwardsForce * Mult);
        }
    }
Esempio n. 7
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. 8
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. 9
0
    void FixedUpdate()
    {
        List <LPSystemPartPartContact> contactslist = sys.GetParticleContacts();
        List <int> indices    = new List <int>();
        List <int> delindices = new List <int>();

        int water = 2;
        int lava  = 1;

        foreach (var contact in contactslist)
        {
            if (contact.ParticleAUserData == water && contact.ParticleBUserData == lava)
            {
                if (!indices.Contains(contact.ParticleBIndex))
                {
                    indices.Add(contact.ParticleBIndex);
                }
                if (!delindices.Contains(contact.ParticleAIndex))
                {
                    delindices.Add(contact.ParticleAIndex);
                }
            }
        }

        if (indices.Count > 0)
        {
            indices.Insert(0, indices.Count);
            LPAPIParticles.SetSelectedParticleFlags(sys.GetPtr(), indices.ToArray(), wall.GetInt());
            LPAPIParticles.SetSelectedParticleColor(sys.GetPtr(), indices.ToArray(), 100, 100, 100, 255);
            LPAPIParticles.SetSelectedParticleUserData(sys.GetPtr(), indices.ToArray(), 0);
        }

        if (indices.Count > 0)
        {
            delindices.Insert(0, delindices.Count);
            LPAPIParticles.SetSelectedParticleFlags(sys.GetPtr(), delindices.ToArray(), zombie.GetInt());
        }
    }
Esempio n. 10
0
    protected override void DoSpawn()
    {
        Vector3 diff = getdiff();

        if (!SpawnOnlyOneParticle)
        {
            pg.LinearVelocity = new Vector2(diff.x, diff.y);
            pg.Initialise(lpman.ParticleSystems[pg.ParticleSystemImIn]);


            if (JoinGroups)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    LPAPIParticleGroups.JoinParticleGroups(lpman.ParticleSystems[pg.ParticleSystemImIn].GetPtr()
                                                           , lastgroup, pg.GetPtr());
                }
                lastgroup = pg.GetPtr();
            }
        }
        else
        {
            int mat = 0;
            if (pg.ParticlesMaterial != null)
            {
                mat = pg.ParticlesMaterial.GetInt();
            }

            LPAPIParticles.CreateParticleInSystem(lpman.ParticleSystems[pg.ParticleSystemImIn].GetPtr()
                                                  , mat, transform.position.x, transform.position.y, diff.x, diff.y
                                                  , (int)(pg._Color.r * 255f), (int)(pg._Color.g * 255f), (int)(pg._Color.b * 255f), (int)(pg._Color.a * 255f)
                                                  , pg.LifeTime);
        }
    }
Esempio n. 11
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);
        }
    }
Esempio n. 12
0
    /// <summary>
    /// Returns an array of LPParticle objects with selected information about selected particles</summary>
    /// <param name="indices">An array of ints indicating the indices of the particles you want to get the details of.
    /// Note that the 1st member of the array must be the total number of indices in the array. ie. the lenght of thr array -1</param>
    public LPParticle[] GetSelectedPartDetails(int[] indices, bool position, bool color, bool age, bool weight, bool velocity, bool userdata)
    {
        LPParticle[] ParticleData = new LPParticle[indices[0]];

        IntPtr particlesPointer = LPAPIParticles.GetSelectedParticlesDetails(PartSysPtr, indices, position, color, age, weight, velocity, userdata);

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

        if (partsNum > 0)
        {
            int datanum = 0;

            if (position)
            {
                datanum += 2;
            }
            if (color)
            {
                datanum += 4;
            }
            if (age)
            {
                datanum += 1;
            }
            if (weight)
            {
                datanum += 1;
            }
            if (velocity)
            {
                datanum += 2;
            }
            if (userdata)
            {
                datanum += 1;
            }

            int     numberOfCoordinates = (partsNum * datanum) + 1;
            float[] pd = new float[numberOfCoordinates];
            Marshal.Copy(particlesPointer, pd, 0, numberOfCoordinates);

            for (int i = 0; i < partsNum; i++)
            {
                ParticleData[i] = new LPParticle();
            }

            int curpos = 1;

            if (position)
            {
                for (int i = 0; i < partsNum; i++)
                {
                    ParticleData[i].Position = new Vector3(pd[curpos + (i * 2)], pd[curpos + (i * 2) + 1]);
                }
                curpos += partsNum * 2;
            }

            if (color)
            {
                for (int i = 0; i < partsNum; i++)
                {
                    ParticleData[i]._Color = new Color(pd[curpos + (i * 4)] / 255f, pd[curpos + (i * 4) + 1] / 255f
                                                       , pd[curpos + (i * 4) + 2] / 255f, pd[curpos + (i * 4) + 3] / 255f);
                }
                curpos += partsNum * 4;
            }
            if (age)
            {
                for (int i = 0; i < partsNum; i++)
                {
                    ParticleData[i].LifeTime = pd[curpos + i];
                }
                curpos += partsNum;
            }
            if (weight)
            {
                for (int i = 0; i < partsNum; i++)
                {
                    ParticleData[i].Weight = pd[curpos + i];
                }
                curpos += partsNum;
            }
            if (velocity)
            {
                for (int i = 0; i < partsNum; i++)
                {
                    ParticleData[i].Velocity = new Vector3(pd[curpos + (i * 2)], pd[curpos + (i * 2) + 1]);
                }
                curpos += partsNum * 2;
            }
            if (userdata)
            {
                for (int i = 0; i < partsNum; i++)
                {
                    ParticleData[i].UserData = (int)pd[curpos + i];
                }
            }
        }

        return(ParticleData);
    }