public void SelectTool(IMapEditorTool tool) { DeselectCurrentTool(); toolSelected = tool; GameObject.Find("MapEditorController").GetComponent <MapEditorController>().DeselectAll(); }
public void DeselectCurrentTool() { // Destory previous tool if (toolSelected != null) { toolSelected.Destory(); GameObject.Find("MapEditorController").GetComponent <MapEditorController>().DeselectAll(); } toolSelected = null; // Make all other buttons gray GrayOutAllToolButtons(); }
public MapElementSelectionDetector([Inject(Id = MapEditorInstaller.SECTION_TILE_EDITOR_ID)] IMapEditorTool sectionTileEditor, [Inject(Id = MapEditorInstaller.UNIT_TILE_EDITOR_ID)] IMapEditorTool unitTileEditor, [Inject(Id = MapEditorInstaller.PLAYER_UNITS_TILE_EDITOR_ID)] IMapEditorTool playerUnitsTileEditor, IMapElementMenuViewController mapElementMenuViewController, IGridInputManager gridInputManager, IInputLock inputLock) { _mapElementMenuViewController = mapElementMenuViewController; _gridInputManager = gridInputManager; _inputLock = inputLock; // TODO: Try to find a way to inject this array even though the implementations are bound with ID. _mapEditorTools = new List <IMapEditorTool> { sectionTileEditor, unitTileEditor, playerUnitsTileEditor }; }
public void Construct(MapStoreId mapStoreId, [Inject(Id = MapEditorInstaller.SECTION_TILE_EDITOR_ID)] IMapEditorTool sectionTileEditor, [Inject(Id = MapEditorInstaller.UNIT_TILE_EDITOR_ID)] IMapEditorTool unitTileEditor, [Inject(Id = MapEditorInstaller.PLAYER_UNITS_TILE_EDITOR_ID)] IMapEditorTool playerUnitsTileEditor, IMapDataStore mapDataStore, IInputLock inputLock, IInputEvents inputEvents, ILogger logger) { _mapStoreId = mapStoreId; _sectionTileEditor = sectionTileEditor; _playerUnitsTileEditor = playerUnitsTileEditor; _unitTileEditor = unitTileEditor; _mapDataStore = mapDataStore; _inputLock = inputLock; _inputEvents = inputEvents; _logger = logger; }
private bool ToolSelected(ISystemContainer systemContainer, IMapEditorTool tool) { var mapEditor = systemContainer.ActivitySystem.MapEditorActivity; return(mapEditor.CurrentTool.GetType() == tool.GetType()); }
// Update is called once per frame void Update() { IMapEditorTool mapEditorTool = toolSelector.toolSelected; // Mouse left click if (Input.GetMouseButtonDown(0)) { // If the event is responded by UI elements, do not respond again. if (EventSystem.current.IsPointerOverGameObject()) { return; } // Respond click if (mapEditorTool != null) { mapEditorTool.RespondMouseLeftClick(); } else { SelectClicked(); } } // Mouse left click up if (Input.GetMouseButtonUp(0)) { // If the event is responded by UI elements, do not respond again. if (EventSystem.current.IsPointerOverGameObject()) { return; } // Respond click if (mapEditorTool != null) { mapEditorTool.RespondMouseLeftUp(); } } // Mouse right click if (Input.GetMouseButtonDown(1)) { // If the event is responded by UI elements, do not respond again. if (EventSystem.current.IsPointerOverGameObject()) { return; } // Respond click if (mapEditorTool != null) { if (mapEditorTool.CanDestroy()) { toolSelector.DeselectCurrentTool(); } else { mapEditorTool.RespondMouseRightClick(); } } else { DeselectAll(); } } // Mouse move if (Input.GetAxis("Mouse X") != 0 || Input.GetAxis("Mouse Y") != 0) { if (mapEditorTool != null) { mapEditorTool.RespondMouseMove( Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y")); } } }