示例#1
0
 public void Open(AmmoContainer container)
 {
     if (container.ammo.Count != 0)
     {
         foreach (KeyValuePair <AmmoType, int> pair in container.ammo)
         {
             if (pair.Value > 0)
             {
                 ammoInSlots.Add(Instantiate(HangarData.instance.ammunitionPrefabs[(int)pair.Key], transform.GetChild(lastVacantSlot)));
                 ammoInSlots.Last().GetComponent <Item>().Init();
                 ammoInSlots.Last().GetComponent <AmmoClip>().Quantity = pair.Value;
                 lastVacantSlot++;
             }
         }
     }
     for (int i = 0; i < transform.childCount; i++)
     {
         if (transform.GetChild(i).childCount > 0)
         {
             transform.GetComponentsInChildren <Slot>()[i].isVacant = false;
         }
         else
         {
             transform.GetComponentsInChildren <Slot>()[i].isVacant = true;
         }
     }
     HangarData.instance.properties.SetActive(true);
 }
示例#2
0
        public void OnPointerDown(PointerEventData eventData)
        {
            if (Input.GetKey(KeyCode.Mouse0))
            {
                HangarData.instance.description.SetActive(false);
            }

            if (Input.GetKey(KeyCode.Mouse1) && transform.parent.GetComponent <Slot>().slotType == SlotType.HardwarePosition)
            {
                if (hw.GetComponent <AmmoContainer>())
                {
                    activeContainer = hw.GetComponent <AmmoContainer>();
                    HangarData.instance.properties.GetComponentInChildren <AmmoSlots>().Open(hw.GetComponent <AmmoContainer>());
                }
            }
        }