Beispiel #1
0
    private static HexNodeMarker CreateMarker(HexNodeType nodeType)
    {
        HexNodeMarker node = new HexNodeMarker();

        node.nodeType = nodeType;
        MARKERS.Add(node);
        return(node);
    }
Beispiel #2
0
 private void CreateMarkerList()
 {
     for (int i = 0; i < HexNodeMarker.MARKERS.Count; i++)
     {
         HexNodeMarker marker = HexNodeMarker.MARKERS[i];
         CreateNodeMarker(marker, i);
     }
 }
Beispiel #3
0
 public void SelectMarker(HexNodeMarker marker)
 {
     if (selectMarker == marker)
     {
         return;
     }
     selectMarker = marker;
     //SetMarker(selectMarker);
 }
Beispiel #4
0
    /// <summary>
    /// 查询路线
    /// </summary>
    /// <param name="tryNode"></param>
    /// <param name="tryMarker"></param>
    /// <returns></returns>
    public int QueryRoute(HexNode tryNode = null, HexNodeMarker tryMarker = null)
    {
        HexNodeMarker backupMarker = null;

        if (tryNode != null && tryMarker != null)
        {
            backupMarker   = tryNode.marker;
            tryNode.marker = tryMarker;
        }

        List <HexNode> startNodes = GetNodesByType(HexNodeType.ORIGIN);

        if (startNodes.Count < 1)
        {
            if (tryNode != null && backupMarker != null)
            {
                tryNode.marker = backupMarker;
            }
            return(int.MaxValue);
        }

        endNode = null;
        List <HexNode> endNodes = GetNodesByType(HexNodeType.END);

        if (endNodes.Count > 1)
        {//终点不可以大于一个
            if (tryNode != null && backupMarker != null)
            {
                tryNode.marker = backupMarker;
            }
            return(0);
        }
        else if (endNodes.Count == 1)
        {
            endNode = endNodes[0];
        }

        allStep = GetSteps();
        Reset();
        routes = new List <List <HexNode> >();
        for (int i = 0; i < startNodes.Count; i++)
        {
            HexNode startNode = startNodes[i];
            RecursiveRoute(startNode);
        }

        if (tryNode != null && backupMarker != null)
        {
            tryNode.marker = backupMarker;
        }
        rating = (allStep + 1) * (allStep + 1) / (routes.Count + 1);
        return(routes.Count);
    }
Beispiel #5
0
    private void CreateNodeMarker(HexNodeMarker marker, int index)
    {
        HexNodeMarkerUI nodeMarker = prefabMarker;

        if (marker.nodeType > HexNodeType.NONE)
        {
            nodeMarker = Instantiate <HexNodeMarkerUI>(prefabMarker);
            nodeMarker.transform.SetParent(prefabMarker.transform.parent, false);
        }
        Vector2 pos = markerPoss[index];

        GroundView.SetGridPos(nodeMarker.transform, (int)pos.x, (int)pos.y);
        nodeMarker.InitData(marker);
    }
Beispiel #6
0
 private void SetMarker(HexNodeMarker marker)
 {
     if (selectNode != null && marker != null)
     {
         int routes = crtQuest.grid.QueryRoute(selectNode, marker);
         if (routes < 1)
         {
             GameEvent.PopTip(ColorUtil.ColorString(Color.red, "×"));
         }
         else
         {
             selectNode.marker = marker;
             if (updateNodeEvent != null)
             {
                 crtQuest.needSave = true;
                 updateNodeEvent(selectNode);
             }
         }
     }
 }
Beispiel #7
0
    public void InitData(HexNodeMarker _data)
    {
        data = _data;
        UIManager.Instance.SetImage(icon, data.icon);
        switch (data.nodeType)
        {
        case HexNodeType.NONE:
            break;

        case HexNodeType.ORIGIN:
            icon.color = Color.green;
            break;

        case HexNodeType.END:
            icon.color = Color.yellow;
            break;

        case HexNodeType.NORM:
            icon.color = Color.gray;
            break;

        case HexNodeType.ORDER:
            ShowTip(((int)data.order).ToString());
            icon.color = Color.gray;
            break;

        case HexNodeType.FREQUENCY:
            icon.color = Color.gray;
            break;

        case HexNodeType.BRIDGE:
            icon.color = Color.gray;
            break;

        default:
            ShowTip(data.nodeType.ToString());
            break;
        }
    }
Beispiel #8
0
 public void Init()
 {
     HexNodeMarker.CreateMarkers();
 }