Beispiel #1
0
    void OnParticleCollision(GameObject other)
    {
        ParticlePhysicsExtensions.GetCollisionEvents(ps, other, collision_events);

        /*
         * if (spawn_sprites) {
         *      for (int i = 0; i < collision_events.Count; i++) {
         *              GameObject obj = Instantiate (blood, collision_events [i].intersection, Quaternion.Euler (new Vector3 (Random.Range (0, 360), Random.Range (0, 360), 0)));
         *              obj.transform.localScale = new Vector3 (Random.Range (0.1f, 0.2f), Random.Range (0.1f, 0.2f), 1);
         *              obj.transform.SetParent (sprite_parent.transform);
         *              spawned_sprites++;
         *              if (spawned_sprites >= max_sprites) {
         *                      spawn_sprites = false;
         *              }
         *      }
         * }*/
        if (spawn_sprites)
        {
            GameObject obj = Instantiate(blood, collision_events [0].intersection, Quaternion.Euler(new Vector3(0, 0, Random.Range(0, 360))));
            obj.transform.localScale = new Vector3(Random.Range(0.1f, 0.2f), Random.Range(0.1f, 0.2f), 1);
            obj.transform.SetParent(sprite_parent.transform);
            spawned_sprites++;
            aus.PlayOneShot(aus.clip);
            if (spawned_sprites >= max_sprites)
            {
                spawn_sprites = false;
            }
        }
    }
Beispiel #2
0
    // On particle collision
    void OnParticleCollision(GameObject other)
    {
        int safeLength = ParticlePhysicsExtensions.GetSafeCollisionEventSize(ps);

        if (collisionEvents.Length < safeLength)
        {
            collisionEvents = new ParticleCollisionEvent[safeLength];
        }

        int numCollisionEvents = ParticlePhysicsExtensions.GetCollisionEvents(ps, other, collisionEvents);

        // Play collision sound and apply force to the rigidbody was hit
        int i = 0;

        while (i < numCollisionEvents)
        {
            //F3DAudioController.instance.ShotGunHit(collisionEvents[i].intersection);

            Rigidbody rb = other.GetComponent <Rigidbody>();
            if (rb)
            {
                Vector3 pos   = collisionEvents[i].intersection;
                Vector3 force = collisionEvents[i].velocity.normalized * 50f;

                rb.AddForceAtPosition(force, pos);

                DamageHelper.MakeDamage(other, DamageType.Kinetik, DamageValues.ShotGun);

                other.SendMessage("Shatter", pos, SendMessageOptions.DontRequireReceiver);
            }

            i++;
        }
    }
Beispiel #3
0
    void OnParticleTrigger()
    {
        int enterCount = ParticlePhysicsExtensions.GetTriggerParticles(ps, ParticleSystemTriggerEventType.Enter, enter);
        int exitCount  = ParticlePhysicsExtensions.GetTriggerParticles(ps, ParticleSystemTriggerEventType.Exit, exit);

        Debug.Log("Trigger,Enter:" + enterCount + ",Exit:" + exitCount);
        Debug.Log("EnterList:" + enter.Count + ",ExitList:" + exit.Count);

        for (int i = 0; i < enter.Count; i++)
        {
            ParticleSystem.Particle p = enter[i];
            p.startColor = Color.green;
            enter[i]     = p;
        }

        for (int i = 0; i < exit.Count; i++)
        {
            ParticleSystem.Particle p = exit[i];
            p.startColor = Color.red;
            exit[i]      = p;
        }

        ParticlePhysicsExtensions.SetTriggerParticles(ps, ParticleSystemTriggerEventType.Enter, enter);
        ParticlePhysicsExtensions.SetTriggerParticles(ps, ParticleSystemTriggerEventType.Exit, exit);
    }
    private void OnParticleCollision(GameObject other)
    {
        ParticlePhysicsExtensions.GetCollisionEvents(launcher, other, collisionEvents);

        for (int i = 0; i < collisionEvents.Count; i++)
        {
            if (other.transform.tag == "Bacteria")
            {
                Debug.Log("bacteria hit");

                if (other.GetComponent <EnemyHealth>())
                {
                    other.GetComponent <EnemyHealth>().GotHit();
                }
            }


            if (other.transform.tag == "Bacteria Sausage")
            {
                isBacteriaBoss = true;
                GameObject hitTarget = other.transform.gameObject;
                hitTarget.transform.parent.GetComponent <EnemyHealthSausageBacteria>().GotHit();
            }


            if (other.transform.tag == "Bacteria Bighead")
            {
                isBacteriaBoss = true;
                GameObject hitTarget = other.transform.gameObject;
                hitTarget.GetComponent <EnemyHealthSausageBacteria>().GotHit();
            }
        }
    }
    void OnParticleCollision(GameObject other)
    {
        print("You hit: " + other.name);

        if (other.name == "LeftTarget")
        {
            ProcessStartInfo PSI = new ProcessStartInfo("Assets\\BCI2000\\prog\\BCI2000Shell.exe");
            PSI.Arguments = "-c SET STATE ResultCode 1";
            Process.Start(PSI);
            if (tar == 1)
            {
                Target [1].SetActive(true);
            }
        }
        else if (other.name == "RightTarget")
        {
            ProcessStartInfo PSI = new ProcessStartInfo("Assets\\BCI2000\\prog\\BCI2000Shell.exe");
            PSI.Arguments = "-c SET STATE ResultCode 2";
            Process.Start(PSI);
        }


        ParticlePhysicsExtensions.GetCollisionEvents(particleLauncher, other, collisionEvents);

        for (int i = 0; i < collisionEvents.Count; i++)
        {
            splatDecalPool.ParticleHit(collisionEvents [i], particleColorGradient);
            EmitAtLocation(collisionEvents[i]);
        }
    }
