示例#1
0
 //called when the scene loads.
 // instantiates the dungeon's first floor, no rooms, no models.
 void Start()
 {
     //GetStatsFromSave();
     CurrentFloor      = -1;
     second            = (int)Time.time;
     myfloor           = new WFloor();
     target            = null;
     myfloor.Yoffset   = -20 * (CurrentFloor + 1);
     myfloor.roomWidth = RoomWidth;
     myfloor.minSize   = MinRooms;
     myfloor.maxSize   = MaxRooms;
     myfloor.ThemePath = ThemePath;
     myfloor.Start(roomprefab);
     //
     //generate the floor's first room, without it's model.
     GenerateNext();
     started             = false;
     playerHasBeenPlaced = false;
     ProceedButton       = GameObject.Instantiate(Resources.Load <GameObject>("CanvasButtonObject"), Vector3.zero, Quaternion.identity, GameObject.Find("UICanvas").transform);
     //(GameObject)UnityEditor.AssetDatabase.LoadAssetAtPath("Assets/p10refabs/CanvasButtonObject.prefab", typeof(GameObject)), Vector3.zero, Quaternion.identity, GameObject.Find("UICanvas").transform);
     ProceedButton.GetComponent <Button>().onClick.AddListener(OnClickEnterFloor);
     ProceedButton.transform.SetAsFirstSibling();
 }
示例#2
0
    /// <summary>
    /// Generates the specified floor level by walking the floor, then assigning models.
    /// Assumes that the floor exists in our "floors" object to load from, otherwise generates a new one.
    /// </summary>
    /// <param name="floorlevel"></param>
    public void EnterFloor(int floorlevel)
    {
        playerObject.GetComponent <UnitBehavior>().SetOverworldDestination(Vector3.zero);
        Debug.Log("enterring floor " + floorlevel + " of " + TotalFloors);
        started = true;
        myfloor.RandomAssignDoorModelsShort = false;
        GenerateNextShortCircuit            = false;
        //if we have previous floors to deal with, save them, then destroy their models.
        if (CurrentFloor >= 0)
        {
            //save the floor we are on (put it inside the floors list)
            //TODO we do this when we generate the floor. do we really need to do it again?
            //if (CurrentFloor < floors.count)
            //use currentfloor for deleting old floor models.
            Debug.Log("DESTROYING A FLOOR~~~~~~~~~~~~~~~");
            foreach (WRoom o in floors[CurrentFloor].map)
            {
                o.DestroyModels();
                //also completely remove
                o.DisposeDeadContents();
            }
        }
        //otherwise we are new and we can assume we had no previous floors
        else
        {
            //if we don't have a label on the player, add one.
            if (playerObject.GetComponent <HealthOverTarget>() == null)
            {
                playerObject.AddComponent <HealthOverTarget>();
            }
        }

        CurrentFloor = floorlevel;
        //if we request a floor greater than our total number of floors, reset our character in the overworld, undo our started aspect, and delete our floors list.
        //if the requested floor exists, load it. (there are no models, it needs to reassign models.)
        //else begin generating a new floor.
        if (CurrentFloor >= TotalFloors || CurrentFloor < 0)
        {
            /*
             * //if we have this tag element, remove it.
             * if (playerObject.GetComponent<HealthOverTarget>() != null)
             * {
             *  HealthOverTarget n = playerObject.GetComponent<HealthOverTarget>();
             *  Destroy(n);
             * }
             */
            playerObject.transform.position = playeroverworldspawnpoint;
            playerObject.GetComponent <UnitBehavior>().SetOverworldDestination(playerObject.transform.position);
            started = false;
            foreach (WFloor f in floors)
            {
                f.DestroyFloor();
            }
            floors.Clear();
            //Destroy(floors);
            floors       = new List <WFloor>();
            CurrentFloor = 0;
            Start();
            playerHasBeenPlaced = true;
            GameObject.Find("Camera").GetComponent <CameraControllerOfflineScript>().Target2 = null;
            Debug.Log("returning to overworld");
            System.GC.Collect();
            //return player to entrance?
            //return;
        }
        // requested floor exists and is not < 0.
        else if (CurrentFloor < floors.Count)
        {
            //GenerateNextShortCircuit = true;
            myfloor         = floors[CurrentFloor];
            myfloor.Yoffset = -20 * (CurrentFloor + 1);
            myfloor.CreateRoomModels(myfloor.ThemePath);
            myfloor.Update();
            playerHasBeenPlaced = false;
        }
        // floor does not exist, must be made.
        else
        {
            myfloor           = new WFloor();
            myfloor.roomWidth = RoomWidth;
            myfloor.minSize   = (int)(MinRooms * Mathf.Pow(PerFloorRoomScaling, CurrentFloor));
            myfloor.maxSize   = (int)(MaxRooms * Mathf.Pow(PerFloorRoomScaling, CurrentFloor));
            myfloor.ThemePath = ThemePath;
            myfloor.Yoffset   = -20 * (CurrentFloor + 1);
            myfloor.Start(roomprefab);
            isNewFloor = true;
            loadtest   = 0; //counts number of times createpath gets called
            GenerateNext();
            floors.Add(myfloor);
            playerHasBeenPlaced = false;
        }
        //Debug.Log("setting player's location to the first room in the map.");
        //playerObject.transform.position= myfloor.map[0].model.transform.position;
    }
 void SetFloor(WFloor obj)
 {
     CurrentFloor = obj;
 }
 /// <summary>
 /// gets the Wfloor object from the Walker object attached to our parent.
 /// </summary>
 void GetFloorFromSibling()
 {
     CurrentFloor = GetComponent <DungeonManager>().myfloor;
 }
示例#5
0
 public MiniMap(WFloor floor)
 {
     myfloor      = floor;
     rawFloorSize = Vector2.zero;    //a new minimap does not create the minimap at creation.
     topleft      = rawFloorSize;
 }