Esempio n. 1
0
    private void FireBeam()
    {
        if (Time.time < _lastShotTime + ShotCooldown)
        {
            return;
        }


        Ray ray = new Ray(Cam.transform.position, Cam.transform.forward);

        Debug.DrawRay(Cam.transform.position, Cam.transform.forward, Color.red, 3f);
        RaycastHit hit;

        Debug.DrawRay(ray.origin, ray.origin + (ray.direction * 100), Color.red, 1);

        if (Physics.Raycast(ray, out hit, int.MaxValue, ShotTargets))
        {
            Destroy(hit.transform.gameObject);

            if (hit.transform.gameObject.GetComponent <Box>() != null)
            {
                if (hit.transform.gameObject.GetComponent <Box>().name.Contains("Black"))
                {
                    Debug.Log(hit.transform.gameObject.GetComponent <Box>());
                    match3.destoryBlack(hit.transform.gameObject.GetComponent <Box>());
                    //Debug.Log("hit");
                    match3.check3();
                }
                else if (hit.transform.gameObject.GetComponent <Box>().name.Contains("White"))
                {
                    match3.destoryWhite(hit.transform.gameObject.GetComponent <Box>());

                    match3.destorybox(hit.transform.gameObject.GetComponent <Box>());
                    Debug.Log("hit");
                    match3.check3();
                }
                else
                {
                    match3.destorybox(hit.transform.gameObject.GetComponent <Box>());
                    Debug.Log("hit");
                    match3.check3();
                }
            }
        }

        _lastShotTime = Time.time;
    }