void Start() { bonus_to_params = GameObject.FindGameObjectWithTag("LevelParams").GetComponent <LevelParams>(); leveltext.text = "LEVEL: " + bonus_to_params.levelnumber.ToString(); PauseButton(); ShowSkills(); }
private IEnumerator ResultsAnim() { if (SceneUtil.IsCurrentLevelIndex) { LevelParams level = SceneUtil.GetParams(SceneUtil.LevelIndex); if (level.HasTrophy) { GameJolt.API.Trophies.Unlock(level.TrophyID); } } foreach (TutorialBoard tb in FindObjectsOfType<TutorialBoard>()) { Destroy(tb.gameObject); } DungeonInfo info = DungeonInfo.Instance; success.text = string.Format("<color=yellow>{0}</color>\ncleared", info.LevelName); success.gameObject.SetActive(true); yield return Util.Lerp(successFadeInDuration, t => success.color = Color.Lerp(Color.clear, Color.white, t)); window.gameObject.SetActive(true); yield return Util.Lerp(windowTransitionDuration, t => window.transform.localScale = Vector2.Lerp(Vector2.up, Vector2.one, t)); exit.gameObject.SetActive(true); yield return WaitThenDisplay(1f, results.gameObject); foreach (GameObject display in stats) { yield return WaitThenDisplay(0.25f, display); } yield return Util.AnimateScore(time, 0, (int)Time.timeSinceLevelLoad, 0.25f, scoreSound); int stepCount = Player.Instance.Stats.StepCount; yield return Util.AnimateScore(steps, 0, stepCount, 0.25f, scoreSound); isDoneShowingResults = true; // Ranking and leaderboard yield return AnimateRank(stepCount); }
void Start() { bonus_to_params = GameObject.FindGameObjectWithTag("LevelParams").GetComponent <LevelParams>(); transform.SetParent(null); Instantiate(soundmanager, Camera.main.transform); }
public FinalBossData(MapHolder holder, LevelParams param) : base(holder) { type = MapType.FinalBoss; tutorialLevel = false; difficulty = param.difficulty; try { if (param.typeParameter != null) { variant = (MapVariant)param.typeParameter; } else { variant = MapVariant.Wide32; } } catch (Exception e) { Debug.LogError(e.StackTrace); variant = MapVariant.Wide32; } switch (variant) { case MapVariant.Wide32: regionsX = 4; regionsY = 3; break; } }
public void PrepareGeneration() { Database = levelGenData.database; genParams = levelGenData.genParams; moduleHolder = new GameObject(); moduleHolder.name = "Module Holder"; moduleHolder.transform.parent = this.transform.parent; }
public LevelData GetLevel(LevelParams lp) { List <Question> qs = GetQuestions(lp); List <EnemyConfig> ecs = GetEnemies(lp, qs); LevelData outlvl = new LevelData(ecs, qs); return(outlvl); }
private void SetupIfIsOfficialLevel() { if (SceneUtil.IsCurrentLevelIndex) { LevelParams level = SceneUtil.GetParams(SceneUtil.LevelIndex); this.stage.text = string.Format("{0}-{1}", level.WorldIndex, level.StageIndex); this.location.text = level.Name; } }
void SetCurrentLevel(int levelIndex) { currentLevelIndex = levelIndex; LevelParams lp = GetCurrentLevelParams(); foreach (FoodSpawnerParams fsp in lp.spawnerParams) { fsp.Reset(); } Debug.Log("Started " + lp.levelName); }
public static LevelParams GetParams() { LevelParams genParams = (LevelParams)ScriptableObject.CreateInstance("LevelParams"); genParams.seed = GetSeed(); genParams.mainPathRooms = GetMainPathRooms(); genParams.maxExits = GetMaxExits(); genParams.maxRoomCount = GetMaxRoomCount(); return(genParams); }
//See if we need to change levels based on the score. public void AdviseScore(int score) { //Is there a next level? if (currentLevelIndex + 1 < gameParams.levels.Length) { //Is our score good enough? LevelParams nextLevel = gameParams.levels[currentLevelIndex + 1]; if (score > nextLevel.activationScore) { SetCurrentLevel(currentLevelIndex + 1); } } }
void Start() { LevelParams = GameObject.FindGameObjectWithTag("LevelParams").GetComponent <LevelParams>(); if (isEvil) { plane.GetComponent <Renderer>().material.color = Color.red; } else { plane.GetComponent <Renderer>().material.color = Color.green; } }
//------------Generate math questions List <Question> GetQuestions(LevelParams lp) { List <Question> outputQues = new List <Question>(); if (!lp.bonuslvl) //make single question { outputQues.Add(MakeQuestion(lp.useOps, lp.quesTypes)); } else { Debug.LogWarning("Not ready to make bonus levels yet"); } return(outputQues); }
public void Init() { levelIndex = transform.GetSiblingIndex(); this.destination = levelIndex + SceneUtil.LEVEL_START_INDEX; LevelParams level = SceneUtil.GetParams(levelIndex); WorldIndex = level.WorldIndex; levelNameText.text = level.Name; indexText.text = string.Format("{0}-{1}", level.WorldIndex, level.StageIndex); if (level.HasTrophy) { levelNameText.color = Color.yellow; } }
void Start() { if (bonus_value < 35) { bonus_value = 35; } bonus_to_params = GameObject.FindGameObjectWithTag("LevelParams").GetComponent <LevelParams>(); if (isEvil) { SetEvil(); } else { bonus_to_params.bonuslist.Add(this.gameObject); bonus_to_params.bonusinlevel++; } }
void StartLevel(bool generate) { Debug.Log("Starting Level"); ResetLevelCtxt(); // First reset the context around the current level if (generate) { LevelParams lp = ComputeParams(lvl); currentLevel = levelFactory.GetLevel(lp); currentQuestion = currentLevel.questions[0]; } SpawnLevel(currentLevel); FreezePlayer(true); FreezeEnemiesShoot(true); StartCoroutine(StartAndWaitCountdown(2, 0)); uiMathTable.SetQuestion(currentQuestion); uiLevelCounter.text = lvl.ToString(); currentStats.maxlvl = lvl; }
LevelParams ComputeParams(int level) { List <mathOp> mo = new List <mathOp>() { mathOp.Add, mathOp.Subtract, mathOp.Multiply }; // Hard code allow all right now List <quesType> qt = new List <quesType>() { quesType.Basic }; // only basic for now bool bonuslvl = false; int bonuscount = 0; Vector2Int shiprange = new Vector2Int(2, 5); Vector2 speedR = new Vector2(0.4f, 1.5f); Vector2 shotDelayR = new Vector2(0.5f, 1.5f); float bulletSpeed = 1.0f; LevelParams lp = new LevelParams(mo, qt, bonuslvl, bonuscount, shiprange, speedR, shotDelayR, bulletSpeed); return(lp); }
void RunCurrentLevel(float dt) { LevelParams lp = GetCurrentLevelParams(); for (int i = 0; i < lp.spawnerParams.Length; i++) { FoodSpawnerParams fsp = lp.spawnerParams[i]; if (fsp.Step(dt)) { GameObject g = GetSpawnObject(fsp); GameObject spawned = Instantiate(g, GetSpawnPos(), Quaternion.identity); //See if we can set the movement speed of objects. Move m = spawned.GetComponent <Move>(); if (m != null) { m.moveSpeed = lp.foodMoveSpeed; } } } }
private void SwitchToNextLevelMode() { if (taskNumber < 4) { taskNumber++; levelParams = new LevelParams(currentLevelNumber); StartTask(); } else { ChangeButtonInteractable(false); finalMessage.text = "Level complete"; finalMessage.enabled = true; shapesPanel.SetActive(false); completeButton.SetActive(false); nextLevelButton.SetActive(true); buttonDescription.text = "Next level"; buttonDescription.enabled = true; } }
void Update() { if (gameObject.transform.childCount > 0) { c.g -= Time.deltaTime * timescale; r.materials[0].color = c; if (c.g < 0.1f) { SoundManager manager = GameObject.FindGameObjectWithTag("SoundSystem").GetComponent <SoundManager>(); manager.PlaySound(AudioEnum.Boom); Instantiate(boomeffect, gameObject.transform.position, Quaternion.identity); gameObject.transform.GetChild(0).SetParent(null); bonus_to_params = GameObject.FindGameObjectWithTag("LevelParams").GetComponent <LevelParams>(); bonus_to_params.Damage(damagevalue); } } else if (c.g < 1) { c.g += Time.deltaTime * timescale; r.materials[0].color = c; } }
public static LevelGenerationParams GetRandom(string seed, LevelData.LevelType type, Biome biome = null) { Rand.SetSyncedSeed(ToolBox.StringToInt(seed)); if (LevelParams == null || !LevelParams.Any()) { DebugConsole.ThrowError("Level generation presets not found - using default presets"); return(new LevelGenerationParams(null)); } var matchingLevelParams = LevelParams.FindAll(lp => lp.Type == type && lp.allowedBiomes.Any()); if (biome == null) { matchingLevelParams = matchingLevelParams.FindAll(lp => !lp.allowedBiomes.Any(b => b.IsEndBiome)); } else { matchingLevelParams = matchingLevelParams.FindAll(lp => lp.allowedBiomes.Contains(biome)); } if (matchingLevelParams.Count == 0) { DebugConsole.ThrowError($"Suitable level generation presets not found (biome \"{(biome?.Identifier ?? "null")}\", type: \"{type}\"!"); if (biome != null) { //try to find params that at least have a suitable type matchingLevelParams = LevelParams.FindAll(lp => lp.Type == type); if (matchingLevelParams.Count == 0) { //still not found, give up and choose some params randomly matchingLevelParams = LevelParams; } } } return(matchingLevelParams[Rand.Range(0, matchingLevelParams.Count, Rand.RandSync.Server)]); }
public FourRegionComplexLevel(MapHolder holder, LevelParams param) : base(holder) { type = MapType.FourRegion; tutorialLevel = true; variant = param.variant; }
public FindBossLevel(MapHolder holder, LevelParams param) : base(holder) { type = MapType.FindBoss; tutorialLevel = true; variant = param.variant; }
private void DetermineLevelParams() { DetermineCurrentLevelNumber(); levelParams = new LevelParams(currentLevelNumber); }
void Start() { bonus_to_params = GameObject.FindGameObjectWithTag("LevelParams").GetComponent<LevelParams>(); }
public SixRegionLevel(MapHolder holder, LevelParams param) : base(holder) { type = MapType.SixRegions; tutorialLevel = true; }
//------------Generate Enemies from parameters List <EnemyConfig> GetEnemies(LevelParams lp, List <Question> qs) { List <EnemyConfig> outCfg = new List <EnemyConfig>(); // pick random number of enemy ships between specified level params, making sure we have enough to cover all questions int shipcount = Random.Range(Mathf.Max(lp.shipCountRange.x, qs.Count), Mathf.Max(lp.shipCountRange.y, qs.Count)); int row = MAXROWS - 1; // The row selection should be random, but starting from back for now if (shipcount > 9 || shipcount < 2) { Debug.LogWarningFormat("I'm not prepared to handle only {0} ship(s)", shipcount); return(outCfg); } while (shipcount != 0 || row >= 0) { int s = Random.Range(1, 4); // pick number between 1 and 3 for # ships per row if (shipcount < s) { s = shipcount; shipcount = 0; } else { shipcount -= s; } float spacing = width / (s + 1); float startx = spacing - width / 2f; for (int i = 0; i < s; i++) { MovementType mt = (MovementType)Random.Range(0, System.Enum.GetNames(typeof(MovementType)).Length); // random movement type List <ShootType> availAttacks = System.Enum.GetValues(typeof(ShootType)).Cast <ShootType>().ToList(); // list of all actions at first switch (mt) { case MovementType.Static: availAttacks.Remove(ShootType.None); break; case MovementType.Horizontal: availAttacks.Remove(ShootType.CircleBurst); break; case MovementType.Circle: availAttacks.Remove(ShootType.CircleBurst); break; } ShootType at = availAttacks[Random.Range(0, availAttacks.Count)]; float shotDelay = Random.Range(lp.shotDelayRange.x, lp.shotDelayRange.y); float moveSpeed = Random.Range(lp.speedRange.x, lp.speedRange.y); float bulletSpeed = lp.bulletSpeed; int bulletCount = 0; if (at == ShootType.CircleBurst) // if we're a circle burst, we need to set addtl parameters { bulletCount = 12; bulletSpeed = bulletSpeed / 2.5f; //Reduce the speed here, it's pretty wacky if too fast shotDelay = shotDelay * 2.0f; //Also so many bullets, slow em down } Debug.LogFormat("Row: {0}", row); Vector3 pos = new Vector3(startx + spacing * i, rowPos[row], 0f) - posOffset; string ans = Random.Range(FAKEMIN, FAKEMAX).ToString(); // Get fake ans (ok if randomly matches right ans for now) outCfg.Add(new EnemyConfig(mt, at, pos, shotDelay, moveSpeed, bulletSpeed, ans, bulletCount)); } row--; } //Now that you've got the ships in the correct positions, add the held values if (qs.Count > outCfg.Count) { Debug.LogErrorFormat("Somehow we have more questions than ships to put ans on? {0} > {1}", qs.Count, outCfg.Count); } List <int> posAvail = Enumerable.Range(0, outCfg.Count).ToList(); // get list of places where we could put answers so we don't double up foreach (Question q in qs) { int pos = Random.Range(0, posAvail.Count); int idx = posAvail[pos]; posAvail.RemoveAt(pos); EnemyConfig cfg = outCfg[idx]; outCfg[idx] = new EnemyConfig(cfg, q.ans); // update cfg with new answer, this is a pretty kludgey way to get around struct immutability } return(outCfg); }
public ChunkController(Transform chunksContainer, LevelParams levelParams) { _chunksContainer = chunksContainer; _levelParams = levelParams; }
// Use this for initialization void Start() { Lparams = GameObject.FindGameObjectWithTag("LevelParams").GetComponent <LevelParams>(); }
public void overridePresetValues(LevelParams levelParams) { genParams = levelParams; }
public GenericMonsterLevel(MapHolder holder, LevelParams param) : base(holder) { type = MapType.GenericMonster; tutorialLevel = false; variant = param.variant; difficulty = param.difficulty; // easy if (difficulty == 1) { variant = Random.Range(15, 17 + 1); regionsX = 4; regionsY = 3; } else if (difficulty == 3) { variant = Random.Range(18, 20 + 1); } else { if (variant == 1) { variant = Random.Range(1, maxMediumVariant + 1); } } // adjust settings if (variant >= 1 && variant <= 4) { regionsX = 4; regionsY = 3; } if (variant >= 5 && variant <= 6) { regionsX = 6; regionsY = 3; } if (variant >= 7 && variant <= 9) { regionsX = 6; regionsY = 3; } if (variant >= 10 && variant <= 14) { regionsX = 5; regionsY = 3; } switch (variant) { case 18: case 19: case 20: regionsX = 4; regionsY = 4; break; } }