Beispiel #1
0
    private void OnSwipe(float angle)
    {
        if (!Parameters.Parameters.Instance.swipeControl)
        {
            return;
        }
        TileBase rootTile   = GetRootTile();
        float    bestDot    = float.MinValue;
        TileBase bestTarget = null;

        for (int targetIdx = 0; targetIdx < clickableTiles.Count; ++targetIdx)
        {
            TileBase potentialTarget = clickableTiles[targetIdx];
            if (potentialTarget == null)
            {
                continue;
            }

            float neighborAngle = rootTile.NeighborToAngle(potentialTarget);
            float dot           = Vector3.Dot(Quaternion.AngleAxis(neighborAngle, Vector3.forward) * Vector3.up, Quaternion.AngleAxis(angle, Vector3.forward) * Vector3.up);

            if (dot > bestDot)
            {
                bestDot    = dot;
                bestTarget = potentialTarget;
            }
        }

        if (bestTarget != null)
        {
            QueueTile(bestTarget);
        }
    }