Ejemplo n.º 1
0
    void PlaceArrow(HexDirection direction, HexCell cell)
    {
        HexCell neighbor = cell.GetNeighbor(direction);

        if (neighbor == null || neighbor.IsUnderwater)
        {
            return;
        }
        EdgeVertices e = new EdgeVertices(
            neighbor.Position + HexMetrics.GetFirstArrowCorner(direction.Opposite()),
            neighbor.Position + HexMetrics.GetSecondArrowCorner(direction.Opposite()));

        Vector3 center = new Vector3(e.v3.x, e.v3.z, -e.v3.y - 0.1f);

        Toggle instance = Instantiate(arrowPrefab);

        instance.onValueChanged.AddListener(delegate { migrationMenu.Open(neighbor, cell); });

        instance.transform.localPosition = HexMetrics.PerturbPerspective(center);
        instance.transform.localRotation = Quaternion.Euler(0f, 0f, 60f - 60f * (float)direction);
        instance.transform.SetParent(arrowContainer, false);
    }