예제 #1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "LostDog")
        {
            _leftDogs.Add(other.GetComponent <Dog>());
            //Debug.Log("Left : " + _leftDogs.Count);
            //Debug.Log("Right : " + _rightDogs.Count);

            other.tag = "Dog";
            other.gameObject.transform.SetParent(this.transform);
            other.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Kinematic;
            CalculatePositionDogs();
            other.gameObject.GetComponent <Dog>().playBackgroundLoop();
            other.gameObject.GetComponent <Dog>().haveMaster(true);
            // other.gameObject.AddComponent<LineRenderer>();

            other.gameObject.GetComponent <LineRenderer>().SetPosition(0, transform.position);
            other.gameObject.GetComponent <LineRenderer>().SetPosition(1, other.transform.position);
            other.gameObject.GetComponent <LineRenderer>().startWidth = 0.1f;
            other.gameObject.GetComponent <LineRenderer>().endWidth   = 0.1f;
        }
        if (other.tag == "start")
        {
            _scoreManager.showTuto();
        }
        if (other.tag == "end")
        {
            _scoreManager.endGame();
            GetComponent <Rigidbody2D>().isKinematic = true;
        }
    }