예제 #1
0
    public void SaveListsForSecondSaveLocation()
    {
        if (listOfSmallLightObjects_SecondSaveLocation != null)
        {
            return;
        }

        setSmallLightObjectList();
        setBigLightObjectList();
        setSinisterOneObjectList();
        setPlattformObjectList();

        listOfSmallLightObjects_SecondSaveLocation = getSmallLightObjectList();
        listOfBigLightObjects_SecondSaveLocation   = getBigLightObjectList();
        listOfSinisterObjects_SecondSaveLocation   = getSinisterObjectList();
        listOfPlattformObjects_SecondSaveLocation  = getPlattformObjectList();

        GameObject            player    = GameObject.Find("Player");
        PlayerLevelController plcScript = player.GetComponent <PlayerLevelController>();

        secondSavedLevelData                  = new levelData();
        secondSavedLevelData.score            = plcScript.getCurrentScore();
        secondSavedLevelData.timer            = plcScript.getCurrentLevelTimer();
        secondSavedLevelData.smalLightCounter = plcScript.returnNumberOfCollectedSmallLights();
        secondSavedLevelData.bigLightCounter  = plcScript.returnNumberOfCollectedBigLights();
    }
예제 #2
0
    public override bool Load()
    {
        level targetData = target as level;

        var    client = new DatabaseClient("", "");
        string error  = string.Empty;
        var    db     = client.GetDatabase(targetData.SheetName, ref error);
        var    table  = db.GetTable <levelData>(targetData.WorksheetName) ?? db.CreateTable <levelData>(targetData.WorksheetName);

        List <levelData> myDataList = new List <levelData>();

        var all = table.FindAll();

        foreach (var elem in all)
        {
            levelData data = new levelData();

            data = Cloner.DeepCopy <levelData>(elem.Element);
            myDataList.Add(data);
        }

        targetData.dataArray = myDataList.ToArray();

        EditorUtility.SetDirty(targetData);
        AssetDatabase.SaveAssets();

        return(true);
    }
예제 #3
0
    public void LoadLevelData(string fileName)
    {
        data.tiles.Clear();
        data.path.Clear();
        data.spawns.Clear();
        string path = Application.dataPath + "/Resources/Levels/" + fileName;

        using (StreamReader streamReader = File.OpenText(path)) {
            string jsonString = streamReader.ReadLine();
            data = JsonUtility.FromJson <levelData>(jsonString);
            string    spawnString;
            spawnData newSpawn;
            for (int i = 0; i < data.spawnsCount; i++)
            {
                spawnString = streamReader.ReadLine();
                newSpawn    = new spawnData();
                newSpawn    = JsonUtility.FromJson <spawnData>(spawnString);
                data.spawns.Add(newSpawn);
            }
        }
        Debug.Log("Load level: '" + data.levelName + "' [" + data.width + "," + data.height + "]");

        //data.spawns.Clear(); GenerateSpawns( 30 );
        //SaveLevelData( fileName );
    }
