public Listening1QA(TestLevel level, LevelSection section) { InitializeComponent(); Level = level; Section = section; m_pageViewModel = new ListeningQAVM(); cbbSettingLevel.ItemsSource = m_pageViewModel.QuestionLevels; cbbSettingPurpose.ItemsSource = m_pageViewModel.QuestionPurposes; DataContext = m_pageViewModel; ResetPage(); SelectedParagraphPropertyChanged(); //var paragraphs = GetParagraph(Level.ToString().GetSubTypeFromTestLevel(), QuestionType.LQA1.ToString()); //foreach (var paragraph in paragraphs) //{ // m_pageViewModel.ItemsSource.Add(paragraph); //} //DataContext = m_pageViewModel; //SelectedParagraphPropertyChanged(); //if (m_pageViewModel.ItemsSource.Count > 0) // m_pageViewModel.Current = m_pageViewModel.ItemsSource[0]; }
public WritingQA(TestLevel level, LevelSection section) { InitializeComponent(); Level = level; Section = section; m_pageViewModel = new WritingQAVM(); cbbSettingLevel.ItemsSource = m_pageViewModel.QuestionLevels; cbbSettingPurpose.ItemsSource = m_pageViewModel.QuestionPurposes; DataContext = m_pageViewModel; ResetPage(); CurrentPropertyChanged(); //var paragraphs = GetQuestion(Level.ToString().GetSubTypeFromTestLevel(), QuestionType.WQA.ToString()); //foreach (var paragraph in paragraphs) //{ // m_pageViewModel.ItemsSource.Add(paragraph); //} //DataContext = m_pageViewModel; //CurrentPropertyChanged(); }
public void Attach(LevelSection from, LevelSection to) { var spawnPosition = from.EndPosition(); spawnPosition.z += to.MinForwardExtend(); to.transform.position = spawnPosition; }
void Awake() { LevelSection previousSection = Beginning; for (int i = 0; i < Sections; ++i) { previousSection = Instantiate(LevelSections[Random.Range(0, LevelSections.Count)], previousSection.Exit.transform.position, Quaternion.identity); } }
public void Free(LevelSection levelSection) { this.DelayedAction(() => { _activelevels.Remove(levelSection); levelSection.gameObject.SetActive(false); _passivelevels.Push(levelSection); }, 2); }
private void OnTriggerEnter2D(Collider2D collision) { LevelSection currentPiece = collision.gameObject.GetComponent <LevelSection>(); if (currentPiece != null) { Destroy(currentPiece.gameObject); levelManager.CheckForCurrentThreshold(); } }
private LevelSection Transform(LevelSection source, LevelSection destination) { destination.SectionId = source.SectionId; destination.LevelId = source.LevelId; destination.StationId = source.StationId; destination.SchoolYear = source.SchoolYear; destination.SectionAdviser.AdviserId = source.SectionAdviser.AdviserId; return(destination); }
public void LoadNextLevel() { _currentSection.OnComplete(); ++_currentLevel; var nextLevel = Get(_currentLevel); Attach(_currentSection, nextLevel); Free(_currentSection); _currentSection = nextLevel; _currentSection.Init(LevelDb.GetLevel(_currentLevel)); }
/// <summary> /// Generates a single row of scenery blocks. /// </summary> private void GenerateBlocks() { LevelSection levelSection = levelSections[currentSection]; // calculate the number of blocks we need to generate to fill a row int numBlocksRadius = Mathf.CeilToInt(horizonWidth / kBlockSize) / 2; int numBlocksAcross = 2 * numBlocksRadius + 1; // get the current LevelSection to generate the blocks for this row levelSection.StartNewBlockRow(currentScrollPos); for (int x = -numBlocksRadius; x <= numBlocksRadius; ++x) { // generate a new block GameObject block = levelSection.GenerateBlock(currentScrollX + x * kBlockSize, currentScrollPos); // potentially spawn some powerups within the block if (levelSection.PowerupSpawner != null) { levelSection.PowerupSpawner.SpawnPowerups(block); } // add the block to our live list blocks.Add(block); } // check if the current section has now generated all its rows if (levelSection.IsCompleted()) { levelSection.Reset(); // move on to the next section, looping around when we reach the end int nextSectionIdx = currentSection + 1; if (nextSectionIdx == levelSections.Length) { nextSectionIdx = startSectionIndex; } SetCurrentSectionIndex(nextSectionIdx); } // update our scroll position by the size of one row currentScrollPos += kBlockSize; // remove any blocks that have moved behind the camera int blockRows = Mathf.CeilToInt(0.5f + (horizonDist / kBlockSize)); while (blocks.Count > numBlocksAcross * blockRows) { Destroy(blocks[0]); blocks.RemoveAt(0); } }
public ReadingQA(TestLevel level, LevelSection section) { InitializeComponent(); Level = level; Section = section; m_pageViewModel = new ReadingQAVM(); cbbSettingLevel.ItemsSource = m_pageViewModel.QuestionLevels; cbbSettingPurpose.ItemsSource = m_pageViewModel.QuestionPurposes; DataContext = m_pageViewModel; ResetPage(); CurrentPropertyChanged(); }
private void ShowSelectedSection(LevelSection levelSection) { var page = m_composePages.FirstOrDefault(x => x.Section == levelSection); if (page == null) { switch (levelSection) { case LevelSection.AR1: page = new ReadingQA(Level, LevelSection.AR1); break; case LevelSection.AR2: page = new ReadingPQA(Level, LevelSection.AR2); break; case LevelSection.AR3: page = new ReadingPA(Level, LevelSection.AR3); break; case LevelSection.AR4A: page = new WritingQA(Level, LevelSection.AR4A); break; case LevelSection.AR4B: page = new WritingQA(Level, LevelSection.AR4B); break; case LevelSection.AL1: page = new Listening1QA(Level, LevelSection.AL1); break; case LevelSection.AL2: page = new ListeningQA(Level, LevelSection.AL2); break; case LevelSection.AL3: page = new Listening1QA(Level, LevelSection.AL3); break; } m_composePages.Add(page); } pageTransition.ShowPage(page as UserControl); }
public ILevelSection GenerateNewSection(ActivityFactory activityFactory) { var position = gameObject.transform.position; if (_sections.Last != null) { position = _sections.Last.Value.LeftEdge; } var playArea = _playAreaGenerator.GeneratePlayArea(position, AvailableFeatures); var endSection = _endsectionGenerator.GenerateEndSection(activityFactory, playArea.LeftTerrainEdge); var section = new LevelSection(playArea, endSection); _sections.AddLast(section); return(section); }
private void enableLetter(LevelSection section) { int letters = section.letterPlaceholders.Count; int r = (int)(Time.deltaTime * 100); LetterController selected = section.letterPlaceholders[r % letters]; if (selected == null) { return; } string nextLetter = letterManager.GetNextLetter(); if (nextLetter != null) { selected.SetLetter(nextLetter); } }
public void GenerateLevel(int difficulty, int sections) { Debug.Log("Generate Level " + difficulty); List <LevelSection> levelDraw = new List <LevelSection>(); foreach (LevelSection levelSection in levelSections) { if (levelSection.minDifficulty == 0 || difficulty >= levelSection.minDifficulty) { if (levelSection.maxDifficulty == 0 || difficulty <= levelSection.maxDifficulty) { int freq = levelSection.frequency; for (int i = 0; i < freq; i++) { levelDraw.Add(levelSection); } } } } int x = -100; int y = 0; for (int i = 0; i < sections; i++) { LevelSection levelSection = (i == 0) ? levelSections[startSectionIndex] :levelDraw[Random.Range(0, levelDraw.Count)]; x += levelSection.deltaX / 2; Instantiate(levelSection.prefab, new Vector3(x, y, 0), Quaternion.identity, transform); y += levelSection.deltaY; x += levelSection.deltaX / 2; } // Final Section { LevelSection levelSection = finalSections[Random.Range(0, finalSections.Length)]; x += levelSection.deltaX / 2; Instantiate(levelSection.prefab, new Vector3(x, y, 0), Quaternion.identity, transform); } }
public async Task <IActionResult> Update(int id, [FromBody] LevelSection levelSectionDTO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var levelSectioninDb = await _unitofWork.LevelSectionRepository.SingleOrDefault(p => p.Id == id); if (levelSectioninDb == null) { return(NotFound()); } Transform(levelSectionDTO, levelSectioninDb); await _unitofWork.Commit(); var result = Mapper.Map <LevelSection, LevelSectionDTO>(levelSectioninDb); return(Ok(result)); }
public override void Init(GameManager serviceLocator) { _picker = serviceLocator.Picker; var entity = serviceLocator.SaveManager.Load(); //SaveEntity entity = null; if (entity == null || !entity.IsSavedData) { _currentSection = Get(0); _currentSection.Init(LevelDb.GetLevel(0)); _picker.Init(_currentSection.StartPosition()); } else { _currentSection = Get(0, entity.LevelEntity.Position, Quaternion.identity); _currentLevel = entity.LevelEntity.CurrentLevel; _currentSection.Init(entity.LevelEntity); _currentSection.ChangeMaterial(LevelDb.GetLevel(entity.LevelEntity.LevelIndex - 1).BoardMaterial); _picker.Init(entity.PlayerEntity.Position); } }
public void GenerateLevels() { CurrentLevelList = new LevelSection[LevelChainLength]; LevelSection previousSection = new LevelSection(); LevelSection newSection; for (int i = 0; i < LevelChainLength; i++) { if (i == 0) { //Make a new section at origin. newSection = GameObject.Instantiate <LevelSection>(LevelPrefabArray[(int)Mathf.Floor(Random.Range(0, LevelPrefabArray.Length))], this.transform); newSection.transform.position += new Vector3(-30, 0, 0); //Connect a level transition section to the right side newSection.RightTransition = GameObject.Instantiate <LevelSectionTransition>(LevelConnectorArray[(int)Mathf.Floor(Random.Range(0, LevelConnectorArray.Length))], newSection.RightSidePosition.transform); //Track new section; CurrentLevelList[i] = newSection; previousSection = newSection; //Detach from parent newSection.transform.parent = null; newSection.LevelHandler = this; //This is the first section newSection.LeftLevelBlock.isInvincible = true; } else { //Make a new Section at the Right Transition of the Previous Section newSection = GameObject.Instantiate <LevelSection>(LevelPrefabArray[(int)Mathf.Floor(Random.Range(0, LevelPrefabArray.Length))], previousSection.RightTransition.RightSidePosition.transform); //Set the Left Transition of the New Section to the Right Transition of the Previous Section newSection.LeftTransition = previousSection.RightTransition; //Connect a level transition section to the right side newSection.RightTransition = GameObject.Instantiate <LevelSectionTransition>(LevelConnectorArray[(int)Mathf.Floor(Random.Range(0, LevelConnectorArray.Length))], newSection.RightSidePosition.transform); CurrentLevelList[i] = newSection; newSection.InitializeSection(); //Detach from parent newSection.transform.parent = null; newSection.LevelHandler = this; previousSection = newSection; } } //FINAL STEP //Make a new Section at the Right Transition of the Previous Section newSection = GameObject.Instantiate <LevelSection>(FinalLevel, previousSection.RightTransition.RightSidePosition.transform); //Set the Left Transition of the New Section to the Right Transition of the Previous Section newSection.LeftTransition = previousSection.RightTransition; newSection.InitializeSection(); //Detach from parent newSection.transform.parent = null; newSection.LevelHandler = this; previousSection = newSection; LevelsGenerated = true; }
/// <summary> /// Generates a new level /// </summary> /// <param name="_levelOutput"> Returns the level generated after the this method runs</param> /// <returns> Returns if a level is generated </returns> public bool Generate(out bool[,] _levelOutput) { // Generation Checks if (mList_LevelSectionType.Count == 0) { Debug.LogWarning("Level.Generate(): mList_LevelSectionType size is zero. There is no section to generate!"); _levelOutput = null; return(false); } if (m_nLevelSize <= 0) { Debug.LogWarning("Level.Generate(): Invalid Level Size (m_nLevelSize = " + m_nLevelSize + "). m_nLevelSize must be more than 0!"); _levelOutput = null; return(false); } if (m_nLevelSectionSize <= 0) { Debug.LogWarning("Level.Generate(): Invalid Level-section Size (m_nLevelSectionSize = " + m_nLevelSectionSize + "). m_nLevelSection must be more than 0!"); _levelOutput = null; return(false); } // Variables Re-intialization marr2_bLevelData = new bool[m_nLevelSize * m_nLevelSectionSize, m_nLevelSize *m_nLevelSectionSize]; // for: Calculates the totalChance count for (int i = 0; i < mList_LevelSectionType.Count; i++) { m_nTotalChance += mList_LevelSectionType[i].Chance; } // for, for: each rows and column of the level-section grid for (int i = 0; i < m_nLevelSize; i++) { for (int j = 0; j < m_nLevelSize; j++) { // Finding a new level-section to spawn int nFinalChance = (int)(UnityEngine.Random.value * (float)m_nTotalChance); int nCurrentChance = 0; LevelSection levelSection = null; for (int k = 0; k < mList_LevelSectionType.Count; k++) { if (nCurrentChance >= nFinalChance) { levelSection = mList_LevelSectionType[k]; break; } nCurrentChance += mList_LevelSectionType[k].Chance; } if (levelSection == null) { levelSection = mList_LevelSectionType[mList_LevelSectionType.Count - 1]; } // for, for: each rows and columns of the tile grid for (int l = 0; l < m_nLevelSectionSize; l++) { for (int m = 0; m < m_nLevelSectionSize; m++) { // if: It is a checked tile in the raw-data array if (levelSection.RawData[m + l * m_nLevelSectionSize]) { // if: random is within range (means it will spawn) if (UnityEngine.Random.value < 1f - levelSection.TilePercentage / 2f) { marr2_bLevelData[m + j * m_nLevelSectionSize, l + i * m_nLevelSectionSize] = true; } } // else: it is not a checked tile in the raw-data array else { // if: random is within range (means it will spawn) if (UnityEngine.Random.value < levelSection.TilePercentage / 2f) { marr2_bLevelData[m + j * m_nLevelSectionSize, l + i * m_nLevelSectionSize] = true; } } } } } } _levelOutput = marr2_bLevelData; return(true); }
private void ShowSelectedSection(LevelSection levelSection) { var page = m_composePages.FirstOrDefault(x => x.Section == levelSection); if (page == null) { switch (levelSection) { // reading case LevelSection.B1R1: page = new ReadingQA(Level, LevelSection.B1R1); break; case LevelSection.B1R2: page = new ReadingPAB1B2(Level, LevelSection.B1R2); break; case LevelSection.B1R3: page = new ReadingPQAB1B2(Level, LevelSection.B1R3); break; case LevelSection.B1R4: page = new ReadingPQA(Level, LevelSection.B1R4); break; case LevelSection.B1R5: page = new ReadingPA(Level, LevelSection.B1R5); break; // writing case LevelSection.B1W1: page = new WritingQA(Level, LevelSection.B1W1); break; case LevelSection.B1W2: page = new WritingQA(Level, LevelSection.B1W2); break; case LevelSection.B1W3: page = new WritingQA(Level, LevelSection.B1W3); break; // listening case LevelSection.B1L1: page = new ListeningQA(Level, LevelSection.B1L1); break; case LevelSection.B1L2: page = new ListeningQA(Level, LevelSection.B1L2); break; case LevelSection.B1L3: page = new Listening1QA(Level, LevelSection.B1L3); break; case LevelSection.B1L4: page = new Listening1QA(Level, LevelSection.B1L4); break; } m_composePages.Add(page); } pageTransition.ShowPage(page as UserControl); }