// Update is called once per frame
 void Update()
 {
     if (levelSetupScript == null)
     {
         levelSetupScript = FindObjectOfType <LevelSetupScript>();
         if (levelSetupScript != null)
         {
             blockedGems = levelSetupScript.blockedGems;
             RNG_order   = levelSetupScript.RNG_order;
         }
     }
     while (nextGems.Count <= gemSprites.Length)
     {
         int n = nextGems.Count;
         GenerateGems();
         if (nextGems.Count == n)
         {
             return;
         }
     }
     for (int i = 0; i < gemDisplay.Length; i++)
     {
         gemDisplay[i].sprite = gemSprites[nextGems[i]];
     }
 }
Пример #2
0
    public void QuitLevel()
    {
        if (isPaused)
        {
            SetPaused();
        }
        else
        {
            GameObject snd = Instantiate <GameObject>(soundPrefab);
            snd.GetComponent <SFXScript>().sfx = clickSFX;
        }
        LevelSetupScript lss            = FindObjectOfType <LevelSetupScript>();
        string           quitLevel      = "";
        bool             endingCutscene = false;

        if (lss != null)
        {
            if (lss.endingCutscene != null && victoryScreen.activeInHierarchy)
            {
                Instantiate <GameObject>(lss.endingCutscene);
                SceneManager.LoadScene("CutsceneScene");
                endingCutscene = true;
            }
            quitLevel = lss.quitLevel;
            Destroy(lss.gameObject);
        }
        if (!endingCutscene)
        {
            SceneManager.LoadScene(quitLevel);
        }
    }
Пример #3
0
    public void NextLevel()
    {
        if (isPaused)
        {
            SetPaused();
        }
        else
        {
            GameObject snd = Instantiate <GameObject>(soundPrefab);
            snd.GetComponent <SFXScript>().sfx = clickSFX;
        }
        LevelSetupScript lss            = FindObjectOfType <LevelSetupScript>();
        bool             endingCutscene = false;
        GameObject       nextLevelSetup = null;

        if (FindObjectOfType <CutsceneData>() != null)
        {
            SceneManager.LoadScene("CutsceneScene");
            endingCutscene = true;
        }
        if (lss != null)
        {
            if (lss.endingCutscene != null)
            {
                Instantiate <GameObject>(lss.endingCutscene);
                SceneManager.LoadScene("CutsceneScene");
                endingCutscene = true;
            }
            nextLevel      = lss.nextLevel;
            nextLevelSetup = lss.nextLevelPrefab;
            Destroy(lss.gameObject);
        }
        if (!endingCutscene)
        {
            if (nextLevelSetup != null)
            {
                if (nextLevelSetup.GetComponent <LevelSetupScript>().startingCutscene != null)
                {
                    GameObject scs = Instantiate <GameObject>(nextLevelSetup.GetComponent <LevelSetupScript>().startingCutscene);
                    scs.GetComponent <CutsceneData>().setupPrefab = nextLevelSetup;
                    SceneManager.LoadScene("CutsceneScene");
                }
                else
                {
                    LevelSelectScript.currentMenu = nextLevelSetup.GetComponent <LevelSetupScript>().index;
                    if (nextLevel.Equals(SceneManager.GetActiveScene().name))
                    {
                        Instantiate <GameObject>(nextLevelSetup);
                    }
                    SceneManager.LoadScene(nextLevel);
                }
            }
            else
            {
                SceneManager.LoadScene(nextLevel);
            }
        }
    }
