public void NextLevelGeneration() { LevelConfiguration _level; for (int i = 0; i < _levelConfigurations.Length; i++) { if (_levelConfigurations[i].LevelStarted == true) { _level = _levelConfigurations[i]; _level.LevelPassed = true; _level.LevelStarted = false; if (i++ < _levelConfigurations.Length - 1) { _level = _levelConfigurations[i++]; _level.LevelStarted = true; Game.Load(_level); } else { _level.LevelStarted = false; Menu.Load(); } } } }
// Start is called before the first frame update void Start() { Instance = this; _levelConfiguration = LevelManager.Instance.CurrentLevel; _currentRespawnTime = _levelConfiguration.RespawnTime; _nextSpawn = _currentRespawnTime; ObjectiveManager.LoadConfiguration(_levelConfiguration); if (!_levelConfiguration.AllowFirstInfiniteRecipe) { _firstObjectiveFinished = true; } _tutoPanel.gameObject.SetActive(!_firstObjectiveFinished); ObjectFactory objFactory = ObjectFactory.Instance; foreach (StockItemConfiguration itemConfiguration in _levelConfiguration.ItemsInStock) { objFactory.GenerateObject(InputGridSystem, itemConfiguration.Position, itemConfiguration.Object); } TimeRemaining = _levelConfiguration.LevelTime; GameCanvas.UpdateTimer(TimeRemaining, 0, false); }
private void SetCurrentLevelConfirguration() { LevelConfiguration level = levels[currentLevelIndex]; config.speed = level.speed; config.minRangeObstacleGenerator = level.minRangeObstacleGenerator; config.maxRangeObstacleGenerator = level.maxRangeObstacleGenerator; }
void Awake() { if (instance) { Debug.LogError("Instance of a singleton " + GetType() + " already exists."); } instance = this; }
public void LoadLevel(string levelData) { LevelData = JsonUtility.FromJson <LevelData>(levelData); configuration = new LevelConfiguration(LevelData); bubbleFactory.Configuration = configuration; CreateLevel(LevelData); powerUpController.Setup(LevelData.PowerUpFills); }
void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); } }
public void RestartLevel() { for (int i = 0; i < _levelConfigurations.Length; i++) { if (_levelConfigurations[i].LevelStarted == true) { _level = _levelConfigurations[i]; Game.Load(_level); } } }
public void LoadLevel(int index) { if (index < 0 || index >= Levels.Count) { return; } MusicManager.Instance.PlaySound("Page"); CurrentLevel = Levels[index]; SceneManager.LoadScene("Play Scene"); }
public bool HasNextLevel(LevelConfiguration config) { int index = Levels.IndexOf(config); if (index == -1) { return(false); } ++index; return(index < Levels.Count); }
void Update() { animator.SetBool("isAlive", alive); if (alive) { if (transform.position.y < LevelConfiguration.GetInstance().deathVerticalLevel) { hitPoints = 0; HandleDead(); } } }
void OnDead() { if (lives > 0) { // Respawn alive = true; hitPoints = maxHitpoints; rigidbody.velocity = Vector2.zero; transform.position = spawnPoint; } else { LevelConfiguration.GetInstance().OnGameOver(); } }
// Start is called before the first frame update void Awake() { if (Instance != null) { Destroy(gameObject); return; } Instance = this; DontDestroyOnLoad(this); if (CurrentLevel == null) { CurrentLevel = Levels[0]; } }
private void DrawSceneObjectField(LevelConfiguration level) { var oldScene = AssetDatabase.LoadAssetAtPath <SceneAsset>(level.TargetScenePath); serializedObject.Update(); EditorGUI.BeginChangeCheck(); var newScene = EditorGUILayout.ObjectField("Scene", oldScene, typeof(SceneAsset), false) as SceneAsset; if (EditorGUI.EndChangeCheck()) { string newPath = AssetDatabase.GetAssetPath(newScene); var scenePathProperty = serializedObject.FindProperty(nameof(level.TargetScenePath)); scenePathProperty.stringValue = newPath; } serializedObject.ApplyModifiedProperties(); }
void OnLevelWasLoaded() { if (IsCanUse) { if (Application.loadedLevelName != defaultLevel) { trackChunkManager = TrackChunkManager.GetInstance(); currentLevelConfiguration = LevelConfiguration.Instance; PrefabInitializationManager = FindObjectOfType <PrefabInitializationManager>(); if (PrefabInitializationManager != null) { foreach (PrefabItem prefabItem in PrefabInitializationManager.PrefabItems) { if (prefabItem.prefab.GetComponent <AbstractPoolableObject>() != null) { Pool.InstantiateAndAdd( prefabItem.prefab.GetComponent <AbstractPoolableObject>(), prefabItem.count); } } } if (Controller.GetInstance() != null) { TrackAbstract.GetInstance().CalculateTrackState(currentLevelConfiguration.DefaultPosition); Controller.GetInstance().MoveToPosition(currentLevelConfiguration.DefaultPosition); trackChunkManager.Initialize(currentLevelConfiguration.DefaultPosition); CollectionInitializedEvent(info.bonuses); } } else { Pool = new Pool <AbstractPoolableObject>(); trackChunkManager = null; currentLevelConfiguration = null; PrefabInitializationManager = null; } } }
//create new player with 5 ships public void CreateDefaultUser() { //create default reflector LevelConfiguration newPlayer = new LevelConfiguration (); //save player reflector if (newPlayer != null) { userPlayer = newPlayer; if (!browserVersion) SaveAndLoad.inst.SaveLevel2 (userPlayer); else{ SaveAndLoad.inst.SavePlayerAtPlayerPrefs (userPlayer); } playerID = 0; PlayerPrefs.SetInt ("ActivePlayerID", playerID); activePlayerID = PlayerPrefs.GetInt("ActivePlayerID", 0); } }
public void UpdateLevelConfiguration(LevelConfiguration levelConfiguration) { using (var db = new SqlConnection(_connectionString)) { var parameters = new { levelConfiguration.Name, levelConfiguration.Description, levelConfiguration.TargetSpawnDelay, levelConfiguration.TargetLifespan, levelConfiguration.IsPublic }; var sql = SqlCrudHelper.GetUpdateStatement(parameters, levelConfiguration.GetType().Name); sql += " WHERE LevelConfigurationId = @LevelConfigurationId"; db.Execute(sql, levelConfiguration); } }
private void RollAllRandomBubbles(LevelManipulator manipulator) { var rng = new System.Random(); var randoms = LevelConfiguration.CreateRandomizers(rng, manipulator.Randoms.ToArray()); ApplyTransformation(manipulator, b => { var modifier = b.modifiers.First(m => m.type == BubbleModifierType.Random); var replacement = new BubbleData(b.X, b.Y, randoms[int.Parse(modifier.data)].GetValue()); var modifiers = b.modifiers.Where(m => m.type != BubbleModifierType.Random).ToArray(); if (modifiers.Length > 0) { replacement.modifiers = modifiers; } return(replacement); }); }
public void Initialize(BattleLogicController battleLogicController, Dictionary <UnitType, int> unitCredits, LevelConfiguration levelConfiguration) { var unitCreatorGO = Instantiate(unitCreatorPrefab); unitCreator = unitCreatorGO.GetComponent <UnitCreator>(); unitCreator.Initialize(); unitCreator.unitCreateEvent += OnUnitCreation; playerBar = GameObject.FindGameObjectWithTag("PlayerBar").GetComponent <ArmyBar>(); enemyBar = GameObject.FindGameObjectWithTag("EnemyBar").GetComponent <ArmyBar>(); SetUpButtons(unitCredits); winScreen = GameObject.FindGameObjectWithTag("WinCondition"); loseScreen = GameObject.FindGameObjectWithTag("LoseCondition"); this.battleLogicController = battleLogicController; this.levelConfiguration = levelConfiguration; }
public Guid CreateLevelConfiguration(LevelConfiguration levelConfiguration) { using (var db = new SqlConnection(_connectionString)) { var parameters = new { levelConfiguration.LevelId, levelConfiguration.OrganisationId, levelConfiguration.CreatedById, levelConfiguration.Name, levelConfiguration.Description, levelConfiguration.TargetSpawnDelay, levelConfiguration.TargetLifespan, levelConfiguration.IsPublic }; var sql = SqlCrudHelper.GetInsertStatement(parameters, levelConfiguration.GetType().Name, "LevelConfigurationId"); Guid newId = db.ExecuteScalar <Guid>(sql, parameters); return(newId); } }
public void LoadPreviousPlayer() { activePlayerID = PlayerPrefs.GetInt ("ActivePlayerID", 0); if (activePlayerID != 0) { if(!browserVersion){ userPlayer = SaveAndLoad.inst.LoadLevel(activePlayerID.ToString()); } else if (browserVersion){ userPlayer = SaveAndLoad.inst.LoadPlayerAtPlayerPrefs(activePlayerID.ToString()); } if(userPlayer == null){ PlayerPrefs.SetInt ("ActivePlayerID", 0); Debug.Log("Player Load failed"); } else{ Debug.Log ("Active player has been loaded"); } } else if (activePlayerID == 0){ CreateDefaultUser(); Debug.Log ("New player has been created"); } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. _spriteBatch = new SpriteBatch(GraphicsDevice); var viewPort = _graphics.GraphicsDevice.Viewport; var screenConfiguration = new GameScreenConfiguration(viewPort.Height, viewPort.Width); var levelConfiguration = new LevelConfiguration(12, Color.Black, 12, 52, Color.Black, 12, 64, Color.Black, 8, Color.Black, 42, 12, 8); var textConfiguration = new TextConfiguration(Color.Black, 2); var textTexture = GetPlain2DTexture(textConfiguration.TextSize); var texture = GetPlain2DTexture(1); _eventAggregator = new EventAggregator(); _randomizer = new Randomizer.Randomizer(); _keyboardManager = new KeyboardManager(_eventAggregator, TimeSpan.Zero); _playerInput = new PlayerInput(_eventAggregator); var collisionManager = new CollisionManager(_eventAggregator); var drawer = new Drawer(_spriteBatch, texture); var textDrawer = new Drawer(_spriteBatch, textTexture); var pixelTextDrawer = new PixelTextDrawer(textDrawer); var particleManager = new ParticleManager(_eventAggregator, drawer, _randomizer); var startScreen = new StartScreen(_eventAggregator, pixelTextDrawer, screenConfiguration, textConfiguration); var levelFactory = new LevelFactory(_eventAggregator, screenConfiguration, levelConfiguration); var levelManager = new LevelManager(_eventAggregator, levelFactory, collisionManager, particleManager, drawer); var gameScreen = new GameScreen(_eventAggregator, levelManager); _screenManager = new ScreenManager(_eventAggregator, startScreen, gameScreen); _keyboardManager.Load(); _playerInput.Load(); _screenManager.Load(); }
private IEnumerator RunLevel(LevelConfiguration config) { // Deactivate bags from previous config if (currentConfig != null) { if (currentConfig.bagConfiguration != null) { currentConfig.bagConfiguration.SetActive(false); } } // Setup new config currentConfig = config; // Add this config's data to the session data for the API sessionData.AddLevelData(levelIndex + 1, currentConfig.thresholdScore, currentConfig.levelTime); if (currentConfig.bagConfiguration != null) { currentConfig.bagConfiguration.SetActive(true); } levelStartTime = Time.unscaledTime; // Special case for middle level if (levelIndex == 2) { // Update colors of hands SetMultiHandColors(); } else { // Update colors of hands RevertHandColors(); } int counter = currentConfig.levelTime; // Initialize timer for the level Debug.Log("Time: " + counter); timerText.text = "TIME: " + counter; while (counter > 0) { yield return(new WaitForSeconds(1)); counter--; // Count down timer Debug.Log("Time: " + counter); timerText.text = "TIME: " + counter; } // If we are here the timer is done. // See if the score threshold was met! int leftHandScore = ScoreManager.instance.GetLeftScore(); int rightHandScore = ScoreManager.instance.GetRightScore(); if (leftHandScore >= currentConfig.thresholdScore || rightHandScore >= currentConfig.thresholdScore) { sessionData.CompleteLevel(levelIndex - 1, leftHandScore, rightHandScore, levelScoreThresholdTime - levelStartTime); ScoreManager.instance.SetTotalScore(); ScoreManager.instance.ResetScore(); levelScoreThresholdTime = 0.0f; levelStartTime = 0.0f; StartNextLevel(); } else { EndGame(); } }
LevelConfiguration CreateTestPlayer() { LevelConfiguration np = new LevelConfiguration (); return np; }
public void Resume(LevelConfiguration levelConfiguration) { this.levelConfiguration = levelConfiguration; buttons = GameObject.FindGameObjectsWithTag ("Button"); enteredPortalPiece = currentPuzzlePiece.name.Contains ("portal") && PuzzlePieceScript.GetSideOfPortal(currentPuzzlePiece) == currentDirection; clickedButtonWhileOnCurrentPuzzlePiece = ButtonNearby (); carStarted = true; PlayEngineSound (); }
private void GetConfiguration() { var levelIndex = Finder.FindMandatory <LevelMetaLoader>().LevelIndex; levelConfiguration = LevelManager.Instance.FindLevelConfiguration(levelIndex); }
public void SetLevelConfiguration(LevelConfiguration levelConfiguration) { _levelConfiguration = levelConfiguration; }
public void StartTheGame(LevelConfiguration levelConfiguration) { this.levelConfiguration = levelConfiguration; currentPuzzlePiece = ClosestPuzzlePiece (null); if (ExplorerLevel ()) currentPuzzlePiece = ClosestPuzzlePiece (currentPuzzlePiece); currentPuzzlePieceConnections = PuzzlePieceScript.PuzzlePieceConnections.GetPuzzlePieceConnections (currentPuzzlePiece); currentConnection = currentPuzzlePieceConnections.getConnectionForSide (PuzzlePieceScript.Coordinate.WEST); currentDirection = currentConnection.OtherSide (PuzzlePieceScript.Coordinate.WEST); currentCoordinateIndex = currentConnection.getFirstCoordinateIndexFor (currentDirection); currentCoordinate = currentConnection.coordinates [currentCoordinateIndex]; buttons = GameObject.FindGameObjectsWithTag ("Button"); carStarted = true; PlayEngineSound (); }
public override void OnEnabled() { levelConfiguration = AssetFinder.SafeSingleAssetFind <LevelConfiguration>("t:" + typeof(LevelConfiguration)); }
public string PlayerReflectorToString(LevelConfiguration t) { Hashtable toSave = new Hashtable(); toSave.Add ("PlayerData", t); BinaryFormatter formatter = new BinaryFormatter(); using (MemoryStream memoryStream = new MemoryStream()) { formatter.Serialize(memoryStream, toSave); byte[] DataToSave = memoryStream.ToArray(); string dataString = System.Convert.ToBase64String(DataToSave); return dataString; } }
//SAVE LOAD OPERATIONS WITH PLAYERS AT PLAYER PREFS public void SavePlayerAtPlayerPrefs(LevelConfiguration p_ref) { Hashtable toSave = new Hashtable(); toSave.Add ("PlayerData",p_ref); BinaryFormatter formatter = new BinaryFormatter(); using (MemoryStream memoryStream = new MemoryStream()) { formatter.Serialize(memoryStream, toSave); byte[] DataToSave = memoryStream.ToArray(); string dataString = System.Convert.ToBase64String(DataToSave); PlayerPrefs.SetString("PlayerData", dataString); } }
void SaveSelectedLevel() { LevelConfiguration newLC = new LevelConfiguration (); newLC.levelNum = curentLevel; BaseActivityElement[] aEls = levelContainer.GetComponentsInChildren<BaseActivityElement> (); for (int i = 0; i < aEls.Length; i++) { BaseElement e = aEls[i]; BaseActivityElement _bae = e as BaseActivityElement; ElementRflector el = new ElementRflector(); newLC.elements.Add(el); el.elementType = e.ElementType; el.position = new float[3]{e.transform.position.x, e.transform.position.y, e.transform.position.z}; IwPropertyValue<PropertyType, int>[] elProps = e.gameObject.GetComponents<IwPropertyValue<PropertyType, int>>(); for (int p = 0; p < elProps.Length; p++) { IwPropertyValue<PropertyType, int> _be = elProps[p]; PropertyReflector pr = new PropertyReflector(_be.propType, _be.val, _be.maxVal); el.properties.Add(pr); } if(_bae != null){ IElementFunction<BaseElement>[] elfuncs = e.gameObject.GetComponents<IElementFunction<BaseElement>>(); for (int f = 0; f < elfuncs.Length; f++) { IElementFunction<BaseElement> func = elfuncs[f]; FunctionReflector fr = new FunctionReflector(func.functionType); el.functions.Add(fr); } } Debug.Log("element saved"); } // if (curentLevel >= levels.Count) { // levels.Add (newLC); // newLC.levelNum = levels.Count - 1; // curentLevel = newLC.levelNum; // } else { // levels[curentLevel] = newLC; // } saveAndLoad.SaveLevelToPrefs (newLC); }
public void ActivateLevel(LevelConfiguration levelConfiguration) { activeLevelConfiguration.ResetStageLevelNumber(); activeLevelConfiguration.ChangeParameters(levelConfiguration.Parameters); DefaultLevel.Load(activeLevelConfiguration); }
public void LoadConfiguration(LevelConfiguration configuration) { // Spawn tutorial objective SpawnObjective(configuration.Objectives[0]); }
public void SetLoadingConfiguration(LevelConfiguration levelConfiguration) { _loadingLevelConfiguration = levelConfiguration; }
public static void Load(LevelConfiguration argument, LoadSceneMode loadSceneMode = LoadSceneMode.Single) { LoadScene(_sceneName, loadSceneMode, argument); }
//SAVE LOAD OPERATIONS WITH PLAYERS public void SaveLevel2(LevelConfiguration p_ref) { Hashtable toSave = new Hashtable(); toSave.Add ("LevelData",p_ref); BinaryFormatter formatter = new BinaryFormatter(); using (MemoryStream memoryStream = new MemoryStream()) { formatter.Serialize(memoryStream, toSave); BinarySaver.SavePlayer(toSave, p_ref.levelNum.ToString()); } }
// save load operations with goals public void DeleteLevelFile(LevelConfiguration gl) { Debug.Log ("Fille to delete: "+Application.dataPath + "/Levels Data/" + gl.levelNum); File.Delete (Application.dataPath + "/Levels Data/" + gl.levelNum+".neo"); }