void OnPlayerPickup(MessageTypes.Pickup m) { // drop currently held item, if any if (gameState.heldObjects[m.slotIndex] != null) { gameState.heldObjects[m.slotIndex].SendMessage("OnDrop"); gameState.heldObjects[m.slotIndex] = null; return; } GameObject target = null; foreach (var item in m.candidates) { bool isAlreadyHeld = System.Array.Exists(gameState.heldObjects, obj => obj == item); if (isAlreadyHeld) { continue; } else { target = item; break; } } if (!target) { return; } target.SendMessage("OnPickup", m); gameState.heldObjects[m.slotIndex] = target; // the powerspherecontroller (inner) }
public void OnPickup(MessageTypes.Pickup m) { // To GoalTriggerReactor on parent rootObject.SendMessage("OnPickup", new MessageTypes.PickupComplete { picker = m.picker, picked = gameObject, slotIndex = m.slotIndex, }); }
private void Pickup(int slotIndex) { Collider[] items = Physics.OverlapSphere(transform.position, baseController.radius * 2f, pickupLayerMask); if (items.Length <= 0) { return; } var pickupMessage = new MessageTypes.Pickup { candidates = items.Select(item => item.gameObject).ToArray(), picker = gameObject, slotIndex = slotIndex, }; GameLogicController.PlayerPick.Invoke(pickupMessage); }