Ejemplo n.º 1
0
        void DetectBuilding()
        {
            Ray        raycast = new Ray(playerCamera.position, playerCamera.forward);
            RaycastHit hit;

            if (Physics.Raycast(raycast, out hit, detectionDistance))
            {
                if (detected == false)
                {
                    detected = true;
                    if (hit.collider.gameObject.CompareTag("Building"))
                    {
                        ui = hit.collider.gameObject.GetComponent <resource>();
                        ui.SetCloseEnough(true);
                    }
                    if (hit.collider.gameObject.CompareTag("Resource"))
                    {
                        // target is rock
                        ui = hit.collider.gameObject.GetComponent <resource>();
                        ui.SetCloseEnough(true);
                        res = hit.collider.gameObject.GetComponent <resource>();
                    }
                }
            }
            else
            {
                if (ui != null)
                {
                    ui.SetCloseEnough(false);
                    ui = null;
                }

                if (res != null)
                {
                    res = null;
                }

                detected = false;
            }
        }
Ejemplo n.º 2
0
 public void RemoveResourceFromWatch(resource fromWatch)
 {
     m_activeResources.Remove(fromWatch);
 }
Ejemplo n.º 3
0
 public void AddResourceToWatch(resource toWatch)
 {
     m_activeResources.Add(toWatch);
 }