public void MoveHorizontally() { // switch next and curr zap if we have a next zap if (m_NextZap != null) { m_StartPosition = m_NextZap.GetOffsetPosition(); m_CurrZap = m_NextZap; m_CurrCol = m_NextCol; } // check to make sure we don't go out of bounds ZapGrid currZapGrid = GameMaster.Instance.m_ZapManager.GetZapGrid(); if (currZapGrid != null) { if (m_IsMovingRight) { if (m_NextCol + 1 < currZapGrid.GetNumCols(m_CurrRow)) { m_NextCol++; } else { m_IsMovingRight = false; m_NextCol--; } } else { if (m_NextCol - 1 >= 0) { m_NextCol--; } else { m_IsMovingRight = true; m_NextCol++; } } m_NextZap = currZapGrid.GetZap(m_CurrRow, m_NextCol); m_TargetPosition = m_NextZap.GetOffsetPosition(); m_StartPosition = this.transform.position; } }
private IEnumerator spawnLaser() { ZapManager zapManager = GameMaster.Instance.m_ZapManager; if (zapManager) { ZapGrid zapGrid = zapManager.GetZapGrid(); int numRows = zapGrid.GetNumRows(); int numCols = zapGrid.GetNumCols(0); // get random row to spawn lasers on int randomRow = Random.Range(0, numRows); Zap zapInRow = zapGrid.GetZap(randomRow, 0); // spawn on left or right side of the screen int randomSide = Random.Range(0, 2); bool isOnRightSide = (randomSide == 1) ? true : false; Vector3 spawnPos = Vector3.zero; // spawn the laser Laser laserInstance = Instantiate(m_LaserPrefab, this.transform); // make changes to lasers position based on if it is on left or right side of the screen. if (randomSide == 0) // spawn on left side of screen { spawnPos = Utility.ScreenUtilities.GetWSofSSPosition(0.0f, 0.0f); } else // spawn on right side of screen { spawnPos = Utility.ScreenUtilities.GetWSofSSPosition(1.0f, 0.0f); } // make sure the laser is spawned at the same y position as the zap row. spawnPos.y = zapInRow.GetOffsetPosition().y; spawnPos.z = 80.0f; laserInstance.SetPositionLaserPost(spawnPos, isOnRightSide); } yield return(new WaitForSeconds(m_SpawnTime)); StartCoroutine(spawnLaser()); }