private static bool CellIsOccupiable(IHexGridCell cell, bool isSquad) { if (cell is null) { return(false); } CreatureComponent creatureComponent = cell.GetComponent <CreatureComponent>(); System.Type creatureType = isSquad ? typeof(EnemyMovementController) : typeof(Squads.SquadController); return(!cell.HasComponent <UnselectableComponent>() && (creatureComponent is null || creatureComponent.Creature.GetType() == creatureType)); }
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); } }
protected virtual bool OccupiableLocation(IHexGridCell location) => !location.HasComponent <CreatureComponent>();