Пример #1
0
    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);
    }
    /// <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);
        }
    }