Ejemplo n.º 1
0
    public MapNode CreateMapNode(MapNodeStruct mapData)
    {
        //Debug.Log("Vector3Int (gridLoc): x: " + vect.x + " y: " + vect.y + " z: " + vect.z);
        GameObject nodeObject      = Instantiate(GetNodePrefab(NodeTypes.MapNode), mapData.parentNode, false);
        Transform  parentTransform = mapData.parentNode.transform;

        if (mapData.spinny == 1) // for the spinny map experimental thing
        {
            parentTransform = mapData.parentNode.transform.Find("RotationalNode").transform;
        }

        nodeObject.transform.SetParent(parentTransform);
        nodeObject.transform.localPosition    = mapData.location; // Dontbe fooled! this is different to worldNode method above
        nodeObject.transform.localEulerAngles = mapData.rotation; // this might need to be looked at later

        MapNode nodeScript = nodeObject.GetComponent <MapNode>();

        if (mapData.spinny == 1) // for the spinny map experimental thing
        {
            nodeScript.Spinney = true;
        }

        nodeScript.NodeMapPiece   = mapData.mapPiece;
        nodeScript.NodeLayerCount = 0;
        nodeScript.NodeID         = mapData.NodeID;
        return(nodeScript);
    }
Ejemplo n.º 2
0
    public MapNode CreateMapNode(MapNodeStruct mapData)
    {
        //Debug.Log("Vector3Int (gridLoc): x: " + vect.x + " y: " + vect.y + " z: " + vect.z);
        GameObject nodeObject = Instantiate(GetNodePrefab(NodeTypes.MapNode), mapData.parentNode, false);

        nodeObject.transform.SetParent(mapData.parentNode);
        nodeObject.transform.localPosition    = mapData.location; // Dontbe fooled! this is different to worldNode method above
        nodeObject.transform.localEulerAngles = mapData.rotation; // this might need to be looked at later

        MapNode nodeScript = nodeObject.GetComponent <MapNode>();

        nodeScript.NodeMapPiece   = mapData.mapPiece;
        nodeScript.NodeLayerCount = 0;
        nodeScript.NodeID         = mapData.NodeID;
        return(nodeScript);
    }
Ejemplo n.º 3
0
    ////////////////////////////////////////////////
    ////////////////////////////////////////////////

    public static void CreateMapNodesForWorldNode(WorldNode worldNode)
    {
        int maxNodeSizeX = 9;
        int maxNodeSizeY = 9;
        int maxNodeSizeZ = 9;

        int nodeDistanceX = MapSettings.MapNodeCountDistanceXZ + 4;
        int nodeDistanceY = MapSettings.MapNodeCountDistanceY + 4;
        int nodeDistanceZ = MapSettings.MapNodeCountDistanceXZ + 4;

        int vectStartLocX = -(nodeDistanceX * 4);
        int vectStartLocY = -(nodeDistanceY * 4);
        int vectStartLocZ = -(nodeDistanceZ * 4);

        int vectLocX = vectStartLocX;
        int vectLocY = vectStartLocY;
        int vectLocZ = vectStartLocZ;

        Dictionary <int, int[]> mapPieces = worldNode.NodeData.worldNodeMapPieces;

        List <MapNode> mapNodes = new List <MapNode>();

        int locCounter = 1; // coz locations start at 1

        for (int y = 0; y < maxNodeSizeY; y++)
        {
            for (int z = 0; z < maxNodeSizeZ; z++)
            {
                for (int x = 0; x < maxNodeSizeX; x++)
                {
                    if (mapPieces.ContainsKey(locCounter))
                    {
                        MapNodeStruct mapData = new MapNodeStruct()
                        {
                            NodeID     = new Vector3Int(vectLocX, vectLocY, vectLocZ),
                            mapPiece   = (MapPieceTypes)mapPieces[locCounter][0],
                            location   = new Vector3Int(vectLocX, vectLocY, vectLocZ),
                            rotation   = new Vector3Int(0, mapPieces[locCounter][1], 0),
                            parentNode = worldNode.gameObject.transform
                        };

                        MapNode mapNode = WorldBuilder._nodeBuilder.CreateMapNode(mapData);
                        mapNode.worldNodeParent = worldNode;
                        mapNodes.Add(mapNode);

                        if (!worldNode.entrance) // this could be better
                        {
                            CoverTypes coverType = CoverTypes.NormalCover;

                            if (mapNode.NodeMapPiece == MapPieceTypes.ConnectorPiece_Hor_Empty)
                            {
                                coverType = CoverTypes.ConnectorCover;
                            }
                            else if (mapNode.NodeMapPiece == MapPieceTypes.ConnectorPiece_Ver_Empty)
                            {
                                coverType = CoverTypes.ConnectorUPCover;
                            }

                            WorldBuilder._nodeBuilder.AttachCoverToNode(mapNode, mapNode.gameObject, coverType);
                        }
                    }

                    locCounter++;

                    vectLocX += nodeDistanceX;
                }
                vectLocX = vectStartLocX;

                vectLocZ += nodeDistanceZ;
            }
            vectLocX = vectStartLocX;
            vectLocZ = vectStartLocZ;

            vectLocY += nodeDistanceY;
        }

        worldNode.mapNodes = mapNodes;
    }