Beispiel #6
0
        private void OnParticleCollision(GameObject other)
        {
            ParticlePhysicsExtensions.GetCollisionEvents(particles, other, collisionEvents);

            /*
             * if(!isTrigger)
             * {
             *  if(other.name.StartsWith("Player"))
             *  {
             *      int id = other.transform.GetComponent<ExposerPlayer>().PlayerIndex;
             *      if(!gc.playersActions[id].isBurning)
             *      {
             *          gc.playersActions[id].isOiled = true;
             *          gc.playersActions[id].timeLeftOiled = 15.0f;
             *      }
             *      else
             *      {
             *          gc.playersActions[id].timeLeftBurn = 5.0f;
             *      }
             *  }
             *  else if(other.name != "jerrican")
             *  {
             *      GameObject oil = ObjectPooler.SharedInstance.GetPooledObject(0);
             *      oil.SetActive(true);
             *      oil.transform.position = collisionEvents[0].intersection;
             *      isTrigger = true;
             *  }
             * }
             */
        }
Beispiel #7
0
    private void OnParticleCollision(GameObject other)
    {
        ParticlePhysicsExtensions.GetCollisionEvents(splatParticles, other, collisionEvents);

        int count = collisionEvents.Count;


        //Debug.Log("---------------- PARTICLE COLLISIONS " + count);

        for (int i = 0; i < count; i++)
        {
            float create = Random.Range(0f, 100f);

            if (create < 50f)
            {
                //Debug.Log("Skip splat -----------------------------------------");
                return;
            }

            List <PooledObject> activeObjects = GameManager.Instance.objectPools.GetActiveObjectsWithinArea(collisionEvents[i].intersection, 0.5f);

            //Debug.Log(activeObjects.Count + " found nearby");

            if (activeObjects.Count > 75)
            {
                return;
            }

            ObjectPoolManager.PoolRequestInfo info = ObjectPoolManager.CreatePoolInfo(
                poolType,
                GameManager.Instance.splatHolder,
                collisionEvents[i].intersection,
                null,
                true,
                false
                );


            PooledObject pooledSplat = GameManager.GetPooledObject(info);

            if (pooledSplat == null)
            {
                //Debug.LogError("Out of Splats");
                return;
            }

            Splat splat = pooledSplat as Splat;
            splat.SetSplatVisualLayer(Splat.SplatLoacation.Foreground);



            //GameObject splat = Instantiate(splatPrefab, collisionEvents[i].intersection, Quaternion.identity) as GameObject;
            //splat.transform.SetParent(GameManager.Instance.splatHolder, true);
            //Splat splatScript = splat.GetComponent<Splat>();
            //splatScript.Initialize(Splat.SplatLoacation.Foreground);


            //Debug.Log("Creations : " + GameManager.splatCreations + " ---------------------------------------");
        }
    }
    public void OnPoopCollision(GameObject other)
    {
        if (other.GetComponentInParent <PoopSplat>() != null) // skip hits on other poop
        {
            return;
        }

        collisions.Clear();
        ParticlePhysicsExtensions.GetCollisionEvents(poopPS, other, collisions);

        for (int i = 0; i < collisions.Count; ++i)
        {
            var pf = pd.splatPrefabs[Random.Range(0, pd.splatPrefabs.Count)];
            var p  = Instantiate(pf);

            ++pd.currentCount;
            ++pd.totalCount;

            p.GetOrAddComponent <PoopSplat>().pooper = this;

            var        pos = collisions[i].intersection;
            RaycastHit hit;
            if (Physics.Raycast(pos, collisions[i].velocity, out hit))
            {
                pos = hit.point;
            }

            p.transform.position = pos;
            StartCoroutine(EnableCollider(p));
        }
    }
    void OnParticleCollision(GameObject other)
    {
        ParticlePhysicsExtensions.GetCollisionEvents(particleLauncher, other, particleCollisionEvents);

        for (int i = 0; i < particleCollisionEvents.Count; i++)
        {
            if (!Physics.Raycast(particleCollisionEvents[i].intersection,
                                 -particleCollisionEvents[i].normal,
                                 out hit,
                                 Mathf.Infinity,
                                 BrushScript.instance.layerMask))
            {
                continue;
            }

            rigidbody = other.transform.parent.GetComponent <Rigidbody>();
            if (rigidbody)
            {
                rigidbody.AddForce(particleCollisionEvents[i].velocity);
            }

            BrushScript.instance.Paint(hit, ParticleColor, ParticleSize * 20);
            EmitAtLocation(particleCollisionEvents[i]);
        }
    }
