コード例 #1
0
	void OnGUI()
	{
		GUILayout.Label("Layers", EditorStyles.boldLabel);
		tileLayer = EditorGUILayout.LayerField("Tiles Layer", tileLayer);
		oneUnitPerTileOnly = EditorGUILayout.Toggle("One Unit Per Tile Only", oneUnitPerTileOnly);
		oneUnitExceptionAllowMoveOver = EditorGUILayout.Toggle("One Unit Exception", oneUnitExceptionAllowMoveOver);

		EditorGUILayout.Space();
		tilesLayout = EditorGUILayout.Popup("Tiles Layout", tilesLayout, MapNavEditor.TilesLayoutStrings);

		EditorGUILayout.Space();
		tileSpacing = EditorGUILayout.FloatField("Tile Spacing", tileSpacing);
		tileSize = EditorGUILayout.FloatField("Tile Size", tileSize);

		EditorGUILayout.Space();
		GUILayout.Label("Create Tile Nodes", EditorStyles.boldLabel);
		GUILayout.Label("Ignore the following if you don't want to create tiles now", EditorStyles.label);
		tileNodeFab = (GameObject)EditorGUILayout.ObjectField("TileNode Prefab", tileNodeFab, typeof(GameObject), false);
		initialTileTypeMask = (TileNode.TileType)EditorGUILayout.EnumMaskField("Initial Tile Mask", initialTileTypeMask);
		EditorGUILayout.BeginHorizontal();
			GUILayout.Label("Width x Length: ", EditorStyles.label);
			edNewNodesXY[0] = EditorGUILayout.IntField(edNewNodesXY[0]);
			edNewNodesXY[1] = EditorGUILayout.IntField(edNewNodesXY[1]);
		EditorGUILayout.EndHorizontal();

		EditorGUILayout.Space();
		if (GUILayout.Button("Create MapNav"))
		{
			CreateMapNav();
			Close();
		}
	}
コード例 #2
0
	public override void OnInspectorGUI()
	{
		EditorGUILayout.Space();
		serializedObject.Update();

		// show node id only when one node selected
		if (!idx.hasMultipleDifferentValues)
		{
			EditorGUILayout.PropertyField(idx, new GUIContent("Unique ID"));
		}

		// can edit multiple nodes' masks at same time
		if (idx.hasMultipleDifferentValues)
		{
			int new_value = (int)((TileNode.TileType)EditorGUILayout.EnumMaskField("Tile Type Mask", (TileNode.TileType)v_tileTypeMask));
			if (new_value != v_tileTypeMask)
			{	// only update masks on nodes if value actually changed, else this will mess up the values if user just selected a few nodes without doing anything else
				v_tileTypeMask = new_value;
				tileTypeMask.intValue = new_value;
				serializedObject.ApplyModifiedProperties();
			}

			// show the Link OnOff Switch button
			GUILayout.Label("Link between selected: ", EditorStyles.boldLabel);
			EditorGUILayout.BeginHorizontal();
			if (GUILayout.Button("Force Link")) CreateLinkBetweenSelected();
			EditorGUILayout.EndHorizontal();

			// show the Link OnOff Switch button
			GUILayout.Label("Set Link between selected: ", EditorStyles.boldLabel);
			types = (TileNode.TileType)EditorGUILayout.EnumMaskField("for Types", types);
			EditorGUILayout.BeginHorizontal();
			if (GUILayout.Button("Off")) SetLinkBetweenSelected(false);
			if (GUILayout.Button("On")) SetLinkBetweenSelected(true);
			EditorGUILayout.EndHorizontal();
		}
		else
		{
			tileTypeMask.intValue = (int)((TileNode.TileType)EditorGUILayout.EnumMaskField("Tile Type Mask", (TileNode.TileType)tileTypeMask.intValue));
			serializedObject.ApplyModifiedProperties();
		}

		EditorGUILayout.Space();
	}
