コード例 #1
0
    ////////////////////////////////////////////////

    // Create Generic Node /////////////////////////////////////////////////////
    public WorldNode CreateWorldNode(WorldNodeStruct mapData)
    {
        //Debug.Log("Vector3Int (gridLoc): x: " + vect.x + " y: " + vect.y + " z: " + vect.z);
        GameObject nodeObject = Instantiate(GetNodePrefab(NodeTypes.WorldNode), WorldManager._WorldContainer.transform, false);

        nodeObject.transform.SetParent(WorldManager._WorldContainer.transform);
        nodeObject.transform.localPosition = Vector3Int.zero;
        nodeObject.transform.position      = mapData.CurrLoc;

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

        nodeScript.NodeLayerCount = 0;
        nodeScript.NodeID         = new Vector3Int((int)mapData.NodeID.x, (int)mapData.NodeID.y, (int)mapData.NodeID.z);
        return(nodeScript);
    }
コード例 #2
0
    ////////////////////////////////////////////////
    ////////////////////////////////////////////////
    public static void CreatePlayerShip(NetworkNodeStruct nodeStruct, int playerID)
    {
        Vector3Int nodeID = new Vector3Int(Mathf.FloorToInt(nodeStruct.NodeID.x), Mathf.FloorToInt(nodeStruct.NodeID.y), Mathf.FloorToInt(nodeStruct.NodeID.z));

        WorldNodeStruct worldNodeData = new WorldNodeStruct()
        {
            NodeID  = nodeID,
            CurrLoc = new Vector3Int(Mathf.FloorToInt(nodeStruct.CurrLoc.x), Mathf.FloorToInt(nodeStruct.CurrLoc.y), Mathf.FloorToInt(nodeStruct.CurrLoc.z)),
            CurrRot = new Vector3Int(Mathf.FloorToInt(nodeStruct.CurrRot.x), Mathf.FloorToInt(nodeStruct.CurrRot.y), Mathf.FloorToInt(nodeStruct.CurrRot.z)),
        };

        WorldNode worldNode = WorldBuilder._nodeBuilder.CreateWorldNode(worldNodeData);

        LocationManager.SaveNodeTo_CLIENT(nodeID, worldNode);

        BasePlayerData playerData = PlayerManager.GetPlayerData(playerID);

        worldNode.transform.eulerAngles = new Vector3Int(0, 90, 0);

        worldNode.NodeData.worldNodeMapPieces = playerData.shipMapPieces;

        MapNodeBuilder.CreateMapNodesForWorldNode(worldNode);

        Dictionary <Vector3Int, WorldNode> dict = new Dictionary <Vector3Int, WorldNode>();

        dict.Add(nodeID, worldNode);
        //LayerManager.AssignLayerCountsToWorldAndMapNodes(dict);

        //if (playerID == PlayerManager.PlayerID)
        //{
        foreach (MapNode mapNode in worldNode.mapNodes)
        {
            mapNode.ActivateMapPiece(true);
        }
        //}

        if (playerData.playerID == PlayerManager.PlayerID)
        {
            MoveShip(playerData, worldNode);

            worldNode.transform.Find("RotationalNode").GetComponent <RotationalNode>()._rotate = true;
            PlayerManager.PlayersShipLoaded();
        }
    }
コード例 #3
0
    ////////////////////////////////////////////////////////////////////////////


    // Create World Nodes ///////////////////////////////////////////////////
    public static void CreateWorldNodes()
    {
        // build inital map Node
        _WorldNodes = new Dictionary <Vector3Int, WorldNode>();

        int rowMultipler  = MapSettings.worldSizeX;
        int colMultiplier = MapSettings.worldSizeZ;

        int totalMultiplier = MapSettings.worldSizeX * MapSettings.worldSizeZ;

        int countFloorX = 0; // complicated to explain to future me
        int countFloorZ = 0;
        int countFloorY = 1;

        int count = 1;

        foreach (Vector3Int location in _WorldNodeVects)
        {
            WorldNodeStruct worldNodeData = new WorldNodeStruct()
            {
                NodeID   = location,
                CurrLoc  = location,
                CurrRot  = Vector3Int.zero,
                PlayerID = -1
            };

            WorldNode nodeScript = WorldBuilder._nodeBuilder.CreateWorldNode(worldNodeData);

            // for the specified map structures
            if (MapSettings.LOADPREBUILT_STRUCTURE)
            {
                StructureData_01 worldStructure       = new StructureData_01();
                List <int[, ]>   worldStructureFloors = worldStructure.floors;

                int[,] structureFloor = worldStructureFloors[countFloorY - 1];
                if (structureFloor[countFloorX, countFloorZ] == 01)
                {
                    nodeScript.NodeData = GetWorldNodeData(new int[] { _1X1, _3X3 });
                }
                else
                {
                    nodeScript.NodeData = GetWorldNodeData(new int[] { _0X0 });
                }
            }
            else
            {
                nodeScript.NodeData = GetWorldNodeData(new int[] { _0X0, _1X1, _3X3 });
            }


            int shipEntranceProbablity = 20;

            //if (nodeScript.NodeData.GetType() == typeof(WorldNodeData_3X3) && Random.Range(0, shipEntranceProbablity) == 0)
            //{
            //    WorldBuilder._nodeBuilder.AttachCoverToNode(nodeScript, nodeScript.gameObject, CoverTypes.LargeGarageCover); // REALLLY DONT LIKE THIS HERE
            //    nodeScript.entrance = true;
            //}

            //Debug.Log("f**k adding worldNode to Vect " + location);

            _WorldNodes.Add(location, nodeScript);

            // for counting, best not to change, even tho its ugly
            countFloorX++;
            if (count % totalMultiplier == 0)
            {
                countFloorY++;
            }
            if (countFloorX % rowMultipler == 0)
            {
                countFloorX = 0;
                countFloorZ++;
            }
            if (countFloorZ % colMultiplier == 0)
            {
                countFloorZ = 0;
            }

            // for the dynamic grid experiment
            LocationManager.SaveNodeTo_CLIENT(location, nodeScript);
            //LocationManager.SetNodeScriptToLocation_SERVER(vect, nodeScript); // this needs to do this in the server

            count++;
        }
    }