private void Tiling() { if (Input.GetMouseButtonUp(1)) { selectionOrientation++; if ((int)selectionOrientation == orientationLength) { selectionOrientation = 0; } } var ray = mainCamera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out var hit)) { map.SetTilesOutLine(hit.point, colors[current_player_id], selectionOrientation, true); if (Input.GetMouseButtonUp(0) && map.outlinedTiles.Count >= 2) { marakeshServer.SetLastCarpetPosition(map.outlinedTiles.Select(t => Array.IndexOf(map.tiles, t)).ToList()); map.SetTilesColor(hit.point, colors[current_player_id]); map.SetTilesOutLine(hit.point, colors[current_player_id], selectionOrientation, false); GoToNextGameState(); marakeshServer.EndTurn(); } } }
public void GetSelectedTiles(Vector3 worldPos, SelectionOrientation orientation) { Tile tile_0, tile_1; switch (orientation) { case SelectionOrientation.Horizontal: tile_0 = GetTileByPosition(worldPos + Vector3.right * Tile.size / 2); tile_1 = GetTileByPosition(worldPos - Vector3.right * Tile.size / 2); if (neighbourTiles.Contains(tile_0) || neighbourTiles.Contains(tile_1)) { outlinedTiles.Add(tile_0); outlinedTiles.Add(tile_1); } break; case SelectionOrientation.Vertival: tile_0 = GetTileByPosition(worldPos + Vector3.forward * Tile.size / 2); tile_1 = GetTileByPosition(worldPos - Vector3.forward * Tile.size / 2); if (neighbourTiles.Contains(tile_0) || neighbourTiles.Contains(tile_1)) { outlinedTiles.Add(tile_0); outlinedTiles.Add(tile_1); } break; } }
public void SetTilesOutLine(Vector3 worldPos, Color color, SelectionOrientation orientation, bool activate) { outlinedTiles.Clear(); if (!activate) { return; } GetSelectedTiles(worldPos, orientation); }
void Start() { marakeshServer = new FakeMarakeshServer(playersCount); my_player_id = marakeshServer.GetMyPlayerID(); marakeshServer.activePlayerChanged += delegate { current_player_id = marakeshServer.GetActivePlayerId(); }; mainCamera = Camera.main; map = new Map(); selectionOrientation = SelectionOrientation.Horizontal; orientationLength = System.Enum.GetValues(typeof(SelectionOrientation)).Length; marakeshModelController = new MarakeshModelController(marakeshModel, map.GetTile(new Vector2Int(map.size / 2, map.size / 2))); currentState = GameState.Move; gameStateLength = System.Enum.GetValues(typeof(GameState)).Length; marakeshModelController.move_finished += GoToNextGameState; }
void Start() { var serverCancellationTokenSource = new CancellationTokenSource(6000); marakeshServer = new MarakeshServer(); //TODO: moe this to UI button Task.Run(() => { marakeshServer.StartServer(serverCancellationTokenSource.Token); Debug.Log($" marakeshServer.StartServer "); }); marakeshClient = new MarakeshServerClient(marakeshServer.IpAddress); var clientCancellationTokenSource = new CancellationTokenSource(3000); //TODO: moe this to UI button Task.Run(async() => { var playerCount = await marakeshClient.GetPlayerCount(clientCancellationTokenSource.Token); Debug.Log($" playerCount {playerCount}"); }); //TODO: catch exceptions mainCamera = Camera.main; map = new Map(); selectionOrientation = SelectionOrientation.Horizontal; orientationLength = System.Enum.GetValues(typeof(SelectionOrientation)).Length; marakeshModelController = new MarakeshModelController(marakeshModel, map.GetTile(new Vector2Int(map.size / 2, map.size / 2))); currentState = GameState.Move; gameStateLength = System.Enum.GetValues(typeof(GameState)).Length; marakeshModelController.move_finished += GoToNextGameState; }