예제 #1
0
    // Detatches the object and places it on the board.
    private void detachToBoard(Hand hand)
    {
        // EARLY OUT! //
        if (_snapper == null)
        {
            Debug.LogWarning(string.Format("Cannot use figurine, missing data. Snapper:{0}", _snapper));
            return;
        }

        var gridPoint       = _snapper.GridPoint;
        var snappedPosition = TerritoryData.GetCenter(gridPoint.X, gridPoint.Y);

        // Send the figurine down to its spawn position.
        var pos = transform.position;

        SetInteractable(false);

        StartCoroutine(dropFigurineToSpawn(pos, snappedPosition, hand));
    }
예제 #2
0
    // Triggered when the grid square changes that the figurine is over.
    // Updates the visual/haptic components of placement snapping.
    private void onFigurineGridSquareChanged()
    {
        if (_snapper != null)
        {
            bool isHighlightActive = _snapper.IsOverBoard && isPlaceableTerritory(_snapper.WorldPosition);
            SL.Get <GridSquareHighlight>().gameObject.SetActive(isHighlightActive);

            if (isHighlightActive)
            {
                var center     = TerritoryData.GetCenter(_snapper.GridPoint.X, _snapper.GridPoint.Y);
                var snappedPos = new Vector3(center.x, 1f, center.z);
                SL.Get <GridSquareHighlight>().transform.position = snappedPos;

                // Trigger haptic pulse when the grid square changes.
                Hand hand = GetComponentInParent <Hand>();
                if (hand && hand.controller != null)
                {
                    hand.controller.TriggerHapticPulse(HapticGridSquareChange);
                }
            }
        }
    }