예제 #4
0
        public void buildLevel(levelData myData, levelData smallRooms)
        {
            int  i, f, g;
            int  boxWidth  = 3;
            int  roomWidth = 8;
            bool place     = false;

            /*myGrid.setRegion(1, 1, 1, boxWidth * roomWidth, boxWidth * roomWidth, boxWidth * roomWidth, 1);
             * for (i = 0; i < roomWidth; i++)
             * {
             *  for (f = 0; f < roomWidth; f++)
             *  {
             *      for (g = 0; g < roomWidth; g++)
             *      {
             *          if (i!=0 && i!=roomWidth-1 && f!=0 && f!=roomWidth-1 && g!=0 && g != roomWidth-1)
             *          {
             *              //if (!(i % 2 == 0) || !(f % 2 == 0))
             *              place = i%2==0;
             *              if (f % 2 == 0) { place = !place; }
             *              if (g % 2 == 0 && g % 4 == 2) { place = !place; }
             *              if (place)
             *              {
             *                  myGrid.setRegion(1 + i * boxWidth, 1 + f * boxWidth, 1 + g * boxWidth, boxWidth, boxWidth, boxWidth, 0);
             *              }
             *          }
             *      }
             *  }
             * }/**/

            /*myGrid.setRegion(1, 1, 1, 15, 15, 15, 1);
             *
             * myGrid.setRegion(6, 6, 6, 3, 3, 3, 0);
             *
             * myGrid.setRegion(3, 3, 3, 3, 3, 3, 0);
             * myGrid.setRegion(3, 9, 3, 3, 3, 3, 0);
             * myGrid.setRegion(9, 3, 3, 3, 3, 3, 0);
             * myGrid.setRegion(9, 9, 3, 3, 3, 3, 0);
             *
             * myGrid.setRegion(3, 3, 9, 3, 3, 3, 0);
             * myGrid.setRegion(3, 9, 9, 3, 3, 3, 0);
             * myGrid.setRegion(9, 3, 9, 3, 3, 3, 0);
             * myGrid.setRegion(9, 9, 9, 3, 3, 3, 0);/**/
            for (i = 0; i < myData.minRooms; i++)
            {
                placeRoom(myData);
            }

            //isConnected();
            //while (isConnected() == false) { placeRoom(myData); }
            while (isConnected() == false)
            {
                connectorList.Add(placeRoom(smallRooms));
            }
            //conway();
            roomCull(1.0f);/**/
예제 #5
0
    public void Win()
    {
        //Code for win
        float     duration_of_level = Time.time - starttime;
        string    save  = "";
        levelData level = new levelData(SceneManager.GetActiveScene().name);

        save += (level.BestTime > duration_of_level || level.BestTime == 0.0f) ? duration_of_level.ToString() : level.BestTime.ToString();
        PlayerPrefs.SetString(SceneManager.GetActiveScene().name, save);
        Debug.Log("Finished with time" + save);
        ToLevelSelect();
    }
예제 #6
0
    void Start()
    {
        //boxGen();
        VoxelMap  myMap      = new VoxelMap(iArenaWidth, cube);
        levelData myLevel    = new levelData(iArenaWidth, minRooms, minWidth, maxWidth);
        levelData smallRooms = new levelData(iArenaWidth, 0, 4, 8);

        myMap.buildLevel(myLevel, smallRooms);
        myMap.cullHidden();
        myMap.instantiate();
        player = Instantiate(player);
        player.transform.position = myMap.startPosition();
        //turret.transform.position = myMap.startPosition();
    }
예제 #7
0
    // Use this for initializatio
    void Start()
    {
        player            = transform.FindChild("player").gameObject;
        levelManager      = GameObject.Find("GameScript").GetComponent <levelData>();
        vertexLocation    = new Vector3[5];
        vertexLocation[0] = transform.FindChild("Lv1").position;
        vertexLocation[1] = transform.FindChild("Lv2").position;
        vertexLocation[2] = transform.FindChild("Lv3").position;
        vertexLocation[3] = transform.FindChild("Lv4").position;
        vertexLocation[4] = transform.FindChild("Lv5").position;

        player.transform.position = vertexLocation[LevelData.playerPosition];
        target = LevelData.playerPosition;
        updateProgression(LevelData.progression);
    }
예제 #8
0
    private void Start()
    {
        Sprite[] thumbnails = Resources.LoadAll <Sprite>("Levels");
        foreach (Sprite thumbnail in thumbnails)
        {
            GameObject container = Instantiate(levelbutton) as GameObject;
            container.transform.SetParent(levelbuttonContainer.transform, false);
            container.transform.GetChild(0).GetComponent <Image>().sprite          = thumbnail;
            container.transform.GetChild(0).GetChild(0).GetComponent <Text>().text = thumbnail.name;
            levelData level = new levelData(thumbnail.name);
            container.transform.GetChild(1).GetChild(0).GetComponent <Text>().text = level.BestTime.ToString("f"); //Gets Best Time panel text component

            string Scenename = thumbnail.name;
            container.GetComponent <Button>().onClick.AddListener(() => LoadLevel(Scenename));
        }
    }
예제 #9
0
 public void StartLevel(int levelId)
 {
     ActiveLevelId = levelId;
     _activeLevel  = _levelDatas[levelId];
     SceneManager.LoadScene(_activeLevel.sceneName);
 }