예제 #1
0
 public void OnDrop(PointerEventData eventData)
 {
     if (eventData.pointerDrag != null)
     {
         if (weapon != null)                                                                                                                                                           //If there is a weapon in this item slot
         {
             weapon.GetComponent <RectTransform>().anchoredPosition = eventData.pointerDrag.GetComponent <DragDrop>().currentItemSlot.GetComponent <RectTransform>().anchoredPosition; //set this items slots weapon's position to new weapons olditem slot position
             weapon.GetComponent <DragDrop>().currentItemSlot       = eventData.pointerDrag.GetComponent <DragDrop>().currentItemSlot.gameObject;                                      //set this items currentItemSlot to new weapons currentItemSlot
         }
         eventData.pointerDrag.GetComponent <RectTransform>().anchoredPosition = GetComponent <RectTransform>().anchoredPosition;                                                      //set new weapons position
         eventData.pointerDrag.GetComponent <DragDrop>().currentItemSlot       = gameObject;                                                                                           //set new weapons currentItemSlot
         eventData.pointerDrag.GetComponent <CanvasGroup>().blocksRaycasts     = false;
         weapon = eventData.pointerDrag.gameObject;                                                                                                                                    //set weapon to new weapon
         if (equipSlot)
         {
             playerHandler.SwitchWeapon(eventData.pointerDrag.GetComponent <DragDrop>().weaponIndex);//calls players switch weapon function with new weapons weaponIndex
         }
     }
 }
예제 #2
0
파일: Gun.cs 프로젝트: tek-f/MyFPS
 /// <summary>
 /// Weapon swap funciton for the gun.
 /// </summary>
 public void TriggerWeaponSwap()
 {
     changing = false;
     player.SwitchWeapon(player.LastWeapon);
 }