public scConvertTo3D(ArrayList cellList, List <scVertexNode> _roomList, scPrims thePrimController)
    {
        Camera.main.gameObject.AddComponent <scGameplayCamera>();
        Camera.main.transform.position = new Vector3(0, 20, 0);
        //temp object to parent all cells in
        GameObject groupCell = new GameObject();

        groupCell.name = "AllCells";

        foreach (GameObject aRoom in cellList)
        {
            aRoom.transform.parent = groupCell.gameObject.transform;
        }

        foreach (scVertexNode aNode in _roomList)
        {
            aNode.getParentCell().AddComponent <scRoom>();
            roomList.Add(aNode.getParentCell());
        }

        //transfer the connection data into rooms so each room knows who it is connected too
        foreach (scEdge aEdge in thePrimController.getConnections())
        {
            aEdge.getNode0().getParentCell().GetComponent <scRoom>().addConnection(aEdge.getNode1().getParentCell());
            aEdge.getNode1().getParentCell().GetComponent <scRoom>().addConnection(aEdge.getNode0().getParentCell());
        }

        //rotate all cells to be on correct axis, no longer working in 2D
        groupCell.transform.eulerAngles = new Vector3(90, 0, 0);
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        if (!noNeed)
        {
            if (!hasStarted)
            {
                if (cellsStill())
                {
                    hasStarted = true;
                }
            }
            else
            {
                if (!isFinished)
                {
                    //turn large cells into rooms;
                    setRooms();

                    //initalize the triangulation
                    theDTController.setupTriangulation(roomList);

                    isFinished = true;
                }
                else
                {
                    if (!DTFinished)
                    {
                        if (!theDTController.getDTDone())
                        {
                            theDTController.Update();
                        }
                        else
                        {
                            DTFinished = true;
                            thePrimController.setUpPrims(roomList, theDTController.getTriangulation());
                        }
                    }
                    else
                    {
                        if (!PrimFinished)
                        {
                            List <GameObject> listEtape = new List <GameObject>();
                            thePrimController.Update();
                            foreach (scVertexNode aNode in roomList)
                            {
                                aNode.getParentCell().AddComponent <ScEtape>();
                                listEtape.Add(aNode.getParentCell());
                            }
                            foreach (scEdge aEdge in thePrimController.getConnections())
                            {
                                aEdge.getNode0().getParentCell().GetComponent <ScEtape>().addConnection(aEdge.getNode1().getParentCell());
                                aEdge.getNode1().getParentCell().GetComponent <ScEtape>().addConnection(aEdge.getNode0().getParentCell());
                            }
                            PrimFinished = true;
                            Debug.Log(listEtape);
                            Debug.Log(thePrimController.edgesInTree);
                            List <GameObject> dirtyObject = new List <GameObject>();
                            foreach (GameObject g in listEtape)
                            {
                                if (!g.GetComponent <ScEtape>().hasConnexion())
                                {
                                    dirtyObject.Add(g);
                                }
                            }
                            listEtape.RemoveAll(r => !r.GetComponent <ScEtape>().hasConnexion());
                            foreach (GameObject g in dirtyObject)
                            {
                                Destroy(g);
                            }
                            foreach (GameObject g in GameObject.FindGameObjectsWithTag("Lines"))
                            {
                                if (g.name == "EdgeLine")
                                {
                                    g.SetActive(false);
                                }
                            }

                            cellHolder.gameObject.SetActive(false);
                            CarteService.instance.initialiseMap(listEtape);
                        }
                    }
                }
            }
        }
    }