Esempio n. 1
0
        /// <summary>
        /// Ajoute un type
        /// </summary>
        /// <param name="type">Type à ajouter</param>
        public void AddType(Type type)
        {
            //vérifie que le type n'est pas une interface ou une classe abstraite
            if (!type.IsClass || type.IsInterface || type.IsAbstract)
            {
                return;
            }
            //Vérifie que le type dérive bien de la classe de base
            if (!IsBasedOn(type, BaseType))
            {
                return;
            }
            //Récupère la valeur clef (nom de la classe si le nom est null)
            string key = type.FullName;

            try {
                Type oldType = this[key];
                if (oldType != null)
                {
                    if (OnIndexChange != null)
                    {
                        OnIndexChange.Invoke(this, new IndexChangeEventArg(IndexChangeEventArg.ChangeType.Created, oldType));
                    }
                }
            } catch {
            }

            //inscrit la classe dans la liste
            creatable[key] = type;

            if (OnIndexChange != null)
            {
                OnIndexChange.Invoke(this, new IndexChangeEventArg(IndexChangeEventArg.ChangeType.Created, type));
            }
        }
Esempio n. 2
0
        public void RaiseNotifications(IndexChange indexChange)
        {
            OnIndexChange?.Invoke(indexChange);

            foreach (var connection in Connections)
            {
                connection.Value.SendIndexChanges(indexChange);
            }
        }
Esempio n. 3
0
 private void CheckTabsCount()
 {
     for (int i = inventory.Count - 1; i >= 0; i--)
     {
         if (inventory[i].TilesList.Count != 0)
         {
             index = i;
             OnIndexChange?.Invoke(index);
             break;
         }
     }
     if (inventory[index].TilesList.Count == 0)
     {
         allListEmpty = true;
         // OnInventoryEmpty?.Invoke(index);
     }
     else
     {
         allListEmpty = false;
     }
 }
Esempio n. 4
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);
      }
 public void SetOnIndexChange(OnIndexChange onIndexChange)
 {
     this.onIndexChange = onIndexChange;
 }