Пример #1
0
      private void DisplayTile()
      {
          if (isVoid || !hitSomething || ground.collider.CompareTag("Wall"))
          {
              return;
          }
          if (notFree && RecupTile())
          {
              return;
          }


          if (inventory[index].TilesList.Count > 0)
          {
              currentTile = Instantiate(currentTile, ground.collider.gameObject.transform.position + Vector3.up * 1.5f, inventory[index].Orientation);
              Tween.LocalPosition(currentTile.transform, ground.collider.gameObject.transform.position + Vector3.up / 2, 0.2f, 0, Tween.EaseIn);
              currentTile.layer = 0;
              currentTile.gameObject.GetComponent <ObjectsInstanciateScript>().Init();
              currentTile.transform.GetChild(0).gameObject.layer = 0;
              inventory[index].TilesList.RemoveAt(0);

              SetActiveFalseAllPreview();
              OnUpdateInventory?.Invoke(inventory[index].TilesList.Count);
              if (inventory[index].TilesList.Count == 0)
              {
                  OnInventoryEmpty?.Invoke(index);
                  CheckTabsCount();

                  index = Mathf.Clamp(index, 0, inventory.Count - 1);
              }
          }
      }
Пример #2
0
      private bool RecupTile()
      {
          Inventory lInventory;

          for (int i = inventory.Count - 1; i >= 0; i--)
          {
              lInventory = inventory[i];
              if (tileOnground.collider.CompareTag(lInventory.Tile.tag) && tileOnground.transform.rotation == lInventory.Orientation)
              {
                  recupTileOnground = tileOnground;
                  recupTileOnground.collider.gameObject.layer = 2;


                  lInventory.TilesList.Add(lInventory.Tile);
                  Tween.LocalPosition(recupTileOnground.transform, recupTileOnground.transform.position + Vector3.up / 2, 0.2f, 0, Tween.EaseIn);
                  tileScaleTween = Tween.LocalScale(recupTileOnground.transform, Vector3.zero, 0.2f, 0.2f, Tween.EaseIn, Tween.LoopType.None, null, () => { testPreview(index); });


                  // CheckTabsCount();
                  index = inventory.IndexOf(lInventory);
                  OnUpdateInventory?.Invoke(inventory[index].TilesList.Count);
                  OnIndexChange?.Invoke(index);

                  currentTile = lInventory.TilesList[0];
                  SetActiveFalseAllPreview();
                  if (allListEmpty)
                  {
                      allListEmpty = false;
                  }
                  return(true);
              }
              if (tileOnground.collider.CompareTag(targetTag) || tileOnground.collider.CompareTag(spawnTag) || tileOnground.collider.CompareTag("Wall") || tileOnground.collider.CompareTag("Teleport"))
              {
                  return(true);
              }
          }

          return(false);
      }
Пример #3
0
 /// <summary>
 /// Update all Inventory elements
 /// </summary>
 public virtual void UpdateInventory()
 {
     OnUpdateInventory.Invoke();
 }