public void PlaceTile(TileInteger tileType, Vector3Int position)
 {
     if (grid.CreateTile(tileType, position))
     {
         Tile            tile            = Instantiate(tileTypes.GetPrefab(tileType), position, Quaternion.identity);
         GameObject      tileGO          = tile.gameObject;
         MonoBehaviour[] behaviorsOnTile = tileGO.GetComponents <MonoBehaviour>();
         for (int i = 0; i < behaviorsOnTile.Length; i++)
         {
             Destroy(behaviorsOnTile[i]);
         }
         Joint[] joints = tileGO.GetComponents <Joint>();
         for (int i = 0; i < joints.Length; i++)
         {
             Destroy(joints[i]);
         }
         Rigidbody rb;
         if (tileGO.TryGetComponent <Rigidbody>(out rb))
         {
             Destroy(rb);
         }
     }
     else
     {
         RangeExceeded.Invoke();
     }
 }
Exemple #2
0
        public void CreateFixedTile(Vector3Int position)
        {
            if (grid.PositionIsFilled(position))
            {
                return;
            }
            Tile fixedTile = tileTypes.GetPrefab(TileInteger.StoneTile);

            CreateTile(fixedTile, position);
        }