private IEnumerator WaitAndTryNewWall(int posX, int posY, int startPosX, int startPosY, bool isVertical) { var timeToWait = (new Vector2(posX - startPosX, posY - startPosY)).magnitude / GlobalConstants.Wall.Speed; LoggerSystem.Log("Schedule new wall creation for " + timeToWait + "s from now!"); yield return(new WaitForSeconds(timeToWait)); string errorMessage; if (_tileMap.Map.AddWall(posX, posY, isVertical, out errorMessage)) { if (EventAddWallSuccess == null) { yield break; } EventAddWallSuccess(posX, posY, isVertical); } else { if (EventAddWallFail == null) { yield break; } EventAddWallFail(errorMessage); } }
// Use this for initialization void Start() { _tileMap = (TileMap)FindObjectOfType(typeof(TileMap)); if (_tileMap == null) { LoggerSystem.Log("Unable to Find TileMap"); } }
public override void OnStartLocalPlayer() { LoggerSystem.Log("New Player Connected"); _rigidbody = GetComponent <Rigidbody>(); _tileMap = FindObjectOfType <TileMap>(); if (_tileMap == null) { LoggerSystem.Log("Unable to Find TileMaps"); } FindObjectOfType <TileMapMouse>().RegisterLocalPlayer(this); }
void Start() { _tileMapNetwork = (TileMapNetwork)FindObjectOfType(typeof(TileMapNetwork)); if (_tileMapNetwork == null) { LoggerSystem.Log("Unable to Find TileMapNetwork"); return; } _tileMapNetwork.EventAddWallSuccess += SpawnWall; _tileMap = (TileMap)FindObjectOfType(typeof(TileMap)); if (_tileMap == null) { LoggerSystem.Log("Unable to Find TileMapMouse"); return; } //TODO: Something better for global constants. }
/// <summary> /// Creates a new gridmap: ///################# ///#0.............1# ///#0........1....1# ///#0.............1# ///################# /// </summary> /// <param name="sizeX">The horizontal size of the map</param> /// <param name="sizeZ">the vertical size of the map</param> /// <param name="wallSize">The wall size (if even will be added 1)</param> public GridMap(int sizeX, int sizeZ, int wallSize) { _map = new char[sizeX, sizeZ]; _players = new Dictionary <char, Tuple <int, int> >(); if (wallSize % 2 == 0) { wallSize += 1; LoggerSystem.Log("Added a wrong wall size"); } _wallSize = wallSize; // Harcoding map: for (int i = 0; i < sizeX; i++) { for (int j = 0; j < sizeZ; j++) { if (j == 0 || j == sizeZ - 1) { _map[i, j] = WALL; } else if (i == 1 || i == 0) { _map[i, j] = '0'; } else if (i == sizeX - 2 || i == sizeX - 1) { _map[i, j] = '1'; } else { _map[i, j] = EMPTY; } } } }
public void RegisterLocalPlayer(PlayerController local) { LoggerSystem.Log("Initialized local player info on TileMap"); local.MouseClick += OnPlayerMouseClick; }
public void WallFailDebug(string message) { LoggerSystem.Log(message); }
public void WallSuccessDebug(int posX, int posY, bool isVertical) { LoggerSystem.Log("New wall succeeded at X=" + posX + " Y=" + posY); }
public void MapClickDebug(object sender, MapCreateEventArgs e) { LoggerSystem.Log("New click at X=" + e.WallPos.x + " Y=" + e.WallPos.y); }