Esempio n. 1
0
        // returns the zap we move through initially when moving up.
        public Zap MoveVertically()
        {
            ZapGrid currZapGrid = GameMaster.Instance.m_ZapManager.GetZapGrid();

            if (currZapGrid)
            {
                m_CurrRow++;
                // don't allow player to jump higher than number of rows in zap grid. Else argumentoutofrange exception
                m_CurrRow = Mathf.Clamp(m_CurrRow, 0, currZapGrid.GetNumRows());


                /* get correct zap on new line to go to
                 *  this will compare the distance between the curr and next zap
                 *  if next zap is closer then go to it and vice versa. */
                Zap  zapOnNewLine      = null;
                Zap  zapMovedThrough   = null;
                bool underneathCurrZap = underneathCurrentZap();
                if (underneathCurrZap)
                {
                    // handles to make sure that we can't repeatedly make up for increment issues when moving vertically.
                    if (m_PrevMovementState != MovementState.MovingVertical)
                    {
                        if (m_IsMovingRight)
                        {
                            m_NextCol--;
                        }
                        else
                        {
                            m_NextCol++;
                        }
                    }
                    zapOnNewLine    = currZapGrid.GetZap(m_CurrRow, m_NextCol);
                    zapMovedThrough = m_CurrZap;
                }
                else
                {
                    zapOnNewLine    = currZapGrid.GetZap(m_CurrRow, m_NextCol);
                    zapMovedThrough = m_NextZap;
                }


                if (zapOnNewLine != null)
                {
                    //m_P2 = m_CurrZap.GetOffsetPosition();
                    //m_P1 = m_StartPosition
                    //m_TargetPosition = GetPoint(m_LerpPercentage);
                    // figure out which zap we are closer too
                    m_CurrZap = zapOnNewLine;
                    m_NextZap = zapOnNewLine;
                    //m_CurrRow += numRows;
                    m_LerpAmount     = 0.0f;
                    m_StartPosition  = this.transform.position;
                    m_TargetPosition = zapOnNewLine.GetOffsetPosition();
                }

                return(zapMovedThrough);
            }

            return(null);
        }
Esempio n. 2
0
        public void MoveRocketJump(int numRows)
        {
            ZapGrid currGrid = GameMaster.Instance.m_ZapManager.GetZapGrid();

            if (currGrid)
            {
                m_CurrRow += numRows;
                m_CurrRow  = Mathf.Clamp(m_CurrRow, 0, currGrid.GetNumRows() - 1);

                bool underneathCurrZap = underneathCurrentZap();
                Zap  next = m_NextZap;
                Zap  curr = m_CurrZap;
                if (underneathCurrZap)
                {
                    m_NextZap = currGrid.GetZap(m_CurrRow, m_CurrCol);
                }
                else
                {
                    m_NextZap = currGrid.GetZap(m_CurrRow, m_NextCol);
                }
                m_CurrZap        = m_NextZap;
                m_TargetPosition = m_NextZap.GetOffsetPosition();
                m_StartPosition  = this.transform.position;
                m_LerpAmount     = 0.0f;

                // don't let player move while rocket jumpin
                m_CanMove = false;
            }
        }
Esempio n. 3
0
 private void decideNextMovementType()
 {
     if (m_MovementState == MovementState.MovingHorizontal)
     {
         SetMovementState(MovementState.MovingHorizontal);
     }
     else if (m_MovementState == MovementState.MovingBounceBackFromZap)
     {
         SetSpeedMultiplier(1.0f, true);
         SetMovementState(MovementState.MovingHorizontal);
     }
     else if (m_MovementState == MovementState.MovingVertical)
     {
         ZapGrid currZapGrid = GameMaster.Instance.m_ZapManager.GetZapGrid();
         if (m_CurrRow == currZapGrid.GetNumRows())
         {
             MoveToWarpZone();
             return;
         }
         SetMovementState(MovementState.MovingHorizontal);
     }
     else if (m_MovementState == MovementState.MovingToWarpZone)
     {
         m_TargetPosition = this.transform.position;
         m_StartPosition  = this.transform.position;
         shouldRotateInTowardTargetPosition = false;
         if (!m_PlayerDecorations.GetWarpZonePS().isPlaying)
         {
             m_PlayerDecorations.ShowWarpZonePS();
         }
         GameMaster.Instance.m_UIManager.m_ShopCanvas.m_WarpStorePanel.Show();
     }
     else if (m_MovementState == MovementState.MovingToZapGrid)
     {
         SetMovementState(MovementState.MovingHorizontal);
         DeathStar deathStar = GameMaster.Instance.m_DeathStar;
         if (deathStar)
         {
             deathStar.ResetPosition();
             deathStar.SetIsMoving(true);
         }
     }
     else if (m_MovementState == MovementState.MovingRocketJump)
     {
         GameMaster.Instance.m_PlayerStats.SetInvicible(false);
         SetMovementState(MovementState.MovingHorizontal);
         m_CanMove = true;
         if (m_PlayerDecorations != null)
         {
             m_PlayerDecorations.DeactivateLockdown();
             m_PlayerDecorations.DeactivateAtmosphereFire();
         }
     }
 }
Esempio n. 4
0
        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());
        }