public static GameLevel[] GetGameLevelsBasedOnCategory(string categoryName) { GameLevelData data = GameLevelToolkitWindow.GetGameLevelsData(); List <GameLevel> categories = new List <GameLevel>(); if (categoryName == data.allCategoriesName) // Get All { for (int i = 0; i < data.gameLevelsCreatedByUser.Count; i++) { categories.Add(data.gameLevelsCreatedByUser[i]); } } else // Get By Name { for (int i = 0; i < data.gameLevelsCreatedByUser.Count; i++) { if (data.gameLevelsCreatedByUser[i].assignedCategory == categoryName) { categories.Add(data.gameLevelsCreatedByUser[i]); } } } return(categories.ToArray()); }
private void Awake() { _character.Initialize(this); _hud.Initialize(this, _character.OnTapDown); // level init LevelData levelEntry = GameController.Instance.GetSelectedLevelData(); _timeBonusPosition = levelEntry.TimeBonusCellPosition; _spikesPosition = levelEntry.SpikesPosition; _levelData = new GameLevelData { Name = levelEntry.Name, MaxCoins = 0 }; _levelData.MaxCoins = GameController.Instance.DataLoader.GetLevelMaxCoins(levelEntry.Name); Debug.Log("Level " + _levelData.Name + " max coins: " + _levelData.MaxCoins.ToString()); var levelObj = GameObject.Instantiate(levelEntry.GamePrefab, _tilemapGrid.transform); levelObj.transform.localPosition = _levelLocalPosition; InitializeTilemap(); CurrentLevelTime = _levelTotalTime; TogglePause(false); LevelStarted = false; }
public void init(string levelCode) { this.reset(); GameLevelData data = DodResources.GetLevelData(levelCode); //判空 if (data == null) { throw new System.Exception("level not found"); } //循环构筑timeline string[] spliter = new string[] { "__" }; foreach (string code in data.commandSource) { _timeline.AddLast(new TimeCommand( code.Split(spliter, StringSplitOptions.None) )); } foreach (TimeCommand line in _timeline) { line.print(); } //todo:初始化关卡参数 }
public static void CreateCategory(string targetName) { GameLevelData data = GameLevelToolkitWindow.GetGameLevelsData(); data.allUserCreatedCategories.Add(targetName); EditorUtility.SetDirty(data); }
public override void Start() { base.Start(); //WorldData worldData = WorldList.Worlds[WorldToLoad.Value]; WorldData worldData = DataMgr.Instance.CurrentWorldData; Levels = worldData.LevelList; _selectedLevel = Levels.Levels[LoadLevel.Value]; WorldName.text = worldData.WorldName.ToUpper(); LevelName.text = string.Format("Level {0}", LoadLevel.Value + 1); if (_selectedLevel != null) { if (_selectedLevel.Photo == null) { if (!string.IsNullOrEmpty(_selectedLevel.PhotoUrl)) { // Format photo string URL here. } else { Debug.LogErrorFormat("Cannot load photo at URL: {0}!", _selectedLevel.Photo); } } LevelImage.sprite = Sprite.Create(_selectedLevel.Photo, new Rect(0, 0, _selectedLevel.Photo.width, _selectedLevel.Photo.height), Vector2.zero); LevelDescription.text = _selectedLevel.Description; } }
public void SetCurrentGameLevelById(string id) { if (_gameLevelDatasById.ContainsKey(id)) { CurrentGameLevelData = _gameLevelDatasById[id]; } }
/// <summary> /// Setta le informazioni necessare per il round corrente. /// </summary> void SetUpRound(int _round, GameLevelData _gameLeveldata) { Debug.Log("Setup Round"); if (GamePlayManager.I.CurrentRound == 1) { foreach (PlayerData playerD in GamePlayManager.I.Players) { playerD.PutCardsInHand(_gameLeveldata.StartNumberOfCards); } } else { foreach (PlayerData playerD in GamePlayManager.I.Players) { if (playerD.CardDataInHand.Count < 8) { playerD.PutCardsInHand(1); } } } foreach (PlayerData p in GamePlayManager.I.Players) { p.Mana = GamePlayManager.I.CurrentRound; } }
public bool TrySaveLevelMaxCoins(GameLevelData data) { var key = GameData.Find(k => string.Equals(k.Name, data.Name)); if (key == null) { GameData.Add(new GameLevelData { Name = data.Name, MaxCoins = data.MaxCoins }); // save PlayerPrefs.SetInt(data.Name, data.MaxCoins); return(true); } if (key.MaxCoins < data.MaxCoins) { key.MaxCoins = data.MaxCoins; // save PlayerPrefs.SetInt(data.Name, data.MaxCoins); return(true); } return(false); }
private void createLevelObjects() { GameLevelData levelData = this.dataManager.GameLevelsData[this.dataManager.CurrenLevel]; foreach (AsteroidLevelData item in levelData.asteroids) { createObject(item.name, item.position, false); } }
private void DuplicateLevel() { if (HasNewLocationNameAssigned() == true) { Debug.LogError("Has No New Location Name Assigned"); return; } if (gameLevelToCreateDuplicateOf == null) { Debug.LogError("Location Required to Duplicate"); return; } GameLevelToolkitWindow toolkit = GameLevelToolkitWindow.GetRefreshedToolkitWindow(); string projectPathName = GameLevelToolkitWindow.GetProjectPathStringWithSlash(); //Check if there is a location already existing with that name. GameLevel existingGameLevel = (GameLevel)AssetDatabase.LoadAssetAtPath("Assets/" + projectPathName + "Resources/" + SceneAndResourceFolderName.folderNameValue + "/" + newGameLevelName + "/" + newGameLevelName + ".asset", typeof(GameLevel)); if (existingGameLevel != null) { Debug.LogError("Location With Same Name Already Exists"); return; } //Create the Location Resource GameLevel gameLevelResource = GameLevelData.CreateInstance <GameLevel>(); AssetDatabase.CreateAsset(GameLevel.CreateInstance <GameLevel>(), "Assets/" + projectPathName + "Resources/" + SceneAndResourceFolderName.folderNameValue + "/" + "Existing " + SceneAndResourceFolderName.folderNameValue + "/" + newGameLevelName + ".asset"); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); GameLevel createdGameLevel = (GameLevel)AssetDatabase.LoadAssetAtPath("Assets/" + projectPathName + "Resources/" + SceneAndResourceFolderName.folderNameValue + "/" + "Existing " + SceneAndResourceFolderName.folderNameValue + "/" + newGameLevelName + ".asset", typeof(GameLevel)); createdGameLevel.gameLevelName = newGameLevelName; createdGameLevel.assignedScenesDirectory = "Assets/" + projectPathName + "Scenes/" + SceneAndResourceFolderName.folderNameValue + "/" + newGameLevelName; createdGameLevel.levelDependencies = gameLevelToCreateDuplicateOf.levelDependencies; createdGameLevel.assignedScenes = gameLevelToCreateDuplicateOf.assignedScenes; GameLevelToolkitWindow.GetGameLevelsData().gameLevelsCreatedByUser.Add(createdGameLevel); //Create the Scene Directory string scenesFolder = AssetDatabase.CreateFolder("Assets/" + projectPathName + "Scenes/" + SceneAndResourceFolderName.folderNameValue, newGameLevelName); //Copy the Existing Scenes for (int i = 0; i < gameLevelToCreateDuplicateOf.assignedScenes.Count; i++) { string sceneToCopy = gameLevelToCreateDuplicateOf.assignedScenesDirectory + "/" + gameLevelToCreateDuplicateOf.gameLevelName + "_" + gameLevelToCreateDuplicateOf.assignedScenes[i] + ".unity"; string destination = createdGameLevel.assignedScenesDirectory + "/" + newGameLevelName + "_" + gameLevelToCreateDuplicateOf.assignedScenes[i] + ".unity"; FileUtil.CopyFileOrDirectory(sceneToCopy, destination); } EditorUtility.SetDirty(createdGameLevel); EditorUtility.SetDirty(toolkit.gameLevelsData); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }
private void LoadEnemyConfig() { _enemyDataConfig.Clear(); GameLevelData currentGameLevel = GameLevelDataController.Instance.CurrentGameLevelData; for (int i = 0; i < currentGameLevel.EnemyDatas.Count; i++) { _enemyDataConfig.Add(currentGameLevel.EnemyDatas[i].UnitPrefabId, currentGameLevel.EnemyDatas[i]); } }
private void LoadTileConfig() { _tileConfig.Clear(); GameLevelData gameLevel = GameLevelDataController.Instance.CurrentGameLevelData; for (int i = 0; i < gameLevel.MapData.TileDatas.Count; i++) { _tileConfig.Add(gameLevel.MapData.TileDatas[i].name, gameLevel.MapData.TileDatas[i]); } }
public void OnLevelLoaded() { GameManager gameManager = GameManager.instance; gameLevelData_ = gameManager.currentLevelData; if (gameLevelData_ != null) { Debug.Log("Successfully loaded level " + gameLevelData_.sceneName); } }
/// <summary> /// Load a GameLevel from an XML file. /// </summary> /// <param name="data">Serialized GameLevelData XML file.</param> public void loadLevel(String path) { // Load GameLevel data GameLevelData data = _gameContentMgr.loadLevelData(path); // Initialize level initLevel(data.NumRows, data.NumCols); // Load all GameTiles for (int row = 0; row < _tileRows; row++) { for (int col = 0; col < _tileCols; col++) { GameTileData tileData = data.Tiles[row * _tileCols + col]; GameTile tile = _tiles[row, col]; Entity tileEntity = new Entity(_gameContentMgr.loadDrawable(tileData.Drawable)); tile.Entity = tileEntity; tile.Active = tileData.Active; tile.Node.translate(0.0f, tileData.Elevation, 0.0f); } } // Load all GameObjects foreach (GameObjectData gobjData in data.GameObjs) { GameObject gobj = null; switch (gobjData.ObjType) { case 0: // GameObject gobj = createGameObject <GameObject>(gobjData.Name, gobjData.Drawable); break; case 1: // GameObjectMovable gobj = createGameObject <GameObjectMovable>(gobjData.Name, gobjData.Drawable); break; case 2: // GameCharacter gobj = createGameObject <GameCharacter>(gobjData.Name, gobjData.Drawable); break; } tileAtIndex(0, 0).Node.attachChildNode(gobj.Node); gobj.Node.translateTo(gobjData.Position); gobj.DirectionVector = gobjData.Direction; gobj.Active = gobjData.Active; } Console.WriteLine("Level loaded: " + path); }
public IEnumerator ChangeLevel(int index) { Debug.Log(string.Format("Loading level {0}", index)); WorldData CurrentWorld = null; if (CNV_TOOL) { CurrentWorld = CNVWorldList.Worlds[WorldToLoad.Value]; } else { if (ConnectionMgr.OFFLINE_DEBUG) { CurrentWorld = WorldList.Worlds[WorldToLoad.Value]; } else { CurrentWorld = DataMgr.Instance.CurrentWorldData; } } Levels = CurrentWorld.LevelList; // Set current level based on selection. CurrentLevel = Levels.Levels[index]; // Download texture for the game. if (!CNV_TOOL) { if (CurrentLevel.Photo == null) { if (!string.IsNullOrEmpty(CurrentLevel.PhotoUrl)) { // Format photo string URL here. } else { Debug.LogErrorFormat("Cannot load photo at URL: {0}!", CurrentLevel.Photo); } } } ToolMgr.Instance.TurnOffAll(); ImageMgr.Instance.FlagAsDirty(); yield return(null); ToolMgr.Instance.TurnOn(CurrentLevel.Tool); }
public static void OpenLocationsData() { GameLevelData data = GetGameLevelsData(); var inspectorType = typeof(EditorGUI).Assembly.GetType("UnityEditor.InspectorWindow"); var inspectorInstance = ScriptableObject.CreateInstance(inspectorType) as EditorWindow; inspectorInstance.Show(); var prevSelection = Selection.activeGameObject; Selection.activeObject = data; var isLocked = inspectorType.GetProperty("isLocked", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public); isLocked.GetSetMethod().Invoke(inspectorInstance, new object[] { true }); Selection.activeGameObject = prevSelection; }
public void LoadNextLevel() { if (currentLevelId < numOfLevels) { playMode = false; currentLevelData_ = gameLevelData[currentLevelId++]; currentLevelData_.UnlockLevel(); //currentSceneName = gameLevelData[currentLevelId++].sceneName; SceneManager.LoadScene(currentLevelData_.sceneName, LoadSceneMode.Single); Debug.Log("Loading next scene : " + currentLevelData_.levelName); } else { Debug.LogError("No more scenes to be loaded"); SceneManager.LoadScene(mainMenuSceneName, LoadSceneMode.Single); } }
/// <summary> /// Setta i players /// </summary> void SetUpPlayers(GameLevelData _gameLeveldata) { Debug.Log("Setup Players"); GamePlayManager.I.Players = LoadPlayersFromDisk(); // TODO: Limitare numero di player a 2. GamePlayManager.I.Players.RemoveRange(2, GamePlayManager.I.Players.Count - 2); SetPlayersOrder(); // Player 1 inizializzazione GamePlayManager.I.PView1.Init(GamePlayManager.I.Players[0]); GamePlayManager.I.Players[0].Mana = GamePlayManager.I.CurrentRound; GamePlayManager.I.Players[0].Life = _gameLeveldata.PlayersStartLife; // Player 2 inizializzazione GamePlayManager.I.PView2.Init(GamePlayManager.I.Players[1]); GamePlayManager.I.Players[1].Mana = GamePlayManager.I.CurrentRound; GamePlayManager.I.Players[1].Life = _gameLeveldata.PlayersStartLife; }
public static void RenameCategory(string categoryOriginalName, string targetCategoryName) { //Get All Levels that Have this category and rename it there too GameLevel[] levels = GetGameLevelsBasedOnCategory(categoryOriginalName); RenameGameLevelsCategory(levels, targetCategoryName); GameLevelData data = GameLevelToolkitWindow.GetGameLevelsData(); for (int i = 0; i < data.allUserCreatedCategories.Count; i++) { if (data.allUserCreatedCategories[i] == categoryOriginalName) { data.allUserCreatedCategories[i] = targetCategoryName; break; } } EditorUtility.SetDirty(data); }
public void InitializeScene() { _character.Initialize(this); _character.transform.position = _characterInitialPosition; _hud.Initialize(this, _character.OnSwipe, _character.OnLeftDown, _character.OnRightDown, _character.OnButtonUp); // level init LevelData levelEntry = GameController.Instance.GetSelectedLevelData(); _levelData = GameController.Instance.DataLoader.GetLevelMaxData(levelEntry.Name); Debug.Log("Level " + _levelData.Name + " max height: " + _levelData.MaxHeight.ToString()); _config = levelEntry.SceneConfig; _cameraPivotPosition.position = new Vector3(0.0f, 0.0f, -5.0f); _baseCameraPivotPos = _cameraPivotPosition.position; InitializeLevel(); CurrentHeight = 0; CurrentPlatforms = 0; TogglePause(false); LevelStarted = false; }
public static GameLevelData GetGameLevelsData() { string[] assetGuid = AssetDatabase.FindAssets(SceneAndResourceFolderName.folderNameValue + " Data"); string path = ""; if (assetGuid.Length == 0) { return(null); } foreach (string item in assetGuid) { path = AssetDatabase.GUIDToAssetPath(item); break; } GameLevelData data = (GameLevelData)AssetDatabase.LoadAssetAtPath(path, typeof(GameLevelData)); return(data); }
public static void DeleteExistingCategory(string targetCategory) { GameLevelData data = GameLevelToolkitWindow.GetGameLevelsData(); //Get All Levels that have this category and assign them to unassigned GameLevel[] levels = GetGameLevelsBasedOnCategory(targetCategory); RenameGameLevelsCategory(levels, data.unassignedCategoryName); //Remove The Item From The data list for (int i = 0; i < data.allUserCreatedCategories.Count; i++) { if (data.allUserCreatedCategories[i] == targetCategory) { data.allUserCreatedCategories.RemoveAt(i); break; } } EditorUtility.SetDirty(data); }
/// <summary> /// Carica da disco le info del livello tramite l'id del livello, /// Operazione da seguire solo nella fase di setup /// </summary> /// <param name="_levelId"></param> /// <returns></returns> GameLevelData GetLevelInfo(string _levelId) { // Creo oggetto riempire e restutire GameLevelData returnGameLevel = new GameLevelData(); GameLevelData[] allLevels = Resources.LoadAll <GameLevelData>("Levels"); foreach (GameLevelData levelData in allLevels) { if (levelData.Id == _levelId) { returnGameLevel = levelData; } } returnGameLevel.AllCards = CardManager.GetAllCards(); #region Costruttore di Livelli //switch (_levelId) { // case 1: // returnGameLevel = new GameLevel() { // StartNumberOfCards = 5, // Cols = new List<BoardCol>() { // new BoardCol() { ColType = -1 }, // new BoardCol() { ColType = 0 }, // new BoardCol() { ColType = 0 }, // new BoardCol() { ColType = 0 }, // new BoardCol() { ColType = -1 }, // } // }; // break; // default: // returnGameLevel = new GameLevel(); // break; //} #endregion return(returnGameLevel); }
void LoadLevelData() { OnNotification.OnNext("Download LevelData.."); Debug.Log("Application.persistentDataPath " + Application.streamingAssetsPath); var filePath = Path.Combine(Application.streamingAssetsPath, FilePath.GAME_LEVEL_DATA); string jsonString; if (Application.platform == RuntimePlatform.Android) //Need to extract file from apk first { WWW reader = new WWW(filePath); while (!reader.isDone) { } jsonString = reader.text; } else { jsonString = GameUtil.GetTextFromFile(filePath); } //OnNotification.OnNext(path); //var jsonData = GameUtil.GetTextFromFile(path); Debug.Log(jsonString); Dictionary <string, object> gameleveldata = JsonConvert.DeserializeObject <Dictionary <string, object> >(jsonString); GameLevelData levelData = JsonConvert.DeserializeObject <GameLevelData>(jsonString); GameDataManager.Instance.SetUpGameLeveldata(levelData); OnNotification.OnNext("LevelData download complete prepareTo Login"); CheckCopmpletedData(-1); Debug.Log("leveldata " + levelData.version); Debug.Log("leveldata gameThemes" + levelData.gameThemesData.Count); Debug.Log("dic count " + gameleveldata.Count); foreach (var data in levelData.gameThemesData) { Debug.Log(string.Format("themename {0} stageLevel {1}", data.themeName, data.gameStages.Count)); } //Debug.Log("gameleveldata "+gameleveldata.gameThemes); }
/// <summary> /// Save the current state of this GameLevel as an XML file. /// </summary> /// <param name="path">File path to save this GameLevel.</param> public void saveLevel(String path) { // XML writer settings for serialization XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; // GameLevelData to hold state data GameLevelData data = new GameLevelData(); // Save GameTiles data.NumRows = _tileRows; data.NumCols = _tileCols; data.Tiles = new GameTileData[_tileRows * _tileCols]; for (int row = 0; row < _tileRows; row++) { for (int col = 0; col < _tileCols; col++) { data.Tiles[row * _tileCols + col] = _tiles[row, col].save(); } } // Save GameObjects data.GameObjs = new GameObjectData[_gameObjs.Count]; int i = 0; foreach (KeyValuePair <String, GameObject> entry in _gameObjs) { data.GameObjs[i] = entry.Value.save(); i++; } // Write XML file using (XmlWriter writer = XmlWriter.Create(path + ".xml", settings)) IntermediateSerializer.Serialize(writer, data, null); // Print success message to console Console.WriteLine("Current level saved to: " + path); }
public static string[] GetAllCategories(bool includeAllType, bool includeUnassigned = true) { GameLevelData data = GameLevelToolkitWindow.GetGameLevelsData(); List <string> categories = new List <string>(); if (includeAllType == true) { categories.Add(data.allCategoriesName); } if (includeUnassigned == true) { categories.Add(data.unassignedCategoryName); } if (data.allUserCreatedCategories.Count > 0) { for (int i = 0; i < data.allUserCreatedCategories.Count; i++) { categories.Add(data.allUserCreatedCategories[i]); } } return(categories.ToArray()); }
public void OnEventButtonStart() { Monster[] list = PoolingManage.Character.GetList <Monster>(); for (int i = 0; i < list.Length; ++i) { list[i].Remove(); } GameDifficult difficult = (GameDifficult)System.Enum.Parse(typeof(GameDifficult), m_difficultyDropdown.captionText.text); int greaterRiftLevel = int.Parse(m_greaterRifitLevel.text); int monsterNum = int.Parse(m_monsterNum.text); for (int i = 0; i < monsterNum; ++i) { Monster monster = (Monster)PoolingManage.Character.Create("Butcher"); Vector3 pos = Vector3.zero; pos.x = Random.Range(-16, 15); pos.z = Random.Range(0, 15); monster.transform.position = pos; GameLevelData.ApplyMonster(monster, difficult, greaterRiftLevel); } Remove(); }
public bool TrySaveLevelMaxRecord(GameLevelData data) { var key = GameData.Find(k => string.Equals(k.Name, data.Name)); if (key == null) { GameData.Add(new GameLevelData { Name = data.Name, MaxHeight = data.MaxHeight, MaxPlatforms = data.MaxPlatforms, }); // save PlayerPrefs.SetInt(data.Name + "_height", data.MaxHeight); PlayerPrefs.SetInt(data.Name + "_platforms", data.MaxPlatforms); return(true); } bool dataSaved = false; if (key.MaxHeight < data.MaxHeight) { key.MaxHeight = data.MaxHeight; PlayerPrefs.SetInt(data.Name + "_height", data.MaxHeight); dataSaved = true; } if (key.MaxPlatforms < data.MaxPlatforms) { key.MaxPlatforms = data.MaxPlatforms; PlayerPrefs.SetInt(data.Name + "_platforms", data.MaxPlatforms); dataSaved = true; } return(dataSaved); }
/// <summary> /// Save Game /// </summary> public void Save() { // Create new Save file. GameStateData stateData = new GameStateData(); GameLevelData levelData = new GameLevelData(); // Write State Data BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Create(PersistentGameState()); bf.Serialize(file, stateData); file.Close(); // Write Level Data file = File.Create(PersistentLevelState()); bf.Serialize(file, levelData); file.Close(); }
/// <summary> /// Creates the level using the data from levelData /// </summary> /// <param name="levelData"></param> private void CreateLevel(GameLevelData levelData) { #region Documentation //Calculate dificulty % , with 0 as minimun and 1 maximum //For example if level is between 6 and 10, difficutly would be 0,0.25,0.50,0.5 and 1 respectively, making the difficulty increasing for every level. //This value will be used for giving a integer value between 2 vars affecting difficulty. //In short , this function calculates an increasing difficulty for a level. #endregion float difficulty = (1.0f / (levelData.MaxLevel - levelData.MinLevel)) * (CurrentLevel - levelData.MinLevel); //Define how many helixes would this level have, according the difficult settings. //More advanced levels will have more helixes. //Example MinHelixNumber=25 and MaxHelixNumber=35 -> the result would be something like 25,25,30,33 and 35 int helixNumber = Mathf.RoundToInt(Mathf.Lerp(levelData.MinHelixNumber, levelData.MaxHelixNumber, difficulty)); //Random.Range(levelData.MinHelixNumber, levelData.MaxHelixNumber); //Assign colors to different pieces deadPieceMaterial.color = levelData.DeadPieceColor; normalPieceMaterial.color = levelData.NormalPieceColor; brokenPieceMaterial.color = levelData.BrokenPieceColor; PlayerController.Instance.SetBallColor(levelData.BallColor); pillarMaterial.color = levelData.PillarColor; //Calculate time needed for this leve, increasing according the level. TimeToPassLevel = Mathf.RoundToInt(Mathf.Lerp(levelData.MinTimeToPassLevel, levelData.MaxTimeToPassLevel, difficulty)); //.Range(levelData.MinTimeToPassLevel, levelData.MaxTimeToPassLevel); //Create the first helix . Every disc is a 12-pieces helix HelixController firstHelixControl = Instantiate(helixPrefab, GPC.firstHelixPosition, Quaternion.identity).GetComponent <HelixController>(); //Pass how many pieces will be disabled , how many would be a kill piece and the colors for each one firstHelixControl.HandleHelix(Random.Range(levelData.MinDisablePiecesNumber, levelData.MaxDeadPiecesNumber), 0, levelData.NormalPieceColor, levelData.DeadPieceColor); firstHelixControl.transform.SetParent(rotaterTrans); //Calculate the height of all helixs, space and distance between the pillar and the first helix float oneHelixHeight = helixPrefab.transform.GetChild(0).GetComponent <Renderer>().bounds.size.y; float totalHelixHeight = oneHelixHeight * helixNumber - (helixNumber - 1) * oneHelixHeight + GPC.helixSpace; float totalSpace = GPC.helixSpace * (helixNumber - 1); float distance = Vector3.Distance(GPC.firstHelixPosition + Vector3.up * oneHelixHeight, pillar.transform.position); //Calculate and set the pillar's height float pillarHeight = totalSpace + totalHelixHeight + Mathf.Round(distance); pillar.transform.localScale = new Vector3(1, pillarHeight, 1); //Create helixes Vector3 nextHelixPos = GPC.firstHelixPosition + Vector3.down * GPC.helixSpace; for (int i = 0; i < helixNumber - 1; i++) { HelixController helixControl = Instantiate(helixPrefab, nextHelixPos, Quaternion.identity).GetComponent <HelixController>(); if (levelData.MovPieces) { helixControl.SetMovPiece(levelData.RandomValues, levelData.OneDirection, levelData.LerpMov, levelData.angleMov, levelData.velMov, levelData.velLerp, levelData.dstMeta, levelData.percentMov); } helixControl.HandleHelix(Random.Range(levelData.MinDisablePiecesNumber, levelData.MaxDisablePiecesNumber), Mathf.RoundToInt(Mathf.Lerp(levelData.MinDeadPiecesNumber, levelData.MaxDeadPiecesNumber, difficulty)), levelData.NormalPieceColor, levelData.DeadPieceColor); helixControl.transform.SetParent(rotaterTrans); nextHelixPos = helixControl.transform.position + Vector3.down * GPC.helixSpace; } //Move bottomHelix object to the bottom bottomPillar.transform.position = nextHelixPos + Vector3.up * oneHelixHeight;; }
private void LoadLevelStateData(GameLevelData levelData) { if (levelData != null) { if (GetCurrentLevel() == levelData.gameData.currentLevel) GameControl.m_gameControl.SetPlayTime(levelData.gameData.playTime); else { Application.LoadLevel(levelData.gameData.currentLevel); return; } } }
protected override void Exit() { GameLevelData level = GameManager.Instance.levels[GameManager.Instance.levelIndex]; GameManager.Instance.RequestLevel(level.sceneName); }
internal void SetData(GameLevelData a_data, int a_index) { label.text = a_data.levelName; button.levelIndex = a_index; }