コード例 #3
0
ファイル: MapNavEditor.cs プロジェクト: C4SEM4N/WhatRemains
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        // gizmo related and info fields
        TMNEditorUtil.DrawSpacer();
        folds[4] = EditorGUILayout.Foldout(folds[4], folds[4] ? "" : "Gizmos");
        if (folds[4])
        {
            GUILayout.Label("Gizmos", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(gizmoDrawNodes);
            EditorGUILayout.PropertyField(gizmoDrawLinks);
            EditorGUILayout.PropertyField(gizmoColorCoding);
        }

        // info
        TMNEditorUtil.DrawSpacer();
        folds[5] = EditorGUILayout.Foldout(folds[5], folds[5] ? "" : "Basic Settings & Info" );
        if (folds[5])
        {
            GUILayout.Label("Info", EditorStyles.boldLabel);
            EditorGUILayout.LabelField("MapNav Size: ", nodesCache.arraySize.ToString() + " (" + ((MapNav)target).nodesXCount + "x" + ((MapNav)target).nodesYCount + ")");
            EditorGUILayout.LabelField("Tiles Layout: ", ((MapNav.TilesLayout)tilesLayout.enumValueIndex).ToString());
            EditorGUILayout.LabelField("Tile Spacing: ", tileSpacing.floatValue.ToString());
            EditorGUILayout.LabelField("Tile Size: ", tileSize.floatValue.ToString());

            // basic fields
            EditorGUILayout.Space();
            GUILayout.Label("Basic Settings", EditorStyles.boldLabel);
            tilesLayer.intValue = EditorGUILayout.LayerField("Tiles Layer", tilesLayer.intValue);
            EditorGUILayout.PropertyField(oneUnitPerTileOnly);
            oneUnitExceptionAllowMoveOver.boolValue = EditorGUILayout.Toggle("One Unit Exception", oneUnitExceptionAllowMoveOver.boolValue);
        }

        // ...
        serializedObject.ApplyModifiedProperties();

        TMNEditorUtil.DrawSpacer();

        // fields to create new tile grid
        folds[0] = TMNEditorUtil.BeginToggleGroup("TileNodes Create Tool", folds[0]);
        if (folds[0])
        {
            GUILayout.Label("Note that this will delete current nodes", EditorStyles.label);
            EditorGUILayout.Space();
            new_TileNodeFab = (GameObject)EditorGUILayout.ObjectField("TileNode Prefab", new_TileNodeFab, typeof(GameObject), false);
            new_tilesLayout = EditorGUILayout.Popup("Tiles Layout", new_tilesLayout, MapNavEditor.TilesLayoutStrings);
            new_tileSpacing = EditorGUILayout.FloatField("Tile Spacing", new_tileSpacing);
            new_tileSize = EditorGUILayout.FloatField("Tile Size", new_tileSize);
            initialTileTypeMask = (TileNode.TileType)EditorGUILayout.EnumMaskField("Initial Tile Mask", initialTileTypeMask);

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Width x Length: ", EditorStyles.label);
            edNewNodesXY[0] = EditorGUILayout.IntField(edNewNodesXY[0]);
            edNewNodesXY[1] = EditorGUILayout.IntField(edNewNodesXY[1]);
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Create"))
            {
                tilesLayout.intValue = new_tilesLayout;
                tileSpacing.floatValue = new_tileSpacing;
                tileSize.floatValue = new_tileSize;

                if (edNewNodesXY[0] <= 0) edNewNodesXY[0] = 1;
                if (edNewNodesXY[1] <= 0) edNewNodesXY[1] = 1;

                //GameObject nodeFab = (GameObject)AssetDatabase.LoadAssetAtPath(MapNavEditor.PREFABS_PATH + "tile_nodes/" + ((MapNav.TilesLayout)new_tilesLayout == MapNav.TilesLayout.Hex ? "TIleNode_Hex.prefab" : "TIleNode_Square.prefab"), typeof(GameObject));
                //MapNav.CreateTileNodes(nodeFab, ((MapNav)target), (MapNav.TilesLayout)new_tilesLayout, new_tileSpacing, new_tileSize, initialTileTypeMask, edNewNodesXY[0], edNewNodesXY[1]);
                if (new_TileNodeFab != null)
                {
                    MapNav.CreateTileNodes(new_TileNodeFab, ((MapNav)target), (MapNav.TilesLayout)new_tilesLayout, new_tileSpacing, new_tileSize, initialTileTypeMask, edNewNodesXY[0], edNewNodesXY[1]);
                    ((MapNav)target).LinkNodes();
                }
            }
        }
        EditorGUILayout.EndToggleGroup();

        // various tools
        if (((MapNav)target).nodesCache != null)
        {
            // hide show node markers
            folds[1] = TMNEditorUtil.BeginToggleGroup("TileNodes Marker Visibility", folds[1]);
            if (folds[1])
            {
                GUILayout.Space(10f);
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Show"))
                {
                    ((MapNav)target).ShowTileNodeMarkers(true);
                    EditorUtility.SetDirty(target);
                }
                if (GUILayout.Button("Hide"))
                {
                    ((MapNav)target).ShowTileNodeMarkers(false);
                    EditorUtility.SetDirty(target);
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndToggleGroup();

            // automated setup of nodes' masks
            folds[2] = TMNEditorUtil.BeginToggleGroup("TileNodes Auto Mask-Setup Tool", folds[2]);
            if (folds[2])
            {
                GUILayout.Space(10f);
                maskAutomation_ParentObject = (Transform)EditorGUILayout.ObjectField("Use Parent Object", maskAutomation_ParentObject, typeof(Transform), true);
                if (maskAutomation_ParentObject != null) maskAutomation_ColliderMask = 0;
                maskAutomation_ColliderMask = EditorGUILayout.LayerField("or use Colliders Layer", maskAutomation_ColliderMask);
                if (maskAutomation_ColliderMask != 0) maskAutomation_ParentObject = null;
                GUILayout.Space(10f);
                maskAutomation_AddMask = (TileNode.TileType)EditorGUILayout.EnumMaskField("New TileNode Mask", maskAutomation_AddMask);
                GUILayout.Space(10f);
                EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("Set"))
                    {
                        if (maskAutomation_ParentObject != null) ((MapNav)target).SetTileNodeMasks(maskAutomation_AddMask, maskAutomation_ParentObject);
                        else ((MapNav)target).SetTileNodeMasks(maskAutomation_AddMask, maskAutomation_ColliderMask);
                        EditorUtility.SetDirty(target);
                    }
                    if (GUILayout.Button("Add"))
                    {
                        if (maskAutomation_ParentObject != null) ((MapNav)target).AddToTileNodeMasks(maskAutomation_AddMask, maskAutomation_ParentObject);
                        else ((MapNav)target).AddToTileNodeMasks(maskAutomation_AddMask, maskAutomation_ColliderMask);
                        EditorUtility.SetDirty(target);
                    }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.HelpBox("This tool helps automate the TileNode Mask setup process.\n\nExample, if you wanted to set nodes under tree meshes to be of Wall type, then you would set 'Parent Object' to the container of the trees and select from 'TileNode Mask' the Wall type (if you defined such in TileNode.TileType) and hit Add/Set.\n\nThe tool will go through all child transforms of the Parent Object and check which nodes are under them and update their tile-type masks.\n\nNote that 'Add' will add the mask to a node's current mask while 'Set' will reset the node mask to the given mask.\n\nYou also have the option to rather check against colliders of objects in your scene. This is useful where an object like a wall might span more than one tile and you want those tiles all to be set to tile type, wall. In this case you want to set 'Colliders Layer' to the layer of the objects to test against and make sure they have colliders since this will use ray casting. Make sure 'Parent Object' is not set in this case else this option will be ignored and Parent Object will be used.", MessageType.None);
            }
            EditorGUILayout.EndToggleGroup();

            // reseting nodes' masks
            folds[3] = TMNEditorUtil.BeginToggleGroup("TileNodes Mask Reset Tool", folds[3]);
            if (folds[3])
            {
                GUILayout.Space(10f);
                maskAutomation_ResetMask = (TileNode.TileType)EditorGUILayout.EnumMaskField("Set all to", maskAutomation_ResetMask);
                if (GUILayout.Button("Reset"))
                {
                    ((MapNav)target).SetAllNodeMasksTo(maskAutomation_ResetMask);
                    EditorUtility.SetDirty(target);
                }
            }
            EditorGUILayout.EndToggleGroup();

            // calc node heights
            folds[6] = TMNEditorUtil.BeginToggleGroup("TileNodes Auto Height-Setup Tool ", folds[6]);
            if (folds[6])
            {
                GUILayout.Space(10f);
                heightAutomation_Mask = EditorGUILayout.LayerField("Colliders Layer", heightAutomation_Mask);
                heightAutomation_DelNodes = EditorGUILayout.Toggle("Node Deletion Active", heightAutomation_DelNodes);
                if (GUILayout.Button("Run Setup"))
                {
                    ((MapNav)target).SetupNodeHeights(heightAutomation_Mask, heightAutomation_DelNodes);
                    EditorUtility.SetDirty(target);
                }
                EditorGUILayout.HelpBox("This tool helps automate the TileNodes height setup. Set the 'Layer' field to the layer used by objects that will determine what height the nodes must be placed at. It is important that the object (for example a variable height terrain) use the same layer and has a collider since this tool will use raycasts the determine at what height to place nodes.\n\nIf Node Deletion is Active, then nodes that did not find anything to adjust their heights against will be unlinked and deleted. This is usefull if you have a non-square terrain area with some overlapping nodes that won't be used and must be deleted.", MessageType.None);
            }
            EditorGUILayout.EndToggleGroup();

            // auto link setup
            folds[7] = TMNEditorUtil.BeginToggleGroup("TileNodes Auto Link-Setup Tool ", folds[7]);
            if (folds[7])
            {
                GUILayout.Space(10f);
                maxHeightBeforeLinkBreak = EditorGUILayout.FloatField("Max Height", maxHeightBeforeLinkBreak);
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Run Setup"))
                {
                    ((MapNav)target).SetupNodeLinkSwitches(maxHeightBeforeLinkBreak);
                    EditorUtility.SetDirty(target);
                }
                if (GUILayout.Button("Reset ALL"))
                {
                    ((MapNav)target).RemoveNodeLinkSwitches();
                    EditorUtility.SetDirty(target);
                }
                if (GUILayout.Button("Delete Unlinked"))
                {
                    ((MapNav)target).DeleteAllUnlinkedNodes();
                    EditorUtility.SetDirty(target);
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.HelpBox("This tool helps automate setting up the links betwene nodes, depending on the height difference betwene the nodes. Enter a max height and links between nodes will be turned off if the height difference between them are higher.\n\nThe 'Delete' button allows for the auto-deletion of all nodes that have no active links.", MessageType.None);

            }
            EditorGUILayout.EndToggleGroup();
        }
    }
コード例 #4
0
    // ====================================================================================================================
    #region create / setup tools

    /// <summary>
    /// Creates a new grid of tile nodes of x by y count
    /// </summary>
    public static void CreateTileNodes(GameObject nodeFab, MapNav map, MapNav.TilesLayout layout, float tileSpacing, float tileSize, TileNode.TileType initialMask, int xCount, int yCount)
    {
        if (xCount <= 0 || yCount <= 0)
        {
            return;
        }

        map.tilesLayout = layout;
        map.tileSpacing = tileSpacing;
        map.tileSize    = tileSize;

        // first delete the old nodes
        List <GameObject> remove = new List <GameObject>();

        foreach (Transform t in map.transform)
        {               // just make sure it is a node in case there are other kinds of objects under MapNav object
            if (t.name.Contains("node"))
            {
                remove.Add(t.gameObject);
            }
        }
        remove.ForEach(go => DestroyImmediate(go));

        // now create new nodes

        map.nodesXCount = xCount;
        map.nodesYCount = yCount;
        map.nodesCache  = new GameObject[map.nodesXCount * map.nodesYCount];

        int   count  = 0;
        bool  atoffs = false;
        float offs   = 0f;
        float xOffs  = map.tileSpacing;
        float yOffs  = map.tileSpacing;

        if (map.tilesLayout == MapNav.TilesLayout.Hex)
        {               // calculate offset to correctly plate hextiles
            xOffs = Mathf.Sqrt(3f) * map.tileSpacing * 0.5f;
            offs  = xOffs * 0.5f;
            yOffs = yOffs * 0.75f;
        }

        for (int y = 0; y < yCount; y++)
        {
            for (int x = 0; x < xCount; x++)
            {
                // create the node
                GameObject go = (GameObject)GameObject.Instantiate(nodeFab);
                go.name  = "node" + count.ToString();
                go.layer = map.tilesLayer;

                // parent under MapNav and position the node
                go.transform.parent        = map.transform;
                go.transform.localPosition = new Vector3(x * xOffs + (atoffs ? offs : 0f), 0f, y * yOffs);
                go.transform.localScale    = new Vector3(map.tileSize, map.tileSize, map.tileSize);

                // update TileNode component
                TileNode n = go.GetComponent <TileNode>();
                n.idx          = count;
                n.mapnav       = map;
                n.tileTypeMask = initialMask;

                // turn off the collider, don't need it now
                go.collider.enabled = false;

                // cache the node
                map.nodesCache[count] = go;
                count++;
            }
            atoffs = !atoffs;
        }
    }
コード例 #5
0
    /// <summary>
    /// Get a path from - to node, checking that the node mask includes validNodesLayer.
    /// Pass validNodesLayer=0 to ignore the mask check (oneUnitPerTileOnly is only applied if validNodesLayer is also applied)
    /// </summary>
    public TileNode[] GetPath(TileNode fromNode, TileNode toNode, TileNode.TileType validNodesLayer)
    {
        if (fromNode == null || toNode == null)
        {
            return(null);
        }

        // reset
        foreach (TileNode n in nodes)
        {
            if (n == null)
            {
                continue;
            }
            n.SetPathParent(null, 0, 0);
        }

        const int       DistanceConst = 10;
        List <TileNode> openList      = new List <TileNode>();
        List <TileNode> closeList     = new List <TileNode>();
        TileNode        tn            = fromNode;

        openList.Add(tn);

        while (openList.Count > 0)
        {
            // find one with lowest F score
            tn = null;
            foreach (TileNode ol in openList)
            {
                if (tn == null)
                {
                    tn = ol;
                }
                else if (ol.PathF < tn.PathF)
                {
                    tn = ol;
                }
            }

            // drop it from open list and add to close list
            closeList.Add(tn);
            openList.Remove(tn);

            if (tn == toNode)
            {
                break;                           // reached destination, break
            }
            // find neighbours of this point
            foreach (TileNode n in tn.nodeLinks)
            {
                // ignore null,
                if (n == null)
                {
                    continue;
                }

                // in close set
                if (closeList.Contains(n))
                {
                    continue;
                }

                // check if it is a tile node that can be used
                if (validNodesLayer > 0)
                {
                    // allow only one unit per tile?
                    if (oneUnitPerTileOnly)
                    {
                        if (!oneUnitExceptionAllowMoveOver && n.units.Count > 0)
                        {
                            continue;
                        }
                    }

                    // now check if another unit is occupying the same layer/level on the node
                    if ((n.tileTypeMask & validNodesLayer) == validNodesLayer)
                    {
                        if (n.GetUnitInLevel(validNodesLayer) != null)
                        {
                            continue;
                        }
                    }

                    // else, not a valid node
                    else
                    {
                        continue;
                    }
                }

                // check if there is link switch between the two nodes and if it is on or off
                if (tn.linkOnOffSwitch != null)
                {
                    if (tn.linkOnOffSwitch.LinkIsOn(n) == 0)
                    {
                        continue;
                    }
                }
                if (n.linkOnOffSwitch != null)
                {
                    if (n.linkOnOffSwitch.LinkIsOn(tn) == 0)
                    {
                        continue;
                    }
                }


                // calc G & H
                int G = tn.PathG + DistanceConst;
                int H = DistanceConst * Mathf.Abs((int)Vector3.Distance(n.transform.position, toNode.transform.position));

                // check if there are movement modifiers
                if (n.movesMod != null)
                {
                    foreach (TNEMovementModifier.MovementInfo m in n.movesMod.moveInfos)
                    {
                        if (m.tileType == validNodesLayer)
                        {
                            G += DistanceConst * m.movesModifier;
                        }
                    }
                }

                // apply
                if (openList.Contains(n))
                {                       // open list contains the neighbour
                                        // check if G score to the neighbour will be lower if followed from this point
                    if (G < n.PathG)
                    {
                        n.SetPathParent(tn, G, H);
                    }
                }
                else
                {                       // add neighbour to open list
                    n.SetPathParent(tn, G, H);
                    openList.Add(n);
                }
            }
        }

        // start at dest and build path
        List <TileNode> path = new List <TileNode>();

        tn = toNode;
        while (tn.PathParent != null)
        {
            path.Add(tn);
            tn = tn.PathParent;
        }

        if (path.Count > 0)
        {               // the path is calculated in reverse, swop it around
                        // and then return the array of the elements
            path.Reverse();
            return((TileNode[])path.ToArray());
        }

        // else return null
        return(null);
    }
コード例 #6
0
ファイル: TileNode.cs プロジェクト: C4SEM4N/WhatRemains
    public void _ShowNeighboursRecursive(int radius, bool show, TileNode.TileType validNodesLayer, bool inclMoveMod, bool incLinkCheck, ref List <TileNode> closeList)
    {
        this._ShowNeighboursRecursive_Helper = radius;
        closeList.Add(this);

        radius--; if (radius < 0)
        {
            return;
        }
        int r = radius;

        foreach (TileNode node in this.nodeLinks)
        {
            if (node == null)
            {
                continue;
            }
            if (closeList.Contains(node))
            {
                if (node._ShowNeighboursRecursive_Helper >= radius)
                {
                    continue;
                }
            }

            r = radius;

            if (show == true)
            {
                if (validNodesLayer > 0)
                {
                    // only allow one unit per tile?
                    if (node.mapnav.oneUnitPerTileOnly && node.units.Count > 0)
                    {
                        continue;
                    }

                    // if validNodesLayer given, then check if this is a valid node according to it mask
                    if ((node.tileTypeMask & validNodesLayer) != validNodesLayer)
                    {
                        continue;
                    }

                    // also check if another unit is occupying the same layer, which makes this node invalid
                    if (node.GetUnitInLevel(validNodesLayer))
                    {
                        continue;
                    }
                }

                // check if movement mod applies
                if (inclMoveMod && node.movesMod != null)
                {
                    foreach (TNEMovementModifier.MovementInfo m in node.movesMod.moveInfos)
                    {
                        if (m.tileType == validNodesLayer)
                        {
                            r -= m.movesModifier;
                        }
                    }
                    if (r < 0)
                    {
                        continue;
                    }
                }

                // check if link possibly off
                if (incLinkCheck)
                {
                    if (!this.LinkIsOnWith(node))
                    {
                        continue;
                    }
                }
            }

            node.Show(show);

            if (r > 0)
            {
                node._ShowNeighboursRecursive(r, show, validNodesLayer, inclMoveMod, incLinkCheck, ref closeList);
            }
        }
    }
コード例 #7
0
ファイル: TileNode.cs プロジェクト: C4SEM4N/WhatRemains
    private void _GetAllInRangeRecursive(int radius, TileNode.TileType validNodesLayer, bool checkIfUnitInWay, bool inclMoveMod, bool incLinkCheck, ref List <TileNode> helper, ref List <TileNode> retNodes)
    {
        this._ShowNeighboursRecursive_Helper = radius;
        helper.Add(this);

        radius--; if (radius < 0)
        {
            return;
        }
        int r = radius;

        foreach (TileNode node in this.nodeLinks)
        {
            if (node == null)
            {
                continue;
            }
            if (helper.Contains(node))
            {
                if (node._ShowNeighboursRecursive_Helper >= radius)
                {
                    continue;
                }
            }

            r = radius;

            if (validNodesLayer > 0)
            {
                // check if this is a valid node according to its mask
                if ((node.tileTypeMask & validNodesLayer) != validNodesLayer)
                {
                    continue;
                }

                if (checkIfUnitInWay)
                {
                    // only allow one unit per tile?
                    if (node.mapnav.oneUnitPerTileOnly && node.units.Count > 0)
                    {
                        continue;
                    }

                    // also check if another unit is occupying the same layer, which makes this node invalid
                    if (node.GetUnitInLevel(validNodesLayer))
                    {
                        continue;
                    }
                }
            }

            // check if movement mod applies
            if (inclMoveMod && node.movesMod != null)
            {
                foreach (TNEMovementModifier.MovementInfo m in node.movesMod.moveInfos)
                {
                    if (m.tileType == validNodesLayer)
                    {
                        r -= m.movesModifier;
                    }
                }
                if (r < 0)
                {
                    continue;
                }
            }

            // check if link possibly off
            if (incLinkCheck)
            {
                if (!this.LinkIsOnWith(node))
                {
                    continue;
                }
            }

            // this node seems fine, incl in return list
            retNodes.Add(node);

            // on to the next
            if (r > 0)
            {
                node._GetAllInRangeRecursive(r, validNodesLayer, checkIfUnitInWay, inclMoveMod, incLinkCheck, ref helper, ref retNodes);
            }
        }
    }
コード例 #8
0
ファイル: TileNode.cs プロジェクト: C4SEM4N/WhatRemains
    /// <summary>
    /// Show tiles that include certain layer in mask and do not have any unit standing in that spot (also applies MapNav.oneUnitPerTileOnly if set)
    /// Good for showing nodes that a unit may move over.
    /// </summary>
    public void ShowNeighbours(int radius, TileNode.TileType validNodesLayer, bool checkMoveMod, bool checkOnOffSwitch)
    {
        List <TileNode> closeList = new List <TileNode>();

        this._ShowNeighboursRecursive(radius, true, validNodesLayer, checkMoveMod, checkOnOffSwitch, ref closeList);
    }
コード例 #9
0
ファイル: TileNode.cs プロジェクト: C4SEM4N/WhatRemains
    /// <summary>
    /// Show tiles that include certain layer in mask and do not have any unit standing in that spot (also applies MapNav.oneUnitPerTileOnly if set)
    /// Good for showing nodes that a unit may move over.
    /// </summary>
    public void ShowNeighbours(int radius, TileNode.TileType validNodesLayer)
    {
        List <TileNode> closeList = new List <TileNode>();

        this._ShowNeighboursRecursive(radius, true, validNodesLayer, false, false, ref closeList);
    }
コード例 #10
0
ファイル: MapNav.cs プロジェクト: mzenm/GAME2017-client
 public void AddToTileNodeMasks(TileNode.TileType mask, int testAgainstCollidersLayer)
 {
     AddOrSetTileNodeMasks(true, mask, 1 << testAgainstCollidersLayer, 100f);
 }
コード例 #11
0
ファイル: MapNav.cs プロジェクト: mzenm/GAME2017-client
 public void AddToTileNodeMasks(TileNode.TileType mask, Transform parent)
 {
     AddOrSetTileNodeMasks(true, mask, parent, 10f);
 }
コード例 #12
0
ファイル: MapNav.cs プロジェクト: mzenm/GAME2017-client
 public void SetTileNodeMasks(TileNode.TileType mask, Transform parent)
 {
     AddOrSetTileNodeMasks(false, mask, parent, 10f);
 }
コード例 #13
0
 public void ShowNeighbours(int radius, TileNode.TileType validNodesLayer, bool checkMoveMod, bool checkOnOffSwitch)
 {
     _ShowNeighboursRecursive(radius, true, validNodesLayer, checkMoveMod, checkOnOffSwitch);
 }
コード例 #14
0
 public void ShowNeighbours(int radius, TileNode.TileType validNodesLayer)
 {
     _ShowNeighboursRecursive(radius, true, validNodesLayer, false, false);
 }
コード例 #15
0
    public void _ShowNeighboursRecursive(int radius, bool show, TileNode.TileType validNodesLayer, bool inclMoveMod, bool incLinkCheck)
    {
        radius--;
        if (radius < 0)
        {
            return;
        }
        List <TileNode> skipList = new List <TileNode>();

        foreach (TileNode node in nodeLinks)
        {
            if (node == null)
            {
                continue;
            }

            if (show == true)
            {
                if (validNodesLayer > 0)
                {
                    if ((node.tileTypeMask & validNodesLayer) != validNodesLayer)
                    {
                        continue;
                    }
                    if (node.GetUnitInLevel(validNodesLayer))
                    {
                        continue;
                    }
                }
                if (inclMoveMod && node.movesMod != null)
                {
                    int r = radius;
                    foreach (TNEMovementModifier.MovementInfo m in node.movesMod.moveInfos)
                    {
                        if (m.tileType == validNodesLayer)
                        {
                            r -= m.movesModifier;
                        }
                    }
                    if (r < 0)
                    {
                        continue;
                    }
                    if (r <= 0)
                    {
                        skipList.Add(node);
                    }
                }
                if (incLinkCheck)
                {
                    if (!LinkIsOnWith(node))
                    {
                        skipList.Add(node);
                        continue;
                    }
                }
            }

            node.Show(show);
        }
        foreach (TileNode node in nodeLinks)
        {
            if (node == null)
            {
                continue;
            }

            if (show == true)
            {
                if (validNodesLayer > 0)
                {
                    if ((node.tileTypeMask & validNodesLayer) != validNodesLayer)
                    {
                        continue;
                    }
                    if (node.GetUnitInLevel(validNodesLayer))
                    {
                        continue;
                    }
                }

                if (skipList.Contains(node))
                {
                    continue;
                }
            }

            node._ShowNeighboursRecursive(radius, show, validNodesLayer, inclMoveMod, incLinkCheck);
        }
    }