Exemple #1
0
 private void OnTriggerEnter(Collider other)
 {
     if (!other.tag.Equals("water"))
     {
         MapTile m = map.GetTileBelow(transform.position);
         if (m != null)
         {
             m.AddWater();
         }
         Destroy(transform.parent.gameObject);
     }
 }
    void FillTank()
    {
        MapTile tileBelow = map.GetTileBelow(transform.position);

        if (tileBelow == null || tileBelow.tileType == MapTile.TileType.water)
        {
            if (transform.position.y > 10f)
            {
                transform.Translate(new Vector3(0f, -1f, 0f));
            }
            waterInTank += fillRate * Time.deltaTime;
            if (waterInTank > waterCapacity)
            {
                waterInTank = waterCapacity;
            }
        }
        else if (transform.position.y < 40f)
        {
            transform.Translate(new Vector3(0f, 1f, 0f));
        }
    }