Пример #1
0
        internal List <Level> GetDocumentLevelList(int OrgID)
        {
            DocumentLevelsModel model   = new DocumentLevelsModel();
            List <SubLevel>     objList = new DocumentLevelsFacade().GetDocumentLevels(OrgID);

            if (objList.Count > 0)
            {
                int      l      = 0;
                Level    lvl    = new Level();
                SubLevel sublvl = new SubLevel();
                foreach (SubLevel sublevel in objList)
                {
                    if (sublevel.LevelID != l)
                    {
                        lvl = new Level()
                        {
                            LevelID = sublevel.LevelID, OrganizationID = OrgID
                        };
                        model.levels.Add(lvl);
                        l = lvl.LevelID;
                    }
                    lvl.sublevels.Add(sublevel);
                }
            }

            return(model.levels);
        }
Пример #2
0
    void InstantiateSubLevel(int idx)
    {
        GameObject o = Instantiate(PrefabSubLevel) as GameObject;

        o.transform.parent = transform;
        SubLevel subLv = o.GetComponent <SubLevel>();

        subLv.levelIndex = idx;
        subLv.isLocked   = idx > 1;
    }
Пример #3
0
 //splits the SubLevel into smaller SubLevels until they're the correct size
 private void SplitLevel(SubLevel level)
 {
     if (level.IsLeaf() && level.IsLarge(maxRoomSize))
     {
         if (level.SplitLevel(minRoomSize, maxRoomSize))
         {
             SplitLevel(level.getChild(1));
             SplitLevel(level.getChild(2));
         }
     }
 }
Пример #4
0
    public void AddSubLevel()
    {
        subLevelToAdd = new GameObject("SubLevel_" + SubLevels.Count);
        subLevelCmpt  = subLevelToAdd.AddComponent <SubLevel>();

        SubLevels.Add(subLevelToAdd);
        subLevelToAdd.transform.SetParent(parent.transform);
        subLevelToAdd.transform.localPosition = new Vector3(0, 0, 0);
        subLevelToAdd.transform.localScale    = new Vector3(1, 1, 1);

        BuildStructure();
    }
Пример #5
0
 //Method to create a list of all rooms created
 public void FindRooms(SubLevel level, List <Room> roomsList)
 {
     if (level.IsLeaf())
     {
         roomsList.Add(level.room);
     }
     else
     {
         FindRooms(level.child1, roomsList);
         FindRooms(level.child2, roomsList);
     }
 }
Пример #6
0
 //Creates a list of all rooms in the level
 private void GetRooms(SubLevel level)
 {
     if (level.getChild(1) != null)
     {
         GetRooms(level.getChild(1));
     }
     if (level.getChild(2) != null)
     {
         GetRooms(level.getChild(2));
     }
     if (level.IsLeaf())
     {
         rooms.Add(level.getRoom());
     }
 }
Пример #7
0
    private bool spawnFailed = true;                                        //if true when generation is 'finished', the level will be generated again

    //main method to generate the map
    void Start()
    {
        while (spawnFailed)           //while loop used until a generation meets all criteria (main one being that every room is actually connected!)
        {
            try{
                spawnFailed = false;    //will be set to true in fatal circumstances (no direct line between rooms, coridoors unable to generate etc)
                SubLevel rootLevel = new SubLevel(levelWidth / 2f, levelHeight / 2f, levelWidth, levelHeight, minRoomSize, true, 0);
                SplitLevel(rootLevel);  //recursive method to split the map into appropriately sized sections
                rootLevel.CreateRoom(); //recursive method to create rooms in the sections
                rootLevel.FindPairs();  //recursive method to find pairs of rooms
                rooms  = new List <Room> ();
                groups = new List <RoomGroup> ();
                coridoorControllers = new List <CoridoorController> ();
                GetRooms(rootLevel);           //returns all rooms
                SpawnRooms();                  //spawns in rooms (including generating stats)
                GroupRooms();                  //groups rooms together
                SpawnCoridoorsWithinGroups();  //spawns coridoors within each group
                SpawnCoridoorsBetweenGroups(); //connects each group with a coridoor
            } catch {
                spawnFailed = true;
            }
            if (spawnFailed)               //Resetting, before trying again

            {
                for (int i = 0; i < roomList.childCount; i++)
                {
                    Destroy(roomList.GetChild(i).gameObject);
                }
                for (int i = 0; i < coridoorList.childCount; i++)
                {
                    Destroy(coridoorList.GetChild(i).gameObject);
                }
                while (roomList.childCount > 0)
                {
                    roomList.GetChild(0).parent = null;
                }
                while (coridoorList.childCount > 0)
                {
                    coridoorList.GetChild(0).parent = null;
                }
                tileController.ResetTiles(levelWidth, levelHeight);
            }
        }

        BuildCoridoors(); //builds the physical aspect of the coridoors;
        BuildRooms();     //builds the physical aspect of the rooms
        BuildNavMesh();   //builds a navmesh, used for AI movement
    }
