Example #1
0
    void checkClick()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray          ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction, Mathf.Infinity, (int)clickTargets);
            if (hit && hit.collider.gameObject.tag.ToLower() == "sheep")
            {
                Sheep sheep = hit.collider.gameObject.GetComponent <Sheep>();

                Sheep startSheepScript = null;
                if (startSheep != null)
                {
                    startSheep.GetComponent <Sheep>();
                }

                if (startSheep != null && sheep == startSheepScript && startSheepScript.startSheep)
                {
                    jump.Play();
                    sheep.ChargeAndStart();
                    isGameOver = false;
                    return;
                }
                if (sheep != null && isGameOver == false)
                {
                    jump.Play();
                    sheep.Jump();
                }
            }
        }
    }