void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.CompareTag("Terrain")) { TilePos tilePos = PathfindingMap.WorldToTilePos(other.transform.position); int tileId = map.GetTile(tilePos.x, tilePos.y).blockTypeId; if (tileId == 3) // collectible { Destroy(other.gameObject); collectibleSpawner.SpawnCollectible(); bar.PickupCollectible(); } else if (tileId == 2) // throttle { Throttle(); } else if (tileId == 4 && cash > 0) //paywall { map.RemoveObstacle(tilePos.x, tilePos.y); cash -= 1; //temp UpdateCashText(); Destroy(other.gameObject); } } }
public void PlaceBlock(int id) { TilePos tilePos = PathfindingMap.WorldToTilePos(spawns[id][0].pos); spawns[id].RemoveAt(0); map.AddObstacle(tilePos.x, tilePos.y, id); }
bool TileValid(Vector2Int tile) { if (PathfindingMap.CanWalkOnTile(new TilePos(tile.x, tile.y)) && (map.GetTile(tile.x, tile.y).blockTypeId != 4 || cash > 0)) { return(true); } else { return(false); } }
void Awake() { //load resources //mapTexture = Resources.Load (mapName) as Texture2D; //backgroundMat = Resources.Load (backgroundMatName) as Material; path = FindObjectOfType <PathfindingMap>(); blocker = FindObjectOfType <SpawnManager>(); player = FindObjectOfType <PlayerController>(); blocker.Init(this); bitmaskSprites = LoadBitmaskSprites("Border"); LoadColorDictionary(); }
private void Awake() { Instance = this; }