BigTile GetBigTile(int baseX, int baseY) { //Debug.LogFormat ("Getting Big Tile for {0} {1}", baseX, baseY); foreach (var bt in _bigTiles) { if ((bt.BaseX == baseX) && (bt.BaseY == baseY)) { //Debug.LogFormat ("Found Big tile"); return(bt); } } var newTile = new BigTile(baseX, baseY); //Debug.LogFormat ("made new tile"); // add to the beginning of the list _bigTiles.Insert(0, newTile); // make sure our cache doesn't get out of control while (_bigTiles.Count > CACHE_SIZE) { _bigTiles.RemoveAt(CACHE_SIZE); Debug.LogFormat("Removed big tile from cache"); } return(newTile); }
internal bool CanMove(int mx, int my, MovementDirection direction, out Color outColor) { //Debug.LogFormat ("Checking canmove from {0} {1} in {2}", mx, my, direction); int nx = mx; int ny = my; switch (direction) { case MovementDirection.EAST: nx = mx + 1; break; case MovementDirection.NORTH: ny = my - 1; break; case MovementDirection.WEST: nx = mx - 1; break; case MovementDirection.SOUTH: ny = my + 1; break; } if (CrossesWall(mx, my, nx, ny)) { outColor = new Color(1.0f, 0.0f, 0.0f); return(CanMoveThroughWall(mx, my, nx, ny)); } CalcBase(mx, my, out int mbx, out int mby); BigTile t = GetBigTile(mbx, mby); if (t.CanMove(mx, my, direction)) { outColor = new Color(0, 0, 0); return(true); } outColor = new Color(0, 1, 0); return(false); }