Пример #1
0
    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "Planet")
        {
            //m_CollidedWithPlanet = true;

            m_CurrentPlanet = collision.gameObject.GetComponent <PlanetGravityField>();
            //Debug.Log("Player Collided with " + collision.gameObject.name);

            // Rotate player towards planet
            RotateTowardsCurrentPlanet();
        }

        else if (collision.gameObject.CompareTag("Hazard") && this.CompareTag("Player"))
        {
            // SFX
            FindObjectOfType <AudioManager>().Play("Lava Death");
            Debug.Log("hazard");
            //GetComponent<KnockOut>().PlayerKnockedOut();

            // Story time.
            // So if I call the knockout function, it tells it to set itself outside of the killbox,
            // which also calls the knockout function, so it takes the KO twice.
            // So I'm setting it outside of the killbox so the killbox calls the function only once. :P
            // SO GOOD [Graham]
            m_RigidBody.MovePosition(new Vector3(-6000, -6000, 0));
        }
    }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        m_RigidBody        = GetComponent <Rigidbody>();
        m_Collider         = GetComponent <Collider>();
        m_PlayerStats      = GetComponent <PlayerStats>();
        m_CurrentPlanet    = null;
        m_PlanetsAffecting = new List <Collider>();
        m_DistanceToGround = m_Collider.bounds.extents.y;

        l_hangTime   = 0.0f;
        l_groundTime = 0.0f;
    }
Пример #3
0
    void OnTriggerEnter(Collider other)
    {
        if (tag.Equals("Player") || tag.Equals("Bullet"))
        {
            if (other.tag == "Planet")
            {
                if (!m_PlanetsAffecting.Contains(other))
                {
                    m_PlanetsAffecting.Add(other);
                    Debug.Log("Entering " + other.name);

                    if (OnlyOnePlanetInRange())
                    {
                        m_CurrentPlanet = other.gameObject.GetComponent <PlanetGravityField>();
                    }

                    RotateTowardsCurrentPlanet();
                }
            }
        }
    }
    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "Planet")
        {
            //m_CollidedWithPlanet = true;

            m_CurrentPlanet = collision.gameObject.GetComponent <PlanetGravityField>();
            //Debug.Log("Player Collided with " + collision.gameObject.name);

            // Rotate player towards planet
            RotateTowardsCurrentPlanet();
        }

        else if (collision.gameObject.CompareTag("Hazard"))
        {
            // SFX
            FindObjectOfType <AudioManager>().Play("Lava Death");
            Debug.Log("hazard");
            GetComponent <KnockOut>().ResetPlayer();
        }
    }
Пример #5
0
    void OnTriggerExit(Collider other)
    {
        if (other.tag == "Planet")
        {
            if (m_PlanetsAffecting.Contains(other))
            {
                Debug.Log("Leaving " + other.name);
                m_PlanetsAffecting.Remove(other);
            }
        }

        //Debug.Log(m_PlanetsAffecting.Count);
        if (!PlanetInRange())
        {
            m_CurrentPlanet = null;
        }
        else if (OnlyOnePlanetInRange())
        {
            m_CurrentPlanet = m_PlanetsAffecting[0].GetComponent <PlanetGravityField>();
            Debug.Log("Current Planet: " + m_CurrentPlanet.name);
            RotateTowardsCurrentPlanet();
        }
    }