public void OnPointerEnter(PointerEventData eventData) { if (!string.IsNullOrEmpty(TooltipTitle)) { Loc.GetGameController().ShowTooltip(TooltipTitle, TooltipText); } }
private void InstantiateNewPlantMesh() { var meshName = PlantName + "_" + (_lastGrowthIndex + 1); var mesh = Loc.GetGameController().MeshRendererFactory.GetItemMesh(meshName); _plantMesh = Renderer.InstantiateSubMesh(mesh); }
private bool SelectCreatures(List <CreatureRenderer> creatures, bool selectSimilar) { if (creatures.Count == 1 && selectSimilar) { var creature = creatures[0].Data; creatures = Loc.GetMap().GetCircle(creature.Cell, DoubleClickRadius) .SelectMany(c => c.Creatures) .Where(c => c.BehaviourName == creature.BehaviourName) .Select(c => c.CreatureRenderer) .ToList(); } foreach (var creature in creatures) { creature.EnableHighlight(ColorConstants.GreenAccent); } if (creatures?.Count > 0) { Loc.GetGameController().ShowCreaturePanel(creatures); return(true); } return(false); }
private static void InvokeCellClickMethod(List <Cell> cells) { if (Loc.GetGameController().OrderSelectionController.CellClickOrder != null) { Loc.GetGameController().OrderSelectionController.CellClickOrder.Invoke(cells); } }
public void Show() { Loc.GetTimeManager().Pause(); Loc.GetGameController().Typing = true; _showingConsole = true; }
public void Update() { if (!Loc.GetGameController().Paused) { Data.Update(Time.deltaTime); } }
private static void EnableAndClear() { Loc.GetGameController().OrderTrayController.gameObject.SetActive(true); foreach (Transform child in Loc.GetGameController().OrderTrayController.transform) { Destroy(child.gameObject); } }
private void DeselectItem() { foreach (var item in Loc.GetIdService().ItemIdLookup.Values) { item.HideOutline(); } Loc.GetGameController().DestroyItemInfoPanel(); }
private void InstantiateFlames(Structure structure) { _flameMesh = Loc.GetGameController().MeshRendererFactory.CreateFlameMesh(structure.Renderer.transform); var scale = structure.BaseFlammability / 100f * 5f * Random.Range(0.75f, 1.25f); _flameMesh.transform.localScale = new Vector3(scale, scale, scale); _flameMesh.transform.rotation = Quaternion.Euler(0, Random.Range(0f, 360f), 0); }
internal void DestroyItem(ItemData item) { if (item != null) { Loc.GetIdService().RemoveItem(item); Loc.GetGameController().AddItemToDestroy(item.Renderer.gameObject); } }
private void DeselectStructure() { foreach (var structure in Loc.GetIdService().StructureIdLookup.Values) { structure.HideOutline(); } Loc.GetGameController().DestroyStructureInfoPanel(); }
private void HandleMouseInput() { if (MouseOverUi()) { return; } if (InputHelper.RightMouseClciked()) { Clear(); DeselectAll(); Loc.GetGameController().OrderSelectionController.DisableAndReset(); } else { var worldMousePosition = GetWorldMousePosition(); if (worldMousePosition != null) { if (InputHelper.LeftMouseButtonDoubleClicked()) { ClearSelection(); GetSelection(_selectionPreference, GetSelectedCells(), true); } else { if (InputHelper.LeftMouseButtonStartClick()) { _selectionStartWorld = GetWorldMousePosition().Value; } if (InputHelper.LeftMouseButtonReleased()) { ClearSelection(); GetSelection(_selectionPreference, GetSelectedCells(), false); } if (InputHelper.LeftMouseButtonIsBeingClicked()) { ShowSelectionRectangle(); var selectionEndScreenPosition = Input.mousePosition; var start = Loc.GetCamera().Camera.WorldToScreenPoint(_selectionStartWorld); start.z = 0f; SelectSquareImage.position = (start + selectionEndScreenPosition) / 2; var sizeX = Mathf.Abs(start.x - selectionEndScreenPosition.x); var sizeY = Mathf.Abs(start.y - selectionEndScreenPosition.y); SelectSquareImage.sizeDelta = new Vector2(sizeX, sizeY); ShowCursorEffects(GetSelectedCells()); } } } } }
public void DisableAndReset() { Loc.Current.Get <CursorController>().ResetSelection(); Loc.GetGameController().OrderTrayController.gameObject.SetActive(false); CellClickOrder = null; Loc.GetGameController().OrderInfoPanel.Hide(); }
private bool SelectZone(ZoneBase zone, bool selectSimilar) { if (zone != null) { Loc.GetGameController().ShowZonePanel(zone); return(true); } return(false); }
public void UpdateStuctureOrder(string structureName) { var structure = Loc.GetStructureController().StructureDataReference[structureName]; Loc.GetGameController().OrderInfoPanel.Show($"Build {structureName}", "Select a location to place the structure. A creature with the build skill will gather the required cost of material and then make the structure.", structure.Description, $"{structure.Cost}"); }
private static void ShowConstructInfo(Construct constuct) { Loc.GetGameController().OrderInfoPanel.Show( $"Place {constuct.Name}", "Select a location to place the construct, rotate with E or Q. A construct is a predefined collection of structures and is built by a creature with the build skill.", constuct.Description, $"{constuct.TotalCost}" ); }
private void DeselectCreature() { foreach (var creature in Loc.GetIdService().CreatureIdLookup.Values.Select(v => v.CreatureRenderer)) { creature.DisableHightlight(); } Loc.GetGameController().DestroyCreaturePanel(); Loc.GetGameController().DestroyToolTip(); }
public void CreatureClicked() { if (Creature != null) { Loc.GetCamera().ViewPoint(Creature.Vector); Loc.GetGameController().ShowCreaturePanel(new List <CreatureRenderer> { Creature.CreatureRenderer }); } }
private void Start() { Loc.GetGameController().OrderTrayController.gameObject.SetActive(false); Loc.GetGameController().OrderInfoPanel.Hide(); BuildButton = CreateOrderButton(BuildTypeClicked, null, "hammer", "#ffffff", false); ConstructButton = CreateOrderButton(ConstructTypeClicked, null, "construct", "#ffffff", false); ZonesButton = CreateOrderButton(ZoneTypeClicked, null, "plus_t", "#ffffff", false); TaskButton = CreateOrderButton(DesignateTypeClicked, null, "designate", "#ffffff", false); }
internal static MeshRenderer CreateFlameMeshWithLight(float range, float intensity, Color color, Transform parent) { var mesh = Loc.GetGameController().MeshRendererFactory.CreateFlameMesh(parent); mesh.transform.localPosition += new Vector3(0, -0.2f, 0); Loc.GetVisualEffectController().CreateFireLight(mesh.transform, color, range, intensity, 1f); return(mesh); }
public void MoveUp() { if (Loc.GetFactionController().PlayerFaction.AvailableTasks.Contains(_task)) { Loc.GetFactionController().PlayerFaction.AvailableTasks.Remove(_task); Loc.GetFactionController().PlayerFaction.AvailableTasks.Insert(0, _task); Loc.GetGameController().UIController.ReloadTaskPanel(); } }
public void Suspend() { if (Loc.GetFactionController().PlayerFaction.AvailableTasks.Contains(_task)) { _task.Suspend(false); Loc.GetFactionController().PlayerFaction.AvailableTasks.Remove(_task); Loc.GetFactionController().PlayerFaction.AvailableTasks.Add(_task); Loc.GetGameController().UIController.ReloadTaskPanel(); } }
public void AddStoreClicked() { ShowStorageInfo(); SetCursorAndSpriteForZone(Loc.GetZoneController().StorageSprite); CellClickOrder = cells => { var newZone = Loc.GetZoneController().CreateStore(FactionConstants.Player, cells.Where(c => CanAddCellToZone(c)).ToArray()); Loc.GetGameController().ShowZonePanel(newZone); }; }
public void ToggleTaskpanel() { if (_currentTaskPanel == null) { _currentTaskPanel = Instantiate(TaskPanelPrefab, Loc.GetGameController().UI.transform); } else { Destroy(_currentTaskPanel.gameObject); } }
private OrderButton CreateOrderButton(UnityAction action, UnityAction onHover, Sprite sprite, bool isSubButton = true) { // create a top level button for an order type var button = Instantiate(OrderButtonPrefab, isSubButton ? Loc.GetGameController().OrderTrayController.transform : transform); button.Button.onClick.AddListener(action); button.OnMouseEnter = onHover; button.Button.image.sprite = sprite; return(button); }
internal void DestroyCreature(CreatureRenderer creature) { if (creature != null) { Debug.Log($"Destroying: {creature.Data.Name}"); if (creature.Data.Task != null) { creature.Data.AbandonTask(); } Loc.GetFactionController().Factions[creature.Data.FactionName].Creatures.Remove(creature.Data); Loc.GetIdService().RemoveCreature(creature.Data); Loc.GetGameController().AddItemToDestroy(creature.gameObject); } }
internal void DestroyStructure(Structure structure) { if (structure != null) { if (structure.Cell == null) { Debug.Log("Unbound structure"); } structure.OnDestroy(); Loc.GetIdService().RemoveStructure(structure); Loc.GetFactionController().Factions[structure.FactionName].Structures.Remove(structure); Loc.GetGameController().AddItemToDestroy(structure.Renderer.gameObject); } }
internal void DestroyBlueprint(Blueprint blueprint) { if (blueprint.BlueprintRenderer != null) { Loc.GetGameController().AddItemToDestroy(blueprint.BlueprintRenderer.transform.gameObject); foreach (var faction in Loc.GetFactionController().Factions.Values) { if (faction.Blueprints.Contains(blueprint)) { faction.Blueprints.Remove(blueprint); return; } } } }
public void ZoneTypeClicked() { if (Loc.GetGameController().OrderTrayController.gameObject.activeInHierarchy) { DisableAndReset(); } else { EnableAndClear(); CreateOrderButton(() => AddRoomClicked(), () => ShowRoomInfo(), "beer_t"); CreateOrderButton(() => AddStoreClicked(), () => ShowStorageInfo(), "box"); CreateOrderButton(() => AddAreaClicked(), () => ShowAreaInfo(), "plate_t"); CreateOrderButton(() => DeleteZoneClicked(), () => ShowDeleteInfo(), "cancel"); } }
internal void SpawnItem(ItemData data) { var mesh = Loc.GetGameController().MeshRendererFactory .GetItemMesh(data.Mesh); var meshObject = Instantiate(mesh, transform); var itemRenderer = meshObject.gameObject.AddComponent <ItemRenderer>(); itemRenderer.Data = data; data.Renderer = itemRenderer; IndexItem(data); data.Cell = Loc.GetMap().GetCellAtCoordinate(new Vector3(data.Coords.X, 0, data.Coords.Z)); itemRenderer.UpdatePosition(); }