Ejemplo n.º 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);
         }
     }
 }
Ejemplo n.º 2
0
 private void HandleCollectibles()
 {
     distanceMovedSinceLastCollectible = Vector2.Distance(transform.position, lastCollectiblePoint.transform.position);
     if (distanceMovedSinceLastCollectible > collectibleSpawnDifference)
     {
         collectibleSpawner.SpawnCollectible();
         Vector3 lastPos = lastCollectiblePoint.transform.position;
         lastCollectiblePoint.transform.position = new Vector3(transform.position.x, lastPos.y, lastPos.z);
     }
 }