Example #1
0
    public bool TryAddTarget(GameObject target, out bool hasFoundAllTargets)
    {
        hasFoundAllTargets = false;

        ISelectionComponent _currentTarget = target.GetComponent <ISelectionComponent>();

        if (_currentTarget != null)
        {
            _currentTarget.Select();
            return(true);
        }

        return(false);
    }
        protected override void OnClick(RaycastHit hit)
        {
            if (timeManager.IsTimeStepAdvancing)
            {
                return;
            }
            GameObject selectedObject = hit.collider.gameObject.transform.parent.gameObject;

            AssertHelper.Assert(selectedObject.name.Contains("hextile"), "Clicked on unexpected gameobject: " + selectedObject.name, this);
            IHexGridCell clickedTile = selectedObject.GetComponent <MonoHexGridCell>().HexGridCell;

            if (clickedTile.HasComponent <UnselectableComponent>())
            {
                return;
            }

            OnHoverOutline onHoverOutline = hit.collider.gameObject.GetComponent <OnHoverOutline>();

            if (onHoverOutline)
            {
                lastClicked = hit.collider.gameObject;
                onHoverOutline.OutlineColor = Color.cyan;
            }

            townCanvasController.DisplayedTown = null;
            ISelectionComponent selectionComponent = clickedTile.GetComponent <ISelectionComponent>();

            if (!(selectionComponent is null))
            {
                selectionComponent.Select();
            }
            foreach (ITileSelectSubscriber subscriber in subscribers)
            {
                subscriber.OnTileSelect(clickedTile);
            }
        }