Пример #4
0
    // Start is called before the first frame update
    void Start()
    {
        score      = 0;
        timer      = timerStart;
        multiplier = 1;
        blocksUsed = 0;

        LevelSetupScript lss = FindObjectOfType <LevelSetupScript>();

        if (lss != null)
        {
            FindObjectOfType <Jukebox>().PlaySong(lss.loadSong);
            FindObjectOfType <Jukebox>().SetLoop(true);
        }

        alreadyPlayedTime = new bool[] { false, false, false, false, false, false, false, false };
        timeToPlay        = new float[] { 30f, 20f, 10f, 5f, 4f, 3f, 2f, 1f };
    }
    // Update is called once per frame
    void Update()
    {
        for (int i = 0; i < 3; i++)
        {
            LevelSetupScript lss = levelSetups[levelIndex + i - 1].GetComponent <LevelSetupScript>();
            contractNumbers[i].text = "CONTRACT #" + (levelIndex + i);
            if (lss.isBossBattle)
            {
                contractNumbers[i].text += "\n[BOSS BATTLE]";
            }
            if (DataTracker.IsUnlocked(levelIndex + i - 1))
            {
                contractNames[i].text = lss.missionName;
                profits[i].text       = "PROFIT: $" + DataTracker.GetScore(levelIndex + i - 1);
                profits[i].gameObject.SetActive(true);
                buttons[i].gameObject.SetActive(true);
                if (lss.cannonPrefab == null)
                {
                    icons[i].gameObject.SetActive(false);
                    for (int k = 0; k < 4; k++)
                    {
                        characterSelects[i * 4 + k].gameObject.SetActive(true);
                    }
                }
                else
                {
                    icons[i].gameObject.SetActive(true);
                    icons[i].sprite = lss.cannonPrefab.GetComponent <CannonScript>().portraits[0];
                    for (int k = 0; k < 4; k++)
                    {
                        characterSelects[i * 4 + k].gameObject.SetActive(false);
                    }
                }
            }
            else
            {
                contractNames[i].text = "Locked!";
                profits[i].gameObject.SetActive(false);
                icons[i].gameObject.SetActive(true);
                icons[i].sprite = lockedIcon;
                buttons[i].gameObject.SetActive(false);
                for (int k = 0; k < 4; k++)
                {
                    characterSelects[i * 4 + k].gameObject.SetActive(false);
                }
            }
        }
        if (levelIndex == 1)
        {
            leftArrow.SetActive(false);
        }
        else
        {
            leftArrow.SetActive(true);
        }
        if (levelSetups.Length - 2 == 1)
        {
            rightArrow.SetActive(false);
        }
        else
        {
            rightArrow.SetActive(true);
        }
        LevelSelectScript.currentMenu = levelIndex;

        if (DataTracker.originalControls)
        {
            controlsButton.sprite = controlsSprites[0];
        }
        else
        {
            controlsButton.sprite = controlsSprites[1];
        }
    }
