private void CreateRingAndAttachToPin(Transform ring) { PinMonitor pinMonitor = StartingPin.GetComponent <PinMonitor>(); Vector3 ringPosition = pinMonitor.GetAvailableEmptySlotPosition(); Transform instance = Instantiate(ring, ringPosition, Quaternion.identity); instance.parent = transform; pinMonitor.AddRing(instance.gameObject); }
private void MoveToPositionOnPinFromAirHandler(GameObject ring) { ring.GetComponent <RingMonitor>().onMoveComplete -= MoveToPositionOnPinFromAirHandler; PinMonitor pinMonitor = _ActivePinForAirRing.GetComponent <PinMonitor>(); pinMonitor.AddRing(ring); ring.SendMessage("SetCurrentStateNeutral"); _ActiveRingInTheAir = null; _RingMovementController.enabled = true; }
/// <summary> /// Ring "Touch End" handler /// </summary> /// <param name="ring">Ring to handle</param> public void RingDropHandler(GameObject ring) { _RingMovementController.StopObjectMovementHandling(); if (IsTopRingOnPinSelected(ring)) { Transform holderPin = _PinController.GetPinIfRingOnTop(ring); ring.SendMessage("SetCurrentStateNeutral"); _RingMovementController.enabled = false; PinMonitor pinMonitor = holderPin.GetComponent <PinMonitor>(); RingMonitor ringMonitor = ring.GetComponent <RingMonitor>(); Vector3 topRingSlotPosition = pinMonitor.GetCurrentTopRingSlotPosition(); ringMonitor.onMoveComplete += MoveToPositionOnPinHandler; ringMonitor.MoveToPosition(topRingSlotPosition, RingMovementTime / ringMonitor.GetRingSize(), true); } else { ring.SendMessage("SetCurrentStateSurprised"); } }
/// <summary> /// Pin collider touched handler /// </summary> /// <param name="activeRing">Active ring</param> /// <param name="selectedPin">Collided pin</param> public void PinSelectHandler(GameObject activeRing, Transform selectedPin) { _PinController.enabled = false; _RingMovementController.enabled = false; _RingMovementController.StopObjectMovementHandling(); PinMonitor pinMonitor = selectedPin.GetComponent <PinMonitor>(); RingMonitor ringMonitor = activeRing.GetComponent <RingMonitor>(); Vector3 moveToPosition = pinMonitor.GetAvailableEmptySlotPosition(); if (pinMonitor.CanAddRing(activeRing)) { activeRing.SendMessage("SetCurrentStateActive"); _ActivePinForAirRing = selectedPin; activeRing.GetComponent <RingMonitor>().onMoveComplete += MoveToPositionOnPinFromAirHandler; activeRing.GetComponent <RingMonitor>().MoveToPosition(moveToPosition, RingMovementTime / ringMonitor.GetRingSize(), true); } else { activeRing.SendMessage("SetCurrentStateSad"); moveToPosition = pinMonitor.GetOverPinPosition(); activeRing.GetComponent <RingMonitor>().onMoveComplete += MoveToPositionOverPinHandler; activeRing.GetComponent <RingMonitor>().MoveToPosition(moveToPosition, RingMovementTime, false); } }