Beispiel #10
0
    // On particle collision
    void OnParticleCollision(GameObject other)
    {
        int safeLength = ParticlePhysicsExtensions.GetSafeCollisionEventSize(ps);

        if (collisionEvents.Length < safeLength)
        {
            collisionEvents = new ParticleCollisionEvent[safeLength];
        }

        int numCollisionEvents = ParticlePhysicsExtensions.GetCollisionEvents(ps, other, collisionEvents);

        // Play collision sound and apply force to the rigidbody was hit
        int i = 0;

        while (i < numCollisionEvents)
        {
            F3DAudioController.instance.ShotGunHit(collisionEvents[i].intersection);

            Rigidbody rb = other.GetComponent <Rigidbody>();
            if (rb)
            {
                Vector3 pos   = collisionEvents[i].intersection;
                Vector3 force = collisionEvents[i].velocity.normalized * 50f;

                rb.AddForceAtPosition(force, pos);
            }

            i++;
        }
    }
Beispiel #11
0
        public static ICollection <ParticleCollisionEvent> GetCollisionsWith(this ParticleSystem particleSystem, GameObject collidingGameObject)
        {
            List <ParticleCollisionEvent> events = new List <ParticleCollisionEvent>();

            ParticlePhysicsExtensions.GetCollisionEvents(particleSystem, collidingGameObject, events);
            return(events);
        }
 // TODO: this will affect particles from ANY system. Need to setup a link to the target particle system.
 // WARNING: For every particle collision in this frame, we check EVERY particle. Could be slow with 1000's of the things and lots of objects.
 // So that's 'number of particles that had a collision with this object in this frame' X 'number of particles' = number of loops.
 // In our case, we're train-lining particles so only one collision occurs at a time.
 // TODO: We use a hard-coded 0.2f in the below. What about units/scaling etc?
 // This value was chosen because 0.1f resulted in some particles not being detected as close enough to change their colour.
 void OnParticleCollision(GameObject fromThisParticleSystem)
 {
     if (fromThisParticleSystem)
     {
         ParticleSystem ps = fromThisParticleSystem.GetComponent <ParticleSystem>();
         //Get all collision events from the particle system that occurred with this sphere in this frame.
         int numCollisionEvents = ParticlePhysicsExtensions.GetCollisionEvents(ps, gameObject, collisionEvents);            //ps.GetCollisionEvents(sc, collisionEvents);
         for (int collisionEventCounter = 0; collisionEventCounter < numCollisionEvents; collisionEventCounter++)
         {
             ParticleCollisionEvent pce = collisionEvents [collisionEventCounter];
             // Now we have to find out which particles actually hit.
             // Get all the particles from this particle system that are 'in flight'.
             ParticleSystem.Particle[] inflightParticles = new ParticleSystem.Particle[ps.particleCount];
             int inflightParticleCount = ps.GetParticles(inflightParticles);
             // Find out which ones are close enough to the sphere to be considered a hit.
             for (int i = 0; i < inflightParticleCount; i++)
             {
                 //MUST use the 'transform' of the PS to get the particles position world space.
                 Vector3 particlePosWS = ps.transform.TransformPoint(inflightParticles [i].position);
                 double  distance      = Vector3.Distance(pce.intersection, particlePosWS);
                 if (distance < 0.2f)
                 {
                     inflightParticles[i].color = photonColor;
                 }
             }
             ps.SetParticles(inflightParticles, inflightParticleCount);                // Think, if multiple particles hit the same point vs hitting different points in this frame?
         }
     }
 }