Пример #6
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetAxisRaw("Pause") == 0)
        {
            canPressPause = true;
        }
        if (canPressPause && Input.GetAxisRaw("Pause") > 0 && !victoryScreen.activeInHierarchy && !failureScreen.activeInHierarchy)
        {
            canPressPause = false;
            SetPaused();
        }
        if (Input.GetAxisRaw("Restart") == 0)
        {
            canPressRestart = true;
        }
        if (canPressRestart && Input.GetAxisRaw("Restart") > 0)
        {
            canPressRestart = false;
            RetryLevel();
        }
        if (textTip != null && textTip.Length > 0 && !victoryScreen.activeInHierarchy && !failureScreen.activeInHierarchy && !pauseScreen.activeInHierarchy)
        {
            textBox.SetActive(true);
        }
        else
        {
            textBox.SetActive(false);
        }
        if (isPaused)
        {
            return;
        }


        if (portraits == null)
        {
            portraits = FindObjectOfType <CannonScript>().portraits;
        }
        if (portraits != null)
        {
            setPortraitTimer -= Time.deltaTime;
            if (timeDrain)
            {
                if (failureScreen.activeInHierarchy)
                {
                    portraitIcon.sprite = portraits[7];
                }
                else
                {
                    portraitIcon.sprite = portraits[6];
                }
            }
            else if (failureScreen.activeInHierarchy)
            {
                portraitIcon.sprite = portraits[5];
            }
            else if (victoryScreen.activeInHierarchy)
            {
                portraitIcon.sprite = portraits[3];
            }
            else if (setPortraitTimer > 0f)
            {
                portraitIcon.sprite = portraits[setPortraitIndex];
            }
            else if (timer < 20f)
            {
                portraitIcon.sprite = portraits[4];
            }
            else
            {
                portraitIcon.sprite = portraits[0];
            }
        }

        if (levelSetupScript == null)
        {
            levelSetupScript = FindObjectOfType <LevelSetupScript>();
            if (levelSetupScript != null)
            {
                timerStart = levelSetupScript.startTime;
                if (!setTimer)
                {
                    timer    = timerStart;
                    setTimer = true;
                }
                textTip     = levelSetupScript.missionTip;
                missionName = levelSetupScript.missionName;
                levelIndex  = levelSetupScript.index;
            }
        }

        if (DataTracker.originalControls)
        {
            controlsTutorialText.text = "STEER: Left/Right\nTHRUST: Up\nBRAKE: Down\nSHOOT BLOCK: Spacebar\nSPECIAL: Left Shift\nRETRY: R\nPAUSE: Escape";
        }
        else
        {
            controlsTutorialText.text = "FLY SHIP: Left/Right/Up/Down\nSHOOT BLOCK: Spacebar\nSPECIAL: Left Shift\nRETRY: R\nPAUSE: Escape";
        }

        LevelSelectScript.currentMenu = levelIndex;
        textBoxText.text     = textTip;
        missionNameText.text = "CONTRACT: " + missionName;

        if (planet == null && timer > 0f)
        {
            PlanetScript[] allPlanets = FindObjectsOfType <PlanetScript>();
            for (int i = 0; i < allPlanets.Length; i++)
            {
                if (allPlanets[i] != null && allPlanets[i].match >= 0)
                {
                    planet = allPlanets[i];
                    break;
                }
            }
            levelWinTimer += Time.deltaTime;

            if (levelWinTimer > timeToDelay)
            {
                victoryScreen.SetActive(true);
                SetHighScore();
            }
        }
        else
        {
            levelWinTimer = 0f;

            float mult = 1f;
            if (timeDrain)
            {
                mult = 600f;
            }
            if (stopTimer)
            {
                mult = 0f;
            }
            timer -= Time.deltaTime * mult;

            for (int t = 0; t < timeToPlay.Length && t < alreadyPlayedTime.Length; t++)
            {
                if (timer < timeToPlay[t] && !alreadyPlayedTime[t])
                {
                    alreadyPlayedTime[t] = true;
                    GameObject snd = Instantiate <GameObject>(soundPrefab);
                    snd.GetComponent <SFXScript>().sfx = lowTimeSFX;
                }
            }

            if (timer < 0)
            {
                timer = 0;

                if (!failureScreen.activeInHierarchy)
                {
                    GameObject snd = Instantiate <GameObject>(soundPrefab);
                    snd.GetComponent <SFXScript>().sfx = timeUpSFX;
                }
                levelLoseTimer += Time.deltaTime;
                if (levelLoseTimer > timeToDelay)
                {
                    failureScreen.SetActive(true);
                }
            }
        }

        int    roundedTimer = (int)(Mathf.Ceil(timer));
        int    minutes      = roundedTimer / 60;
        int    seconds      = roundedTimer % 60;
        string minStr       = "" + minutes;

        if (minutes < 10)
        {
            minStr = "0" + minStr;
        }
        string secStr = "" + seconds;

        if (seconds < 10)
        {
            secStr = "0" + secStr;
        }
        timerText.text = minStr + ":" + secStr;
        scoreText.text = "SCORE: " + score;

        if (spMove == null)
        {
            specialMoveText.text = "";
            spMove = FindObjectOfType <SpecialMove>();
        }
        else
        {
            string str = "SPECIAL : " + spMove.displayName;
            if (spMove.GetCanBeUsed())
            {
                str += "\n[Press Left Shift]";
                specialMoveIcon.sprite = spMove.iconReady;
            }
            else
            {
                str += "\nAlready used!";
                specialMoveIcon.sprite = spMove.iconUsed;
            }
            specialMoveText.text = str;
        }
    }