private IEnumerator SwapPickups() { //We only need to swap to/from the slots that actually have something equipped bool sourceFinished = !dragSlot.IsEquipped(); bool targetFinished = !currentDropTarget.IsEquipped(); //Lerp the pickup icons between the swapped slot locations while (!sourceFinished || !targetFinished) { if (!sourceFinished) { dragSlot.GetTransform().position = Vector3.MoveTowards(dragSlot.GetTransform().position, currentDropTarget.GetHomeCoords(), Time.deltaTime * swapSpeed); sourceFinished = dragSlot.GetTransform().position.Equals(currentDropTarget.GetHomeCoords()); } if (!targetFinished) { currentDropTarget.GetTransform().position = Vector3.MoveTowards(currentDropTarget.GetTransform().position, dragSlot.GetHomeCoords(), Time.deltaTime * swapSpeed); targetFinished = currentDropTarget.GetTransform().position.Equals(dragSlot.GetHomeCoords()); } yield return(0); } //Remove the highlights that were established as part of the drag dragSlot.RemovePickupHighlight(); currentDropTarget.RemoveSlotHighlight(); //Complete the actual swap of the pickups dragSlot.SwapPickup(currentDropTarget); //The slots that have pickups equipped may have changed so recalculate which ones need to be visible ResetVisibilityOnAllSlots(); //End this drag dragSlot = null; currentDropTarget = null; }
private PickupSlot FindBestAvailableSlot() { PickupSlot slot = null; if (rightHander) { if (!rightSlot.IsEquipped()) { slot = rightSlot; } else if (!leftSlot.IsEquipped()) { slot = leftSlot; } else if (upperRightSlot != null && !upperRightSlot.IsEquipped()) { slot = upperRightSlot; } else if (upperLeftSlot != null && !upperLeftSlot.IsEquipped()) { slot = upperLeftSlot; } } else { if (!leftSlot.IsEquipped()) { slot = leftSlot; } else if (!rightSlot.IsEquipped()) { slot = rightSlot; } else if (upperLeftSlot != null && !upperLeftSlot.IsEquipped()) { slot = upperLeftSlot; } else if (upperRightSlot != null && !upperRightSlot.IsEquipped()) { slot = upperRightSlot; } } return(slot); }