Пример #8
0
    //splits the SubLevel into two smaller SubLevels
    public bool SplitLevel(int minLevelSize, int maxLevelSize)
    {
        if (!IsLeaf())
        {
            return(false);
        }

        if ((float)width / (float)height >= 1.2f)
        {
            splitHorizontal = false;
        }
        else if ((float)height / (float)width >= 1.2f)
        {
            splitHorizontal = true;
        }
        else
        {
            splitHorizontal = Random.Range(0.0f, 1.0f) > 0.5f;
        }

        if ((Mathf.Max(height, width) / 3) < minLevelSize)
        {
            return(false);
        }

        if (splitHorizontal)
        {
            splitPoint = Random.Range(minLevelSize, height - minLevelSize);

            child1      = new SubLevel(xCentre, zCentre - height / 2f + splitPoint / 2f, width, splitPoint, minRoomSize, true, depth + 1);
            child2      = new SubLevel(xCentre, zCentre + splitPoint / 2f, width, height - splitPoint, minRoomSize, false, depth + 1);
            child1.pair = child2;
            child2.pair = child1;
        }
        else
        {
            splitPoint = Random.Range(minLevelSize, width - minLevelSize);

            child1      = new SubLevel(xCentre - width / 2f + splitPoint / 2f, zCentre, splitPoint, height, minRoomSize, true, depth + 1);
            child2      = new SubLevel(xCentre + splitPoint / 2f, zCentre, width - splitPoint, height, minRoomSize, false, depth + 1);
            child1.pair = child2;
            child2.pair = child1;
        }

        return(true);
    }
Пример #9
0
    public void AddLayer()
    {
        if (!LevelCreator.LCSubLevel.SubLevels.Contains(selection))
        {
            return;
        }

        layerToAdd      = Instantiate(LevelCreator.LayerPrefab, Vector3.zero, Quaternion.identity, selection.transform);
        layerToAdd.name = "Layer_" + Layers.Count;

        Layers.Add(layerToAdd);
        layerToAdd.transform.SetParent(selection.transform);
        layerToAdd.transform.localPosition = new Vector3(0, 0, 0);
        layerToAdd.transform.localScale    = new Vector3(1, 1, 1);

        subLevelCmpt = selection.GetComponent <SubLevel>();
        subLevelCmpt.Layers.Add(layerToAdd);

        AddNodes(Layers.Last());
    }
Пример #10
0
        private List <Tuple <string> > BuildDocTypeList_OldCode(int OrgID)
        {
            List <Level> doclevels = new DocumentLevelService().GetDocumentLevelList(OrgID);

            // Build doc hierarchy for all levels
            List <DocType> templist   = new List <DocType>();
            Level          firstlevel = doclevels[0];

            for (int s = 0; s < firstlevel.sublevels.Count; s++)
            {
                SubLevel sub = firstlevel.sublevels[s];
                DocType  doc = new DocType()
                {
                    DocName = sub.Abbreviate, Description = sub.Name
                };
                AddRecursive(doc, 1, doclevels);
                templist.Add(doc);
            }

            // Get all lowermost levels into doctypelist
            List <DocType> docTypelist = new List <DocType>();

            foreach (DocType type in templist)
            {
                docTypelist.AddRange(type.AllChilds);
            }

            // Process all childs to doc name list
            List <Tuple <string> > result = new List <Tuple <string> >();

            foreach (DocType doc in docTypelist)
            {
                result.Add(new Tuple <string>(doc.DocPath));
            }

            return(result);
        }
Пример #11
0
    public void RemoveSelectedLayer()
    {
        if (!Layers.Contains(selection))
        {
            return;
        }

        int index = Layers.FindIndex(x => x.Equals(selection));

        for (int i = Nodes.Count - 1; i >= 0; i--)
        {
            Node node = Nodes[i].GetComponent <Node>();
            if (node.NodeLayerId == index)
            {
                DestroyImmediate(Nodes[i]);
                Nodes.Remove(Nodes[i]);
            }
        }

        subLevelCmpt = selection.GetComponentInParent <SubLevel>();
        subLevelCmpt.Layers.Remove(selection);
        DestroyImmediate(selection);
        Layers.Remove(selection);
    }
Пример #12
0
 public InGameStruct(string name, IComponentContainer container, SubLevel SubLevel) : base(name, container)
 {
     this.SubLevel = SubLevel;
 }