public void TouchCell(int button, Vector3 position, bool isOnce) { position = transform.InverseTransformPoint(position); var clickedTile = TileHelper.GetTile(HexCoordinates.FromPosition(position)); if (clickedTile != null) { if (isOnce) { ClickOnceEvent(button, clickedTile); } else { ClickContinuingEvent(button, clickedTile); } } }
public void FindPath() { var startTile = TileHelper.GetTile(findPathStart); var endTile = TileHelper.GetTile(findPathEnd); PathFinderManager.StartPathFinding(true, startTile, endTile, (outPath) => { path = outPath; TileHelper.SetTilesColorToEnvironment(); float strengthPerPath = 1.0f / outPath.Count; int cnt = 0; foreach (var path in path) { path.color = new Color(strengthPerPath * ++cnt, 0, 0, 1); } TileHelper.ReDrawHexMesh(); }); }
// NOTE : 대륙 타일 설정 페이즈 private void CreateContinentTilePhase(IndexPair firstContinentTileIndex, ref List <Tile> continentTileList) { var continentTilesForCreate = new List <ContinentTile>(); // NOTE : 퍼센트를 계산하기 위한 기본 단위. 전체 타일의 1%에 해당 int percentBasicUnit = numOfMaxContinentTiles / 100; // NOTE : 대륙 영향력. 영향력이 높을수록 인접타일이 대륙일 확률이 높음 int influence = (int)(numOfMaxContinentTiles * Mathf.Clamp(influenceOfContinent, 0, 1)); // NOTE : 첫 대륙타일을 기준으로 대륙을 생성. var firstContinentTile = new ContinentTile(TileHelper.GetTile(firstContinentTileIndex), --influence / percentBasicUnit); continentTilesForCreate.Add(firstContinentTile); // NOTE : 최소 생성 수를 넘을때까지 대륙 생성 알고리즘을 반복 do { CreateContinentTilesFromNearTiles(continentTilesForCreate, influence, percentBasicUnit); } while (Mathf.Clamp(numOfLeastContinentTiles, 0, numOfMaxContinentTiles) > continentTilesForCreate.Count); Debug.Log($"{continentTilesForCreate.Count}continentTiles have created"); continentTileList = continentTilesForCreate.Select(x => x.tile).ToList(); }