Exemplo n.º 1
0
        private static bool SelectedResearchFacilityTile(PlotSelectable selectable)
        {
            // Selected the selected object, so open research facility
            if (selectable == selected)
            {
                Deselect(selectable);

                EventManager.Instance.RaiseEvent(new OpenResearchFacilityEvent());
                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Performs a raycast from the camera to the mouse
        /// </summary>
        /// <param name="selectable">The PlotSelectable that is hit by the raycast</param>
        /// <returns>True or False depending on whether we hit a PlotSelectable</returns>
        private bool RayCast(out PlotSelectable selectable)
        {
            Ray mouseRay = playerCamera.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(mouseRay, out RaycastHit hitinfo))
            {
                GameObject hitObject = hitinfo.collider.gameObject;
                selectable = hitObject.GetComponent <PlotSelectable>();

                if (selectable != null)
                {
                    return(true);
                }
            }

            selectable = null;
            return(false);
        }
Exemplo n.º 3
0
        private static bool SelectedBuilding(PlotSelectable selectable, AbstractBuildingTile abstractBuildingTile)
        {
            // Selected the selected object, so open market
            if (selectable == selected)
            {
                Deselect(selectable);

                if (abstractBuildingTile.HasDebris)
                {
                    EventManager.Instance.RaiseEvent(new SelectedBuildingTileEvent(abstractBuildingTile, true));
                    return(true);
                }

                EventManager.Instance.RaiseEvent(new OpenMarketEvent(abstractBuildingTile));
                return(true);
            }

            // Send the tile if it has a building, else send null so that the listeners know you selected something that has no building
            EventManager.Instance.RaiseEvent(new SelectedBuildingTileEvent(abstractBuildingTile.HasBuilding ? abstractBuildingTile : null, true));

            return(false);
        }
Exemplo n.º 4
0
        private void Select(PlotSelectable selectable)
        {
            AbstractTile abstractTile = selectable.GetTile();

            if (!(abstractTile is AbstractBuildingTile))
            {
                // we did not select a building, so tell our listeners
                EventManager.Instance.RaiseEvent(new SelectedBuildingTileEvent(null, false));
            }

            switch (abstractTile)             // Handle special actions if we selected an already selected tile
            {
            case AbstractBuildingTile buildingTile when SelectedBuilding(selectable, buildingTile):
            case ResearchFacilityTile researchFacilityTile when SelectedResearchFacilityTile(selectable):
                return;
            }

            Deselect(selected);             // Deselect the last selected object

            // select the new object
            selected = selectable;
            selectable.Select(selectedMaterial);
        }
Exemplo n.º 5
0
        private static void Deselect(ISelectable selectable)
        {
            selectable?.Deselect();

            selected = null;
        }