Beispiel #1
0
 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);
         }
     }
 }
Beispiel #2
0
    public void PlaceBlock(int id)
    {
        TilePos tilePos = PathfindingMap.WorldToTilePos(spawns[id][0].pos);

        spawns[id].RemoveAt(0);

        map.AddObstacle(tilePos.x, tilePos.y, id);
    }