Beispiel #13
0
    private void OnParticleCollision(GameObject other)
    {
        int numCollisionEvents = ParticlePhysicsExtensions.GetCollisionEvents(shotgunPellets, other, collisionEvents);

        int i = 0;

        while (i < numCollisionEvents)
        {
            if (other.tag == "Player")
            {
                var target             = other.gameObject.GetComponent <Player>();
                var targetPlayerNumber = target.ID;
                if (targetPlayerNumber != firingPlayerNumber)
                {
                    shotgun.player.RegisterNewValidHit(shotgun.player, target, shotgun.DamageAmount);
                    shotgun.CreateBloodSpray(target.transform.position, transform.rotation);
                }
            }
            else if (other.tag == "NPCHitbox")
            {
                var target = other.gameObject.GetComponent <AbstractCharacter>();
                shotgun.player.RegisterNewValidHit(shotgun.player, target, shotgun.DamageAmount);
            }
            i++;
        }
    }
Beispiel #14
0
    void OnParticleCollision(GameObject other)
    {
        ParticlePhysicsExtensions.GetCollisionEvents(breathParticle, other, collisionEvents);


        for (int i = 0; i < collisionEvents.Count; i++)
        {
            if (collisionEvents[i].colliderComponent != null)
            {
                if (collisionEvents[i].colliderComponent.tag == "Player")
                {
                    if (other.transform.GetChild(2).GetComponent <HealthPlayer>() != null)
                    {
                        if (!other.transform.GetChild(2).GetComponent <InvincibilityFrames>().GetInvincibleState())
                        {
                            print("Player got hit");
                            other.transform.GetChild(2).GetComponent <InvincibilityFrames>().StartInvincibility();

                            other.transform.GetChild(2).GetComponent <HealthPlayer>().Player_TakingDamage(
                                mDamageValues.damage,
                                mDamageValues.canKnockBack,
                                mDamageValues.knockBackPower * (other.transform.position - transform.position).normalized +
                                mDamageValues.knockBackPower / 2 * other.transform.forward
                                );
                        }
                    }
                    EmitAtLocation(collisionEvents[i]);
                }
                else
                {
                    EmitAtLocation(collisionEvents[i]);
                }
            }
        }
    }
 private void OnParticleCollision(GameObject other)
 {
     ParticlePhysicsExtensions.GetCollisionEvents(Gun, other, collisonEvents);
     for (int i = 0; i < collisonEvents.Count; i++)
     {
         EmitatLocation(collisonEvents[i]);
     }
 }
Beispiel #16
0
 private void OnParticleCollision(GameObject other)
 {
     ParticlePhysicsExtensions.GetCollisionEvents(moteParticleSystem, other, collisionEvents);
     for (int i = 0; i < collisionEvents.Count; i++)
     {
         MagicChamber.Instance.well.addMagic(condenser.GetCharge());
     }
 }
 private void OnParticleCollision(GameObject other)
 {
     ParticlePhysicsExtensions.GetCollisionEvents(particleLauncher, other, collisionEvent);
     for (int i = 0; i < collisionEvent.Count; i++)
     {
         EmitAtLocation(collisionEvent[i]);
     }
 }
Beispiel #18
0
 private void OnParticleCollision(GameObject other)
 {
     if (other.TryGetComponent(out IDamageable damagable))
     {
         var amount = ParticlePhysicsExtensions.GetCollisionEvents(particle, other, collisionEvents);
         damagable.TakeDamage(damage * amount);
     }
 }
