public void SaveAndExit()
    {
        //not seem to save between plays on the test in unity wonder if will work when build it

        PlayersPrefsManager.SetMasterVolume(volumeSlider.value);
        PlayersPrefsManager.SetDifficulty(difficultySlider.value);

        levelManager.LoadLevel("Start Menu");
    }
    // Update is called once per frame
    void Update()
    {
        musicManager.SetVolume(volumeSlider.value);
//	Debug.Log("OC set difficulty to " + difficultySlider.value);


        PlayersPrefsManager.SetDifficulty(difficultySlider.value);
        Debug.Log("OC set difficulty to " + difficultySlider.value);
    }
Пример #3
0
    public void LoadLastLevel()
    {
        string lastLevel;

        lastLevel = PlayersPrefsManager.GetLastLevel();
        SceneManager.LoadScene(lastLevel);
        resetStatics();
        //if levelmanager not persist this may not happen
        //Debug.Log("I reset statics following loading a level");
    }
Пример #4
0
    void OnTriggerEnter2D()
    {
        //reseting the static just incase
        Spawner.roughAdjustmentAllSpawnRates = 1f;

        string thisLevel = SceneManager.GetActiveScene().name;

        PlayersPrefsManager.SetLastLevel(thisLevel);

        levelManager.LoadLevel("03b_Lose");
    }
Пример #5
0
    void Start()
    {
        difficulty = PlayersPrefsManager.GetDifficulty();

        if (difficulty > 2f && difficultyUpdatedThisLevel == false)
        {
            roughAdjustmentAllSpawnRates += UptheDifficulty();
            Debug.Log("have I upped the initial roughadjustment " + roughAdjustmentAllSpawnRates);
            difficultyUpdatedThisLevel = true;
        }
    }
Пример #6
0
    void OnLevelWasLoaded(int level)
    {
        AudioClip thisLevelMusic = levelMusicChangeArray[level];


        Debug.Log("Playing clip" + levelMusicChangeArray[level]);



        if (thisLevelMusic)
        {
            // i made below up does it work cant tell without deleting playerprefs
            //im setting on initialisation of the music the music to the volume previously set and if it has never been set to a default

            //need to add one to the start button in start menu to initiallise difficults as default or preset too

            //if ( PlayersPrefsManager.GetMasterVolume() != null)

            //float hasAMasterVolumeBeenAsigned = PlayersPrefsManager.GetMasterVolume();
            //if ( hasAMasterVolumeBeenAsigned != null){

            //if ( PlayersPrefsManager.GetMasterVolume() != nul 3f){

            if (PlayersPrefsManager.GetMasterVolume() != null)
            {
                audioSource.volume = PlayersPrefsManager.GetMasterVolume();
            }


            else
            {
                audioSource.volume = 0.5f;
            }


            audioSource.clip = thisLevelMusic;
            audioSource.loop = true;
            audioSource.Play();
        }



        /*my attempt
         * int thisLevel = SceneManager.GetActiveScene().buildIndex;
         *
         * if (indexCheck != thisLevel){
         * indexCheck = thisLevel;
         * AudioSource music = levelMusicChangeArray[indexCheck];
         * music.Play();}
         *
         */
    }
Пример #7
0
    private void DifficultyAdjustment()
    {
//altering star value

        oldColor = starText.color;
        Debug.Log("Stars unmodified " + stars);

        starsFloat          = stars;
        difficulty          = PlayersPrefsManager.GetDifficulty();
        starModifierPercent = 0.2f - difficulty * 0.1f;
        starsFloat         += starsFloat * starModifierPercent;

        stars = (Mathf.RoundToInt(starsFloat / 5)) * 5;

//stars = (Mathf.RoundToInt(starsFloat/10f))*10;
        Debug.Log("Timer: difficulty = " + difficulty + " StarModifierPercent = " + starModifierPercent + " Starsfloat = " + starsFloat + " stars = " + stars);

// would be nice to reduce gnome and trophy cost but not sure how to find those objects as all dropped in two places one for cost one to make;
    }
Пример #8
0
    // Use this for initialization
    void Start()
    {
        slider       = GetComponent <Slider>();
        audioSource  = GetComponent <AudioSource>();
        levelManager = GameObject.FindObjectOfType <LevelManager>();

        int thisLevel = SceneManager.GetActiveScene().buildIndex;

//	Debug.Log("this is level " + SceneManager.GetActiveScene().name + " index " + SceneManager.GetActiveScene().buildIndex + " Im unlocking " + thisLevel);

        PlayersPrefsManager.Unlocklevel(thisLevel);


        FindYouWin();
        winLabel.SetActive(false);



        //timeLeft = startTime;
        //UpdateSlider(timeLeft);
    }
Пример #9
0
    void Start()
    {
        ///ahh still no idea why i can grab the button component
        //i have named a script button will try rename it


        thisButton = this.GetComponent <Button>();
        thisButton.interactable = false;

        levelManager = GameObject.FindObjectOfType <LevelManager>();



        //this.gameObject.SetActive(false);



//interactable would be better but cant seem to get hold of it



        //build order is one more than the level code
        //turning my text into code so dont need to rely on public variable, cutting string or using the name of this object or tag
        //may have to do above if start using level names

        mytextLvlName      = this.GetComponent <Text>();
        levelNameInt       = int.Parse(mytextLvlName.text);
        buildLvlEquivalent = levelNameInt + 1;

//Debug.Log("from available level ... my level button text is " + levelNameInt + " that is build equivalent " + buildLvlEquivalent);

        levelAvailable = PlayersPrefsManager.IsLevelUnlocked(buildLvlEquivalent);

        if (levelAvailable)
        {
            thisButton.interactable = true;
        }
    }
Пример #10
0
/* works wanted to try something else
 * private void UptheDifficulty(){
 *
 * //gets called every time there is a spawner
 * //want the first to do it for all of them
 *
 *
 * //I want each lane to increase rate from 0 to 2% this is 10% increase over all so may be a bit nasty
 *
 *
 * float increaseToLaneDifficulty = ((difficulty -  2f) /10f);
 * roughAdjustmentAllSpawnRates = 1 + increaseToLaneDifficulty;
 * //Debug.Log("Starting release rate increased to " + roughAdjustmentAllSpawnRates + " on top of all later changes");
 * difficultyUpdatedThisLevel = true;
 *
 * }
 */
    public float UptheDifficulty()
    {
        difficulty = PlayersPrefsManager.GetDifficulty();

//cant get defender spawner to call this method

//I want each lane to increase rate from 0 to 2% this is 10% increase over all so may be a bit nasty
        if (difficulty > 2f)
        {
            float difficultySpawnIncrement = ((difficulty - 2f) / 10f);

//Debug.Log("Starting release rate increased to " + roughAdjustmentAllSpawnRates + " on top of all later changes");

//Debug.Log("Spawner says the difficulty is " + difficulty + " and is returning " + difficultySpawnIncrement);
            return(difficultySpawnIncrement);
        }
        else
        {
//			Debug.Log("Spawner says the difficulty is " + difficulty + " and is returning " + 0f);

            return(0f);
        }
    }
Пример #11
0
 // Use this for initialization
 void Start()
 {
     musicManager           = GameObject.FindObjectOfType <MusicManager>();
     volumeSlider.value     = PlayersPrefsManager.GetMasterVolume();
     difficultySlider.value = PlayersPrefsManager.GetDifficulty();
 }