示例#1
0
    public LivingEntity DetectEntity()
    {
        if (!UIManager.Instance.YearUIActive())
        {
            float castDist = orbitCam.maxDistance;

            RaycastHit hit;

            if (Physics.Raycast(transform.position, transform.forward, out hit, castDist))
            {
                LivingEntity entity = hit.transform.GetComponent <LivingEntity>();

                if (entity && !entity.Dead)
                {
                    if (UIManager.Instance != null)
                    {
                        UIManager.Instance.SetInformationPanelActive(true);
                    }

                    if (!orbitCamEnabled && Input.GetButtonDown("Fire1"))
                    {
                        selectedEntity = entity;

                        SetOrbitCamera(true);
                        orbitCam.SetFocus(entity.transform, entity.orbitCamViewOffset);
                        orbitCamEnabled = true;
                    }

                    if (selectedEntity)
                    {
                        return(selectedEntity);
                    }

                    return(entity);
                }
            }
        }

        if (orbitCamEnabled)
        {
            return(selectedEntity);
        }

        if (UIManager.Instance != null)
        {
            UIManager.Instance.SetInformationPanelActive(false);
        }


        return(null);
    }