public void SetDestinationByArrow(TileManager.TileDirection direction) { var borderDictionary = SearchBorderTiles(); var movableDictionary = SearchMovableTiles(borderDictionary); toMoveTile = movableDictionary[direction]; }
void CreateArrow(Dictionary <TileManager.TileDirection, Tile> movableDictionary) { directionArrowList = new List <DirectionArrow>(); foreach (KeyValuePair <TileManager.TileDirection, Tile> pair in movableDictionary) { TileManager.TileDirection direction = pair.Key; Vector3 characterPosition = characterInstance.transform.position; Vector2 arrowCoordinate = FieldTileUtility.GetCoordOfDirectionByPosition(direction, characterPosition); Vector2 arrowPosition = FieldTileUtility.GetPositionFromCoordinate(arrowCoordinate.x, arrowCoordinate.y); Vector3 arrowPositionWithZ = new Vector3(arrowPosition.x, arrowPosition.y, characterPosition.z); DirectionArrow directionArrow = null; directionArrow = GameObject.Instantiate(arrowPrefeb, arrowPositionWithZ, Quaternion.identity) as DirectionArrow; DirectionArrow directionArrowScript = directionArrow.gameObject.GetComponent <DirectionArrow>(); directionArrowScript.SetArrowDirection(direction); directionArrowList.Add(directionArrow); } }
public void SetArrowDirection(TileManager.TileDirection enumFormTileKey) { arrowDirection = enumFormTileKey; }
public static Vector2 GetCoordOfDirectionByPosition(TileManager.TileDirection direction, Vector3 basePosition) { Vector2 standardPosition = basePosition; Vector2 standardCoordinate = GetCoordFromPosition(standardPosition.x, standardPosition.y); Vector2 coordinate = Vector3.zero; if ((int)standardCoordinate.y % 2 == 1) //odd number { if (direction == TileManager.TileDirection.UpLeft) { coordinate = new Vector2(standardCoordinate.x, standardCoordinate.y + 1); } else if (direction == TileManager.TileDirection.MidLeft) { coordinate = new Vector2(standardCoordinate.x - 1, standardCoordinate.y); } else if (direction == TileManager.TileDirection.DownLeft) { coordinate = new Vector2(standardCoordinate.x, standardCoordinate.y - 1); } else if (direction == TileManager.TileDirection.UpRight) { coordinate = new Vector2(standardCoordinate.x + 1, standardCoordinate.y + 1); } else if (direction == TileManager.TileDirection.MidRight) { coordinate = new Vector2(standardCoordinate.x + 1, standardCoordinate.y); } else if (direction == TileManager.TileDirection.DownRight) { coordinate = new Vector2(standardCoordinate.x + 1, standardCoordinate.y - 1); } } else //even number { if (direction == TileManager.TileDirection.UpLeft) { coordinate = new Vector2(standardCoordinate.x - 1, standardCoordinate.y + 1); } else if (direction == TileManager.TileDirection.MidLeft) { coordinate = new Vector2(standardCoordinate.x - 1, standardCoordinate.y); } else if (direction == TileManager.TileDirection.DownLeft) { coordinate = new Vector2(standardCoordinate.x - 1, standardCoordinate.y - 1); } else if (direction == TileManager.TileDirection.UpRight) { coordinate = new Vector2(standardCoordinate.x, standardCoordinate.y + 1); } else if (direction == TileManager.TileDirection.MidRight) { coordinate = new Vector2(standardCoordinate.x + 1, standardCoordinate.y); } else if (direction == TileManager.TileDirection.DownRight) { coordinate = new Vector2(standardCoordinate.x, standardCoordinate.y - 1); } } return(coordinate); }