public void BeginScreenAttack() { // Reset from previous Screen Attack m_iCurrentAttackElement = 0; m_lgoScreenAttackObjects.Clear(); m_ttRevealTimer.FinishTime = m_fRevealPieceInitialTime; m_eScreenAttackState = ScreenAttackState.REVEALING; int xMax = (LevelGrid.TileCountHorz - LevelGrid.TileHorzOffsetCount); int yMax = (LevelGrid.TileCountVertz - LevelGrid.TileVertzOffsetCount) - 1; // -1 For Array Index Offset int ixSpawnTile = 0; int iySpawnTile = (int)((float)LevelGrid.TileCountVertz * 0.5f); for (int y = 0; y < yMax; ++y) { if (ixSpawnTile == xMax) { ixSpawnTile = 0; } for (int x = Mathf.Abs(LevelGrid.TileHorzBeginID); x <= xMax; ++x) { // If Guaranteed Spawn, or Spawn Chance hit if ((x == ixSpawnTile) || ((xMax - x) == ixSpawnTile) || (y == iySpawnTile) || (Random.Range(0, 100) < m_iTileSpawnChance)) { Fireball_ScreenAttackMagic rAttackObject = m_rMagicPool.GetFreeObjectInList(); rAttackObject.transform.position = LevelGrid.GetTile(x, y).transform.position; m_lgoScreenAttackObjects.Add(rAttackObject); } } ixSpawnTile += 1; } // Shuffle Screen Attack Objects List, so when iterating through later they appear randomly. int iRemainingElements = m_lgoScreenAttackObjects.Count; while (iRemainingElements > 1) { int k = (Random.Range(0, iRemainingElements)); iRemainingElements -= 1; Fireball_ScreenAttackMagic value = m_lgoScreenAttackObjects[k]; m_lgoScreenAttackObjects[k] = m_lgoScreenAttackObjects[iRemainingElements]; m_lgoScreenAttackObjects[iRemainingElements] = value; } }
private void UpdateRevealingState() { m_ttRevealTimer.Update(); if (m_ttRevealTimer.TimeUp()) { m_ttRevealTimer.FinishTime -= (m_ttRevealTimer.FinishTime * 0.1f); m_ttRevealTimer.Reset(); Fireball_ScreenAttackMagic rAttackObject = m_lgoScreenAttackObjects[m_iCurrentAttackElement]; rAttackObject.gameObject.SetActive(true); rAttackObject.BeginAttack(); m_iCurrentAttackElement += 1; if (m_iCurrentAttackElement == m_lgoScreenAttackObjects.Count) { m_eScreenAttackState = ScreenAttackState.WAIT_FOR_PLAYER_ANIMATION; m_rPlayerRef.BeginScreenAttackAnimation(); } } }