public void AddTileType(TileType tileType) { if (!tileTypes.ContainsKey(tileType)) { tileTypes[tileType] = 1; } else { tileTypes[tileType]++; } tileEvent.Invoke(tileType); }
////Event handler //void OnMouseUp() //{ // clicked.Invoke(this); //} public void OnPointerClick(PointerEventData eventData) { if (eventData.button == PointerEventData.InputButton.Left) { clicked.Invoke(this); } }
/// <summary>Sets the grid space as occupied with the given character grid object.</summary> /// <param name="newObject">Parameter for the grid object that will occupy the grid space.</param> /// <returns>Returns true if the grid object is not null and returns false if it is null.</returns> public bool OccupySpace(GridObject newObject) { if (newObject != null) { // Remove current occupant if there is one if (HasGridObject()) { UnoccupySpace(); } gridObject = newObject; if (IsObjectType(ObjectType.Wall)) { SetWallTriggers(); UpdateGridButtonPosition(); } if (GameToolTipManager.Instance.IsActive() && GameToolTipManager.Instance.IsShowingToolTip(this)) { GameToolTipManager.Instance.Deactivate(); GameToolTipManager.Instance.Activate(this); } // Call on Enter onEnter?.Invoke(this); return(true); } Debug.LogWarning("WARNING: Grid Object Passed to Grid Space is null!"); return(false); }
public void BoosterGoOff() { if (boosterEvent != null && boosterTile != null) { boosterEvent.Invoke(boosterTile); } }
public void Capture(Tile newBorder, UnityAction <WorldTile> capturedCallback) { PlayerBorderTilemap.SetTile(LocalPlace, newBorder); tileCaptured.Invoke(this); tileCaptured.RemoveAllListeners(); tileCaptured.AddListener(capturedCallback); }
public static void TriggerEvent(string eventName, TaskableBase location) { TileEvent thisEvent = null; if (instance.tileEventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.Invoke(location); } }
private void OnMouseExit() { //Conditions: 1. Must have tile selected 2. this must not be the one selected already if (boardHandler.Tiles.Count == 0 || boardHandler.Tiles.Contains(this) == false || boardHandler.Tiles.First() == this) { return; } //Call Event OnDisconnectTile.Invoke(this); }
private void OnMouseEnter() { //Conditions: 1. Must have tile selected 2 if (boardHandler.Tiles.Count == 0) { return; } //Call Event OnConnectTile.Invoke(this); }
IEnumerator MoveTo(Vector3 targetPosition) { NewLocation = targetPosition; InitialLocation = targetPosition; while (true) { yield return(new WaitForEndOfFrame()); if (Vector3.Distance(rectTransform.localPosition, NewLocation) > MINIMUM_DIST) { rectTransform.localPosition = Vector3.MoveTowards(rectTransform.localPosition, NewLocation, Speed); } else { OnReachLocation.Invoke(this); yield break; } } }
private void Update() { if (Input.GetMouseButtonDown(0)) { Vector3 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition); Vector3Int mousePosition = new Vector3Int((int)pos.x, (int)pos.y, 0); TileBase tile = tilemap.GetTile(mousePosition); if (tile != null) { Debug.Log(tile.name + " clicked"); for (int i = 0; i < hexTypes.Count; i++) { if (tile.name == hexTypes[i].name) { TileClicked.Invoke(hexTypes[i], mousePosition); } } } } }
// Start is called before the first frame update void Awake() { tileCreated.Invoke(this); }
public void Buy(GameObject buyer) { ChangeState(InteriorTileState.Opend); GetComponent <BoxCollider2D>().enabled = false; onBuy.Invoke(this); }
private void OnMouseDown() { //Call Event OnSelectTile.Invoke(this); }
private void OnMouseUp() { //Call Event OnDeselectTile.Invoke(this); }
public void MoveToTile(WorldTile tile) { movement--; transform.position = new Vector3(tile.WorldLocation.x, tile.WorldLocation.y, -9); captureTile.Invoke(tile); }
private void Update() { Vector2 cameraPositionInMeters = new Vector2(Camera.main.transform.position.x, Camera.main.transform.position.z); cameraPositionInMeters += OriginInMeters; cameraPositionInMeters += new Vector2(-NumericConstants.TILE_SIZE, NumericConstants.TILE_SIZE); Tile currentTile = GeoPositioningHelper.GetTileFromCoordinate( GeoPositioningHelper.GetCoordinateFromMeters(cameraPositionInMeters), Zoom); if (Tilemap.CenterTile != currentTile) { Tilemap.UpdateCenterTile(currentTile); for (int i = 0; i < osmFileParsers.Count; i++) { if (Tilemap.IsTileOnMap(osmFileParsers[i].Tile)) { osmFileParsers.RemoveAt(i); break; } } for (int i = 0; i < osmGeoJSONParsers.Count; i++) { if (Tilemap.IsTileOnMap(osmGeoJSONParsers[i].Tile)) { osmGeoJSONParsers.RemoveAt(i); break; } } } if (Tilemap.HasTilesToRemove()) { OnTileRemoved.Invoke(Tilemap.DequeueTileToRemove()); } if (Tilemap.HasTilesToVisualize()) { DownloadAndVisualizeTile(Tilemap.DequeueTileToVisualize()); } for (int i = 0; i < osmFileParsers.Count; i++) { if (osmFileParsers[i].IsCompleted) { OnOsmFileParsed.Invoke(osmFileParsers[i]); osmFileParsers.RemoveAt(i); break; } } for (int i = 0; i < osmGeoJSONParsers.Count; i++) { if (osmGeoJSONParsers[i].IsCompleted) { OnGeoJSONParsed.Invoke(osmGeoJSONParsers[i]); osmGeoJSONParsers.RemoveAt(i); break; } } }