示例#1
0
 public void OnPointerEnter(PointerEventData eventData)
 {
     if (!string.IsNullOrEmpty(TooltipTitle))
     {
         Loc.GetGameController().ShowTooltip(TooltipTitle, TooltipText);
     }
 }
示例#2
0
        private void InstantiateNewPlantMesh()
        {
            var meshName = PlantName + "_" + (_lastGrowthIndex + 1);
            var mesh     = Loc.GetGameController().MeshRendererFactory.GetItemMesh(meshName);

            _plantMesh = Renderer.InstantiateSubMesh(mesh);
        }
示例#3
0
        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);
        }
示例#4
0
 private static void InvokeCellClickMethod(List <Cell> cells)
 {
     if (Loc.GetGameController().OrderSelectionController.CellClickOrder != null)
     {
         Loc.GetGameController().OrderSelectionController.CellClickOrder.Invoke(cells);
     }
 }
示例#5
0
    public void Show()
    {
        Loc.GetTimeManager().Pause();
        Loc.GetGameController().Typing = true;

        _showingConsole = true;
    }
示例#6
0
 public void Update()
 {
     if (!Loc.GetGameController().Paused)
     {
         Data.Update(Time.deltaTime);
     }
 }
示例#7
0
 private static void EnableAndClear()
 {
     Loc.GetGameController().OrderTrayController.gameObject.SetActive(true);
     foreach (Transform child in Loc.GetGameController().OrderTrayController.transform)
     {
         Destroy(child.gameObject);
     }
 }
示例#8
0
 private void DeselectItem()
 {
     foreach (var item in Loc.GetIdService().ItemIdLookup.Values)
     {
         item.HideOutline();
     }
     Loc.GetGameController().DestroyItemInfoPanel();
 }
示例#9
0
        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);
        }
示例#10
0
 internal void DestroyItem(ItemData item)
 {
     if (item != null)
     {
         Loc.GetIdService().RemoveItem(item);
         Loc.GetGameController().AddItemToDestroy(item.Renderer.gameObject);
     }
 }
示例#11
0
 private void DeselectStructure()
 {
     foreach (var structure in Loc.GetIdService().StructureIdLookup.Values)
     {
         structure.HideOutline();
     }
     Loc.GetGameController().DestroyStructureInfoPanel();
 }
示例#12
0
        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());
                        }
                    }
                }
            }
        }
示例#13
0
    public void DisableAndReset()
    {
        Loc.Current.Get <CursorController>().ResetSelection();

        Loc.GetGameController().OrderTrayController.gameObject.SetActive(false);
        CellClickOrder = null;

        Loc.GetGameController().OrderInfoPanel.Hide();
    }
示例#14
0
 private bool SelectZone(ZoneBase zone, bool selectSimilar)
 {
     if (zone != null)
     {
         Loc.GetGameController().ShowZonePanel(zone);
         return(true);
     }
     return(false);
 }
示例#15
0
    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}");
    }
示例#16
0
 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}"
         );
 }
示例#17
0
        private void DeselectCreature()
        {
            foreach (var creature in Loc.GetIdService().CreatureIdLookup.Values.Select(v => v.CreatureRenderer))
            {
                creature.DisableHightlight();
            }

            Loc.GetGameController().DestroyCreaturePanel();
            Loc.GetGameController().DestroyToolTip();
        }
示例#18
0
 public void CreatureClicked()
 {
     if (Creature != null)
     {
         Loc.GetCamera().ViewPoint(Creature.Vector);
         Loc.GetGameController().ShowCreaturePanel(new List <CreatureRenderer> {
             Creature.CreatureRenderer
         });
     }
 }
示例#19
0
    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);
    }
示例#20
0
        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);
        }
示例#21
0
        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();
            }
        }
示例#22
0
        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();
            }
        }
示例#23
0
    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);
        };
    }
示例#24
0
 public void ToggleTaskpanel()
 {
     if (_currentTaskPanel == null)
     {
         _currentTaskPanel = Instantiate(TaskPanelPrefab, Loc.GetGameController().UI.transform);
     }
     else
     {
         Destroy(_currentTaskPanel.gameObject);
     }
 }
示例#25
0
    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);
    }
示例#26
0
    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);
        }
    }
示例#27
0
        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);
            }
        }
示例#28
0
        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;
                    }
                }
            }
        }
示例#29
0
    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");
        }
    }
示例#30
0
    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();
    }