Beispiel #19
0
    private void OnParticleCollision(GameObject other)
    {
        ParticlePhysicsExtensions.GetCollisionEvents(particles, other, collisionEvents);

        // int count = collisionEvents.Count;
        // for (int i = 0; i < count; i++) {
        Instantiate(bloodSprites[Random.Range(0, bloodSprites.Length)], collisionEvents[0].intersection, Quaternion.Euler(0f, 0f, 0f));
        // }
    }
Beispiel #20
0
    private void OnParticleCollision(GameObject other)
    {
        ParticlePhysicsExtensions.GetCollisionEvents(particleLauncher, other, collisionEvents);

        for (int i = 0; i < collisionEvents.Count; i++)
        {
            SpawnDecalBloodDroplets(collisionEvents[i]);
        }
    }
Beispiel #21
0
    void OnParticleCollision(GameObject other)
    {
        ParticlePhysicsExtensions.GetCollisionEvents(shooter, other, collisionEvents);

        foreach (var e in collisionEvents)
        {
            EmitAtLocation(e);
        }
    }
    private void OnParticleCollision(GameObject other)
    {
        int numcollisionevent = ParticlePhysicsExtensions.GetCollisionEvents(splatterparticles, other, collisionevents);

        for (int i = 0; i < numcollisionevent; i++)
        {
            dropletdecalpool.particlehit(collisionevents[i]);
        }
    }
 void OnParticleCollision(GameObject other)
 {
     ParticlePhysicsExtensions.GetCollisionEvents(particleLauncher, other, collisionEvents);
     for (int i = 0; i < collisionEvents.Count; i++)
     {
         otherSystem.Play();
         particleLauncher.Stop(true);
     }
 }
Beispiel #24
0
 private void OnParticleCollision(GameObject other)
 {
     Debug.Log("Hit!");
     ParticlePhysicsExtensions.GetCollisionEvents(skillParticle, other, collisionEvents);
     for (int i = 0; i < collisionEvents.Count; i++)
     {
         EmitAtLocation(collisionEvents[i]);
     }
 }
    private void OnParticleCollision(GameObject other)
    {
        ParticlePhysicsExtensions.GetCollisionEvents(bloodEmitter, other, collisionEvents);

        for (int i = 0; i < collisionEvents.Count; i++)
        {
            SpawnBloodAt(collisionEvents[i]);
        }
    }
 private void OnParticleCollision(GameObject other)
 {
     ParticlePhysicsExtensions.GetCollisionEvents(mNormalShots, other, collisionEvents);
     print("event found");
     for (int i = 0; i < collisionEvents.Count; i++)
     {
         EmitAtLocation(collisionEvents[i]);
     }
 }
    void OnParticleCollision(GameObject other)
    {
        ParticlePhysicsExtensions.GetCollisionEvents(particleLauncher, other, collisionEvents);

        for (int i = 0; i < collisionEvents.Count; i++)
        {
            splatDecalPool.ParticleHit(collisionEvents[i], particleColorGradient);
        }
    }
    private void OnParticleCollision(GameObject collidedObject)
    {
        ParticlePhysicsExtensions.GetCollisionEvents(_currentParticles, collidedObject, _collisionEvents);

        for (int i = 0; i < _collisionEvents.Count; i++)
        {
            BloodDecalPool.ParticleHit(_collisionEvents[i]);
        }
    }
    void OnParticleCollision(GameObject other)
    {
        int numCollisionEvents = ParticlePhysicsExtensions.GetCollisionEvents(particleLauncher, other, collisionEvents);

        for (int i = 0; i < numCollisionEvents; i++)
        {
            dropletDecalPool.ParticleHit(new ContactData(collisionEvents[i]), particleColorGradient);
        }
    }
Beispiel #30
0
    //particleSystem is the particle system whose particles cause the collision
    void OnParticleCollision(GameObject other)
    {
        ParticleSystem part = other.GetComponent <ParticleSystem>();

        ParticleCollisionEvent[] collisionEvents = new ParticleCollisionEvent[100];
        int numParticles = ParticlePhysicsExtensions.GetCollisionEvents(part, gameObject, collisionEvents);

        this.hp -= numParticles;
    }