示例#1
0
    void OnCollisionEnter(Collision collision)
    {
        //gameplayScript.EndGame();

        //Debug.Log(collision.gameObject.transform.name);

        GameplayScript gs = collision.gameObject.GetComponent <GameplayScript>();

        if (gs != null)
        {
            gs.EndGame();
        }
        else
        {
            Debug.Log("NIEWŁAŚCIWY OBIEKT WYKRYWA KOLIZJĘ");
        }
    }
示例#2
0
    void OnTriggerEnter(Collider other)
    {
        //Debug.Log(other.gameObject.name);

        if (other.attachedRigidbody.name.Contains("Car"))
        {
            GameplayScript gameplayScript = other.attachedRigidbody.gameObject.GetComponent <GameplayScript>();

            if (rigidbodies.ContainsKey(gameplayScript))
            {
                rigidbodies[gameplayScript]++;
            }

            if (gameplayScript.AddWaypointIndex(WaypointID))
            {
                Vector3 collisionPosition = other.gameObject.GetComponent <Collider>().ClosestPointOnBounds(transform.position);

                gameplayScript.SetWaypointPosition(collisionPosition);
                gameplayScript.SetNormalToWaypoint(Normal);
                gameplayScript.IncreaseScore(BonusPointsForCrossing);

                //Debug.Log("Waypoint " + WaypointID + ", point: " + collisionPosition);

                rigidbodies.Add(gameplayScript, 1);

                if (IsFinishLine)
                {
                    gameplayScript.ClearWaypointIndexes();
                }
            }
            else
            {
                if (!rigidbodies.ContainsKey(gameplayScript))
                {
                    //Debug.Log("COFNĄŁ SIĘ - UBIT");
                    gameplayScript.EndGame();
                }
            }
        }
    }