예제 #1
0
        private void Update()
        {
            if (!Input.GetMouseButtonDown(0))
            {
                return;
            }

            Vector3 mousePosition = Input.mousePosition;

            Ray r = mainCam.ScreenPointToRay(mousePosition);

            r.origin    = rayCaster.position;
            r.direction = rotationTransform * r.direction;

            int count = Physics2D.GetRayIntersectionNonAlloc(r, cache, 1000f, tooltipMask);

            if (count > 0)
            {
                ItemObjectBase newObj = cache[0].transform.GetComponent <ItemObjectBase>();

                tooltip.Enable();
                tooltip.ShowTooltip(newObj);
            }
            else
            {
                tooltip.Disable();
            }
        }
예제 #2
0
        public void ShowTooltip(ItemObjectBase obj)
        {
            if (current == obj)
            {
                return;
            }

            switch (obj)
            {
            case MapResourceObject resource:

                ShowResourceTooltip(resource);
                break;

            case FactoryObject factory:
                ShowFactoryTooltip(factory);
                break;

            default:
                return;
            }
        }
예제 #3
0
 public void Disable()
 {
     current = null;
     gameObject.SetActive(false);
 }