コード例 #1
0
    private void Solver_OnCollision(ObiSolver s, ObiSolver.ObiCollisionEventArgs e)
    {
        // reset to unwrapped state:
        foreach (var wrappable in wrappables)
        {
            wrappable.Reset();
        }

        var world = ObiColliderWorld.GetInstance();

        foreach (Oni.Contact contact in e.contacts)
        {
            // look for actual contacts only:
            if (contact.distance < 0.025f)
            {
                var col = world.colliderHandles[contact.other].owner;
                if (col != null)
                {
                    var wrappable = col.GetComponent <Wrappable>();
                    if (wrappable != null)
                    {
                        wrappable.SetWrapped();
                    }
                }
            }
        }
    }
コード例 #2
0
    private void HandleCollision(object sender, ObiSolver.ObiCollisionEventArgs e)
    {
        foreach (Oni.Contact contact in e.contacts)
        {
            // this one is an actual collision:
            if (contact.distance < 0.01)
            {
                //print(collidedParticles.Count);
                //print(totalParticles);

                Component collider;
                if (ObiCollider.idToCollider.TryGetValue(contact.other, out collider))
                {
                    if (collidedParticles.Contains(contact.particle))
                    {
                        return;
                    }

                    if (collider.CompareTag("Obstacle"))
                    {
                        collidedParticles.Add(contact.particle);
                    }
                    if ((float)collidedParticles.Count / totalParticles >= failRatio)
                    {
                        Splited = true;//========================================================================
                    }
                    // do something with the collider.
                }
            }
        }
    }
コード例 #3
0
    private void ObiSolverOnOnCollision(ObiSolver solver, ObiSolver.ObiCollisionEventArgs contacts)
    {
        //   var contact = contacts.contacts[0];


        foreach (var contact in contacts.contacts)
        {
            // this one is an actual collision:
            if (contact.distance < 0.01)
            {
                ObiCollider.idToCollider.TryGetValue(contact.other, out var collider);
                if (collider != null)
                {
                    if (collider.tag == "GameOverTrigger")
                    {
                        var emitter = (ObiEmitter)solver.particleToActor[contact.particle].actor;
                        emitter.life[solver.particleToActor[contact.particle].indexInActor] = 0;

                        if (_solverStore.IsAllPlayerPuddlesDied())
                        {
                            OnDied?.Invoke();
                        }
                    }

                    if (collider.tag == "Connectable")
                    {
                        var puddle = collider.GetComponent <Puddle>();
                        puddle.Join(_obiEmitter);
                        _source.PlayOneShot(_source.clip);
                    }
                }
            }
        }
    }
コード例 #4
0
        private void Solver_OnCollision(object sender, ObiSolver.ObiCollisionEventArgs e)
        {
//            Debug.Log("collision obi");
            if (OnParticleCollided != null)
            {
                foreach (var item in e.contacts)
                {
                    Component collider;
                    if (ObiCollider.idToCollider.TryGetValue(item.other, out collider))
                    {
                        OnParticleCollided.Invoke(this, collider.gameObject);

                        // Destroy particle
                        if (collider.tag.Equals("Throwable"))
                        {
                            ObiSolver.ParticleInActor pa = _solver.particleToActor[item.particle];
                            ObiEmitter emitter           = pa.actor as ObiEmitter;

                            if (emitter != null)
                            {
                                emitter.life[pa.indexInActor] = 0;
                            }
                        }
                    }
                }
            }
        }
コード例 #5
0
    private void Solver_OnCollision(ObiSolver solver, ObiSolver.ObiCollisionEventArgs e)
    {
        onGround = false;

        var world = ObiColliderWorld.GetInstance();

        foreach (Oni.Contact contact in e.contacts)
        {
            // look for actual contacts only:
            if (contact.distance > 0.01)
            {
                var col = world.colliderHandles[contact.other].owner;
                if (col != null)
                {
                    onGround = true;
                    return;
                }
            }
        }
    }
コード例 #6
0
    private void Solver_OnCollision(ObiSolver s, ObiSolver.ObiCollisionEventArgs e)
    {
        var world = ObiColliderWorld.GetInstance();

        foreach (Oni.Contact contact in e.contacts)
        {
            // look for actual contacts only:
            if (contact.distance > 0.01)
            {
                var col = world.colliderHandles[contact.other].owner;
                if (col == deathPitCollider)
                {
                    onDeath.Invoke();
                    return;
                }
                if (col == finishCollider)
                {
                    onFinish.Invoke();
                    return;
                }
            }
        }
    }
コード例 #7
0
ファイル: MazeManager.cs プロジェクト: AsliAsln/fruit_game
    private void Solver_OnCollision(ObiSolver s, ObiSolver.ObiCollisionEventArgs e)
    {
        var world = ObiColliderWorld.GetInstance();

        foreach (Oni.Contact contact in e.contacts)
        {
            // look for actual contacts only:
            if (contact.distance < 0.01f)
            {
                var col = world.colliderHandles[contact.bodyB].owner;
                if (colorizers[0].collider == col)
                {
                    solver.userData[contact.bodyA] = colorizers[0].color;
                    if (coloredParticles.Add(contact.bodyA))
                    {
                        UpdateScore(finishedParticles.Count, coloredParticles.Count);
                    }
                }
                else if (colorizers[1].collider == col)
                {
                    solver.userData[contact.bodyA] = colorizers[1].color;
                    if (coloredParticles.Add(contact.bodyA))
                    {
                        UpdateScore(finishedParticles.Count, coloredParticles.Count);
                    }
                }
                else if (finishLine == col)
                {
                    if (finishedParticles.Add(contact.bodyA))
                    {
                        UpdateScore(finishedParticles.Count, coloredParticles.Count);
                    }
                }
            }
        }
    }