private void OnCreateBoard(IBoard board) { var maxPosY = float.MinValue; var maxPosX = float.MinValue; var minPosY = float.MaxValue; var minPosX = float.MaxValue; foreach (var pos in board.Positions) { var hex = pos.Point; var cell = BoardManipulationOddR.GetCellCoordinate(hex); var worldCellPos = tileMap.CellToWorld(cell); if (worldCellPos.x > maxPosX) { maxPosX = worldCellPos.x; } if (worldCellPos.y > maxPosY) { maxPosY = worldCellPos.y; } if (worldCellPos.x < minPosX) { minPosX = worldCellPos.x; } if (worldCellPos.y < minPosY) { minPosY = worldCellPos.y; } } Centralize(minPosX, minPosY, maxPosX, maxPosY); }
public void GeneratePositions() { var hexPoints = Data.GetHexPoints(); var cellPoints = BoardManipulationOddR.ConvertGroup(hexPoints); Positions = new Position <T> [cellPoints.Length]; for (var index = 0; index < cellPoints.Length; index++) { var i = cellPoints[index]; Positions[index] = new Position <T>(i); } OnCreateBoard(); }
private void CreateBoard() { //using the tile map orientation to pick the default value if (tileMap.orientation == Tilemap.Orientation.XY) { CreateBoardPointy(); } else { CreateBoardFlat(); } BoardManipulation = new BoardManipulationOddR(boardShape); }
void OnDrawGizmos() { if (CurrentBoard == null) { return; } foreach (var hex in controller.boardShape.GetHexPoints()) { var cell = BoardManipulationOddR.GetCellCoordinate(hex); var worldPosition = tileMap.CellToWorld(cell); Gizmos.DrawWireSphere(worldPosition, 0.93f); } }
void InitializeGameDataStructures(GameArgs args) { { //Create Players var userId = args.GameParameters.Profiles.UserPlayer.id; var aiId = args.GameParameters.Profiles.AiPlayer.id; var user = new Player(userId, args.GameParameters, args.Dispatcher); var ai = new Player(aiId, args.GameParameters, args.Dispatcher); Players = new[] { user, ai }; //Create Hands Hands = new IHand[] { new Hand(user.Id, args.GameParameters, Dispatcher), new Hand(ai.Id, args.GameParameters, Dispatcher) }; //Create Inventories Inventories = new IInventory[] { new Inventory(user.Id, Parameters, Dispatcher), new Inventory(ai.Id, Parameters, Dispatcher) }; //Create Score Score = new Score(Players, args.GameParameters, args.Dispatcher); } //Create Board Board = new Board <CreatureElement>(args.GameParameters, Dispatcher); //Create Board Manipulation BoardManipulation = new BoardManipulationOddR(args.GameParameters.BoardData); //Create Pool Pool = new Pool <CardPool>(args.GameParameters, Dispatcher); { //Create Library var libData = new Dictionary <PlayerId, CardData[]> { { PlayerId.User, args.GameParameters.Profiles.UserPlayer.LibraryData.GetDeck() }, { PlayerId.Ai, args.GameParameters.Profiles.AiPlayer.LibraryData.GetDeck() } }; Library = new Library(libData, Dispatcher); } }
void CreateBoardUi() { foreach (var element in _registerUiElements.Values) { ObjectPooler.Instance.Release(element.gameObject); } _registerUiElements.Clear(); TileMap.ClearAllTiles(); foreach (var pos in CurrentBoard.Positions) { var hex = pos.Point; var cell = BoardManipulationOddR.GetCellCoordinate(hex); TileMap.SetTile(cell, test); } }
private void InitializeGameDataStructures(GameArgs args) { { var localPlayer = args.LocalPlayer; var remotePlayer = args.RemotePlayer; Players = new[] { localPlayer, remotePlayer }; //Create Hands Hands = new IHand[] { new Hand(localPlayer.Seat, args.GameParameters, Dispatcher), new Hand(remotePlayer.Seat, args.GameParameters, Dispatcher) }; //Create Inventories Inventories = new IInventory[] { new Inventory(localPlayer.Seat, Parameters, Dispatcher), new Inventory(remotePlayer.Seat, Parameters, Dispatcher) }; //Create Score Score = new Score(Players, args.GameParameters, args.Dispatcher); } //Create Board Board = new Board <CreatureElement>(args.GameParameters, Dispatcher); //Create Board Manipulation BoardManipulation = new BoardManipulationOddR(args.GameParameters.BoardData); //Create Pool Pool = new Pool <CardPool>(args.GameParameters, Dispatcher); { //Create Library var libData = new Dictionary <SeatType, CardData[]> { { SeatType.Bottom, args.GameParameters.Profiles.localPlayer.libraryData.GetDeck() }, { SeatType.Top, args.GameParameters.Profiles.remotePlayer.libraryData.GetDeck() } }; Library = new Library(libData, Dispatcher); } }
private void OnCreateBoard(IBoard board) { Hide(); _highlights.Clear(); foreach (var p in board.Positions) { var hex = p.Point; var cell = BoardManipulationOddR.GetCellCoordinate(hex); var worldPosition = TileMap.CellToWorld(cell); var highlight = Instantiate(highlightTiles, worldPosition, Quaternion.identity, transform) .GetComponent <UiHoverParticleSystem>(); highlight.name = hex.ToString(); if (!_highlights.ContainsKey(hex)) { _highlights.Add(hex, highlight); } } }
void DrawPositions() { const string uiPosition = "UiPosition_"; var identity = Quaternion.identity; ClearPositions(); _positions = new GameObject[CurrentBoard.Positions.Length]; for (var i = 0; i < CurrentBoard.Positions.Length; i++) { var hex = CurrentBoard.Positions[i].Point; var cell = BoardManipulationOddR.GetCellCoordinate(hex); var worldPosition = tileMap.CellToWorld(cell); var gameObj = Instantiate(textPosition, worldPosition, identity, transform); _positions[i] = gameObj; var tmpText = gameObj.GetComponent <TMP_Text>(); var sPosition = $"x:{hex.q}\ny:{hex.r}\nz:{hex.s}"; // var sPosition = $"x:{cell.x}\ny:{cell.y}"; tmpText.text = sPosition; tmpText.name = uiPosition + sPosition; } }