예제 #1
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);
        }
    }
예제 #2
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);
        }
    }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        if (LPAPIParticleSystems.GetNumberOfParticles(sys.GetPtr()) <= 0)
        {
            return;
        }

        SetPositionToGroupCenteroid();
        MoveGroupToMousePosition();
    }
예제 #4
0
    private IEnumerator Melt()
    {
        yield return(new WaitForSeconds(waittime));

        if (mat != null)
        {
            LPAPIParticleGroups.SetParticleFlagsInGroup(sys.GetPtr(), group.GetPtr(), mat.GetInt());
        }
        else
        {
            LPAPIParticleGroups.SetParticleFlagsInGroup(sys.GetPtr(), group.GetPtr(), 0);
        }

        Debug.Log("flags set");
    }
예제 #5
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);
            }
        }
    }
예제 #6
0
 /// <summary>Create this particle group in the simulation with a shape pointer you already have
 /// Note: Used for concave fixtures or fixtures with more than 8 vertices
 /// They are broken up into several fixtures </summary>
 protected override void InitialiseWithShape(IntPtr shape)
 {
     SubPtrs.Add(LPAPIParticleGroups.CreateParticleGroup(sys.GetPtr(), getPartNum(), getGroupNum(), 0f, Strenght, AngularVelocity
                                                         , LinearVelocity.x, LinearVelocity.y
                                                         , shape
                                                         , (int)(_Color.r * 255f), (int)(_Color.g * 255f), (int)(_Color.b * 255f), (int)(_Color.a * 255f)
                                                         , Stride, LifeTime, UserData)
                 );
 }
예제 #7
0
    /// <summary>Create this particle group in the simulation</summary>
    public void Initialise(LPParticleSystem s)
    {
        sys = s;
        IntPtr shape = GetShape();

        ThingPtr = LPAPIParticleGroups.CreateParticleGroup(sys.GetPtr(), getPartNum(), getGroupNum(), 0f, Strenght, AngularVelocity
                                                           , LinearVelocity.x, LinearVelocity.y
                                                           , shape
                                                           , (int)(_Color.r * 255f), (int)(_Color.g * 255f), (int)(_Color.b * 255f), (int)(_Color.a * 255f)

                                                           , Stride, LifeTime, UserData);
        LPAPIUtility.ReleaseShape(shape);

        if (SubPtrs != null && ParticlesMaterial != null && (ParticlesMaterial.elastic || ParticlesMaterial.spring))
        {
            foreach (IntPtr groupptr in SubPtrs)
            {
                LPAPIParticleGroups.JoinParticleGroups(sys.GetPtr(), ThingPtr, groupptr);
            }
        }
    }
예제 #8
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());
        }
    }
예제 #9
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);
        }
    }
예제 #10
0
 void FixedUpdate()
 {
     LPAPIParticleSystems.DestroyParticlesInShape(sys.GetPtr(), Shape, transform.position.x, transform.position.y
                                                  , Mathf.Deg2Rad * transform.rotation.eulerAngles.z, false);
 }
예제 #11
0
    /// <summary>Create this particle group in the simulation</summary>	
    public void Initialise(LPParticleSystem s)
    {
        sys = s;
        IntPtr shape = GetShape();
        ThingPtr = LPAPIParticleGroups.CreateParticleGroup(sys.GetPtr(),getPartNum(),getGroupNum(),0f,Strenght,AngularVelocity
                                                           ,LinearVelocity.x,LinearVelocity.y
                                                           ,shape
                                                           ,(int)(_Color.r*255f),(int)(_Color.g*255f),(int)(_Color.b*255f),(int)(_Color.a*255f)

                                                                                                          ,Stride,LifeTime,UserData);
        LPAPIUtility.ReleaseShape(shape);

        if (SubPtrs !=null && ParticlesMaterial !=null && (ParticlesMaterial.elastic || ParticlesMaterial.spring))
        {
            foreach (IntPtr groupptr in SubPtrs)
            {
                LPAPIParticleGroups.JoinParticleGroups(sys.GetPtr(),ThingPtr,groupptr);
            }
        }
    }