Пример #1
0
    /*
     * \brief Called when this first collides with something
     */
    void OnCollisionEnter(Collision collision)
    {
        if (m_playerState == GruntState.FallingFromTower)
        {
            return;
        }

        m_physics.CallOnCollisionEnter(collision);
    }
Пример #2
0
    /*
     * \brief Called when this first collides with something
     */
    void OnCollisionEnter(Collision collision)
    {
        if (m_playerState == GruntState.FallingFromTower)
        {
            return;
        }

        foreach (ContactPoint contact in collision)
        {
            //Debug.Log("This Collider: " + contact.thisCollider.gameObject.name);
            //Debug.Log("Other Collider: " + contact.otherCollider.gameObject.name);
            if (contact.otherCollider != null && contact.otherCollider.gameObject != null)
            {
                if (contact.otherCollider.gameObject.name == "Player Spawn")
                {
                    //Debug.Log("Collided with player");
                    m_playerState = GruntState.Attacking;
                    m_ticksInContactWithPlayer++;
                }
            }
            if (contact.thisCollider.gameObject.name == "Bip001 L Hand001" && contact.otherCollider.gameObject.name == "Player Spawn")
            {
                Debug.Log("Hit player");
                CEntityPlayer.GetInstance().PushPlayerFromTower();
                m_playerDetected = false;
            }
        }


        m_physics.CallOnCollisionEnter(collision, m_playerDetected);

        if (collision.collider.gameObject.name == "GruntBarrier")
        {
            m_onBarrier = true;
        }
        if (collision.collider.gameObject.name == "GruntSpawn" && !m_playerDetected)
        {
            m_playerState             = GruntState.Standing;
            m_physics.MovingDirection = -1;
        }
        if (collision.collider.gameObject.name == "Electricity")
        {
            //Kill grunt
            Object deathBlast = Instantiate(DeathEffect, transform.position, transform.rotation);
            Destroy(deathBlast, 2);
            Debug.Log(this);
            this.transform.gameObject.SetActiveRecursively(false);
        }
    }