Esempio n. 1
0
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.collider.gameObject.tag == "Wall")
        {
            if (maxRebounds > 0 && --maxRebounds == 0)
            {
                Destroy(gameObject);
            }

            var normal = collision.GetContact(0).normal;

            var baby   = GameObject.FindGameObjectWithTag("Baby");
            var toBaby = (baby.transform.position - transform.position).normalized;

            var angle = Mathf.Acos(Vector3.Dot(toBaby, -normal)) / Mathf.PI;
            if (angle <= .5 || angle >= 1.5)
            {
                Destroy(gameObject);
            }
            else
            {
                var rb = GetComponent <Rigidbody>();
                rb.velocity = toBaby * rb.velocity.magnitude;
            }
        }
        else if (collision.collider.gameObject.tag == "Baby")
        {
            Debug.Log("baby heals itself");
            babyHealth.AddHealth(heal);
            babyPoo.AddPoo(food);
            Destroy(gameObject);
        }
    }
Esempio n. 2
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         babyHealth.RemoveHealth(10);
     }
     else if (Input.GetKeyDown(KeyCode.Backspace))
     {
         babyHealth.AddHealth(14);
     }
     else if (Input.GetKeyDown(KeyCode.J))
     {
         babyPoo.AddPoo(14);
     }
     else if (Input.GetKeyDown(KeyCode.K))
     {
         babyPoo.RemovePoo(17);
     }
     else if (Input.GetKeyDown(KeyCode.G))
     {
         babyWeight.AddWeight(17);
     }
     else if (Input.GetKeyDown(KeyCode.H))
     {
         babyWeight.RemoveWeight(17);
     }
 }
Esempio n. 3
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.collider.gameObject.tag == "Wall")
     {
         if (maxRebounds > 0 && --maxRebounds == 0)
         {
             Destroy(gameObject);
         }
     }
     else if (collision.collider.gameObject.tag == "Baby")
     {
         Debug.Log("baby eat cupcake");
         babyPoo.AddPoo(food);
         Destroy(gameObject);
     }
 }
Esempio n. 4
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.collider.gameObject.tag == "Wall")
     {
         if (maxRebounds > 0 && --maxRebounds == 0)
         {
             Destroy(gameObject);
         }
     }
     else if (collision.collider.gameObject.tag == "Baby")
     {
         Debug.Log("baby cuts itself");
         babyHealth.RemoveHealth(damages);
         babyPoo.AddPoo(food);
         Destroy(gameObject);
     }
 }