예제 #1
0
 //implémentation de l'interface IPointerClickHandler
 public void OnPointerClick(PointerEventData eventData)
 {
     if (eventData.button == PointerEventData.InputButton.Left)
     {
         if (Inventory.InventoryScr.TheSlot != null && MoveManager.TheMoveManager.Itembougeable != null && MoveManager.TheMoveManager.Itembougeable is BagItem)
         {
             if (Bag != null)
             {
                 Inventory.InventoryScr.SwapBags(Bag, MoveManager.TheMoveManager.Itembougeable as BagItem);
             }
             else
             {
                 BagItem b = (BagItem)MoveManager.TheMoveManager.Itembougeable;
                 b.BagButton = this;
                 b.Use();
                 Bag = b;
                 MoveManager.TheMoveManager.Drop();
                 Inventory.InventoryScr.TheSlot = null;
             }
         }
         //si on clique en appuyant sur caps lock, on prend le sac
         else if (Input.GetKey(KeyCode.CapsLock))
         {
             MoveManager.TheMoveManager.PickBougeable(Bag);
         }
         //sinon ou l'ouvre/ferme
         else if (bagitem != null)
         {
             bagitem.BagScr.OpenOrClose();
         }
     }
 }
예제 #2
0
파일: Inventory.cs 프로젝트: Alexanoz/Odyh
    private void Awake()
    {
        BagItem bag = (BagItem)Instantiate(items[0]);

        bag.Init(20);
        bag.Use();
    }
예제 #3
0
파일: Inventory.cs 프로젝트: Alexanoz/Odyh
    public void SwapBags(BagItem oldB, BagItem newB)
    {
        int newSlotCount = (TotalSlotNb - oldB.Slotnumber) + newB.Slotnumber;

        if (newSlotCount - FullSlotNb >= 0)
        {
            List <Item> oldItems = oldB.BagScr.GetItems();
            Delete_bag_inventory(oldB);

            newB.BagButton = oldB.BagButton;
            newB.Use();

            foreach (var item in oldItems)
            {
                if (item != newB)
                {
                    AddInventoryItem(item);
                }
            }
            AddInventoryItem(oldB);
            MoveManager.TheMoveManager.Drop();
            InventoryScr.TheSlot = null;
        }
    }
예제 #4
0
파일: Inventory.cs 프로젝트: Alexanoz/Odyh
    // Ceci est uniquement réservé au test
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.R))
        {
            BagItem bag = (BagItem)Instantiate(items[0]);
            bag.Init(20);
            bag.Use();
        }

        if (Input.GetKeyDown(KeyCode.T))
        {
            BagItem bag = (BagItem)Instantiate(items[0]);
            bag.Init(20);
            AddInventoryItem(bag);
        }

        if (Input.GetKeyDown(KeyCode.P))
        {
            HealthPotionItem pot = (HealthPotionItem)Instantiate(items[1]);

            AddInventoryItem(pot);
        }

        if (Input.GetKeyDown(KeyCode.F))
        {
            Flèche flèche = (Flèche)Instantiate(items[2]);

            AddInventoryItem(flèche);
        }

        if (Input.GetKeyDown(KeyCode.H))
        {
            AddInventoryItem((Equipement)Instantiate(items[3]));
            AddInventoryItem((Equipement)Instantiate(items[4]));
            AddInventoryItem((Equipement)Instantiate(items[5]));
            AddInventoryItem((Equipement)Instantiate(items[6]));
            AddInventoryItem((Equipement)Instantiate(items[7]));
            AddInventoryItem((Equipement)Instantiate(items[8]));
            AddInventoryItem((Equipement)Instantiate(items[9]));
            AddInventoryItem((Equipement)Instantiate(items[10]));
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            Inventory.InventoryScr.OpenOrClose();
        }

        if (Input.GetKeyDown(KeyCode.M))
        {
            Key key = (Key)Instantiate(items[12]);

            AddInventoryItem(key);
        }

        if (Input.GetKeyDown(KeyCode.V))
        {
            Bombes bombes = (Bombes)Instantiate(items[11]);

            AddInventoryItem(bombes);
        }

        // Test si l'inventaire est ouvert ou non
        if (bags.Count != 0)
        {
            if (!bags[0].BagScr.Open)
            {
                player.InInventory = false;
            }
            else
            {
                player.InInventory = true;
            }
        }
    }