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 bool UpdateLocation(IHexGridCell location) { CreatureComponent otherCreature = location.GetComponent <CreatureComponent>(); if (!(otherCreature is null) && !(otherCreature.Creature is EnemyMovementController && IsUserControlledFunction())) { return(false); } if (Location != null) { AssertHelper.Assert(creatureComponent != null, "Missing creature component", this); bool success = Location.RemoveComponent(creatureComponent); AssertHelper.Assert(success, "Failed to remove creature component", this); } else { creatureComponent = new CreatureComponent(this); } Location = location; Location.AddComponent(creatureComponent); return(true); }
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); } }