示例#1
0
    // init the menu
    void Awake()
    {
        _audio = GetComponent <AudioSource> ();
        if (_audio == null)         // if AudioSource is missing
        //			Debug.LogWarning("AudioSource component missing from this gameobject. Adding one.");
        // let's just add the AudioSource component dynamically
        {
            _audio = gameObject.AddComponent <AudioSource>();
        }



        if (PlayerPrefManager.GetSound() == 1)
        {
            MainMenu.GetComponent <AudioSource> ().mute = false;
        }
        else
        {
            MainMenu.GetComponent <AudioSource> ().mute = true;
        }



        // store the initial title so we can set it back
        //_mainTitle = titleText.text;

        // disable/enable Level buttons based on player progress
        //setLevelSelect();

        // determine if Quit button should be shown
        displayQuitWhenAppropriate();

        // Show the proper menu
        //ShowMenu("MainMenu");
    }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        GameManager myGM = (GameManager)target;

        if (GUILayout.Button("Reset Purchases"))
        {
            // if button pressed, then call funciton in script
            PlayerPrefManager.SetHighscore(0);
            PlayerPrefManager.SetIsProductUnlocked("BTN_Orange ball", false);
            PlayerPrefManager.SetIsProductUnlocked("BTN_Blue ball", false);
            PlayerPrefManager.SetIsProductUnlocked("BTN_Red ball", false);
            PlayerPrefManager.SetIsProductUnlocked("BTN_Green ball", false);
            PlayerPrefManager.SetIsProductUnlocked("BTN_Pink ball", false);
            PlayerPrefManager.SetIsProductUnlocked("BTN_Yellow ball", false);
            PlayerPrefManager.SetIsProductUnlocked("BTN_dark red ball", false);
            PlayerPrefManager.SetIsProductUnlocked("BTN_Purple ball", false);

            PlayerPrefManager.SetHighscore(0);
        }

        if (GUILayout.Button("Output coins"))
        {
            // if button pressed, then call function in script
            Debug.Log(PlayerPrefManager.GetCoins());
        }
    }
示例#3
0
    public void OnClickMusicBtn()
    {
        int musicValue = PlayerPrefManager.GetMusic();

        PlayerPrefManager.SetMusic(musicValue == 0 ? 1 : 0);
        SetMusicButton();
    }
    void OnTriggerEnter2D(Collider2D other)
    {
        if ((other.tag == "Ball") && (!taken))
        {
            sr.enabled = false;                // turn off sprite so animation can finish
            ec.enabled = false;                // turn off edge collider so animation can finish
            gemDeath.SetBool("Dead", true);
            taken = true;                      //set to taken so there is no chance of coin being picked up again
            GameManager.gm.AddCoin(coinValue); //add coin value to collection
            gemScore.GetComponent <BlackBarrierAnimations>().EnableAnimation();


            //PlayerPrefManager.GetSoundFX() == true &&
            if (GetComponent <AudioSource>() && PlayerPrefManager.GetSoundFX() == true)
            {
                audiSou.clip = coinSound;
                audiSou.Play();
                Destroy(gameObject.transform.parent.gameObject, deathclip.length);
            }
            else
            {
                Destroy(gameObject.transform.parent.gameObject);
            }
        }
    }
示例#5
0
 void OnApplicationQuit()
 {
     if (highscore > PlayerPrefManager.GetHighscore())
     {
         PlayerPrefManager.SetHighscore(highscore);
     }
 }
示例#6
0
    // check if gameover, else reset level
    public void ResetLevel()
    {
        // subtract from player lives
        PlayerLives--;
        // store lives
        PlayerPrefManager.SetLives(PlayerLives);

        RefreshGUI();

        // if game over
        if (PlayerLives <= 0)
        {
            // Save stats
            PlayerPrefManager.SavePlayerStats(PlayerLives, PlayerScore, PlayerHighscore);

            // load game over screen
            SceneManager.LoadScene(GameOverScreen);
        }
        // else respawn player and balloons at starting point
        else
        {
            // load default weapon
            _player.GetComponent <PlayerShoot>().ActiveWeapon = PlayerShoot.Weapons.Anchor;

            // respawn player
            _player.GetComponent <CharacterController2D>().RespawnPlayer();

            // respawn balloons
            RespawnBalloons();

            // reset hit points needed to win
            CalculateHitsForWin();
        }
    }
示例#7
0
 private void Awake()
 {
     if (!Instance)
     {
         Instance = this;
     }
 }
    //Setup all startup game stuff
    public void Setup()
    {
        //Indicate that gameFinsihed is false
        gameFinished = false;

        //Set start time counter
        m_StartTime = Time.time;

        //Assign level number to gui
        txtLevelNo.text = "Level: " + Application.loadedLevelName.After("_");

        //Get all UI Buttons in order to assign them click sound
        GameObject btnResume    = GeneralMethods.GetChildWithName(pausePanel, "BtnResume");
        GameObject btnExitPause = GeneralMethods.GetChildWithName(pausePanel, "BtnExit");
        GameObject btnRetry     = GeneralMethods.GetChildWithName(losePanel, "BtnRestart");
        GameObject btnExitLose  = GeneralMethods.GetChildWithName(losePanel, "BtnExit");
        GameObject btnNext      = GeneralMethods.GetChildWithName(winPanel, "BtnNext");
        GameObject btnExitWin   = GeneralMethods.GetChildWithName(winPanel, "BtnExit");

        //Assign buttons the click sound when clicked (instead of doing it in inspector manually)
        GeneralMethods.AssignSoundToButton(pauseBtn, "Click");
        GeneralMethods.AssignSoundToButton(btnResume, "Click");
        GeneralMethods.AssignSoundToButton(btnExitPause, "Click");
        GeneralMethods.AssignSoundToButton(btnRetry, "Click");
        GeneralMethods.AssignSoundToButton(btnExitLose, "Click");
        GeneralMethods.AssignSoundToButton(btnNext, "Click");
        GeneralMethods.AssignSoundToButton(btnExitWin, "Click");

        //Save that this level has been accessed so the MainMenu can enable it
        PlayerPrefManager.UnlockLevel();
    }
示例#9
0
    public void ResetControls()
    {
        PlayerPrefManager.ResetKeybind("key_move_forward");
        PlayerPrefManager.ResetKeybind("key_move_backward");
        PlayerPrefManager.ResetKeybind("key_move_left");
        PlayerPrefManager.ResetKeybind("key_move_right");
        PlayerPrefManager.ResetKeybind("key_jump");
        PlayerPrefManager.ResetKeybind("key_crouch_toggle");
        PlayerPrefManager.ResetKeybind("key_crouch_hold");
        PlayerPrefManager.ResetKeybind("key_sprint_toggle");
        PlayerPrefManager.ResetKeybind("key_sprint_hold");
        PlayerPrefManager.ResetKeybind("key_primary_fire");
        PlayerPrefManager.ResetKeybind("key_secondary_fire");
        PlayerPrefManager.ResetKeybind("key_interact");
        PlayerPrefManager.ResetKeybind("key_toggle_flashlight");
        PlayerPrefManager.ResetKeybind("key_toggleGUI");
        PlayerPrefManager.MessageKeybindObservers();
        int childCount = scrollViewContent.transform.childCount;

        for (int i = 0; i < childCount; i++)
        {
            GameObject child = scrollViewContent.transform.GetChild(i).gameObject;
            if (!(child.name.Equals("Mouse Sensitivity") || child.name.Equals("Mouse Invert") || child.name.Equals("Reset Keybinds")))
            {
                Destroy(child);
            }
        }
        InitializeScroller();
    }
示例#10
0
    public void StartGame()
    {
        string s;

        if (GetGameIsReady(out s))
        {
            if (singleplayer)
            {
                PlayerPrefManager.SetInt("game_playercount", 1);
                PlayerPrefManager.SetString("game_p1_plane", p1Plane.ToString());
                PlayerPrefManager.SetString("game_p1_input", PlayerInput.InputType.DUAL.ToString());
            }
            else
            {
                PlayerPrefManager.SetInt("game_playercount", 2);
                PlayerPrefManager.SetString("game_p1_plane", p1Plane.ToString());
                PlayerPrefManager.SetString("game_p1_input", p1Input.ToString());
                PlayerPrefManager.SetString("game_p2_plane", p2Plane.ToString());
                PlayerPrefManager.SetString("game_p2_input", p2Input.ToString());
            }
            PlayerPrefManager.SetString("game_difficulty", difficulty.ToString());
            PlayerPrefManager.SetString("game_currentstage", stage.ToString());
            LevelLoader.current.LoadStage(stage);
        }
        else
        {
            Debug.LogError("this line shouldnt be reachable since the button should be disabled if the game cant be started");
        }
    }
示例#11
0
    // Use this for initialization
    void Awake()
    {
        PrefManager = this;

        PlayerStats.SetStats();
        hpS            = PlayerStats.HP;
        maxHPS         = PlayerStats.MaxHP;
        attkBaseS      = PlayerStats.AttackBase;
        defBaseS       = PlayerStats.DefenseBase;
        magicAttkBaseS = PlayerStats.MagicAttkBase;
        magicDefBaseS  = PlayerStats.MagicDefBase;
        attkS          = PlayerStats.Attk;
        defS           = PlayerStats.Def;
        magicAttkS     = PlayerStats.MagicAttk;
        magicDefS      = PlayerStats.MagicDef;
        expS           = PlayerStats.EXP;
        maxEXPS        = PlayerStats.MaxEXP;
        lvlS           = PlayerStats.LVL;

        PlayerPrefs.SetFloat("hpS", hpS);
        PlayerPrefs.SetFloat("MaxHP", maxHPS);
        PlayerPrefs.SetFloat("AttkBase", attkBaseS);
        PlayerPrefs.SetFloat("DefBase", defBaseS);
        PlayerPrefs.SetFloat("MagAttkBase", magicAttkBaseS);
        PlayerPrefs.SetFloat("MagDefBase", magicDefBaseS);
        PlayerPrefs.SetFloat("attkS", attkS);
        PlayerPrefs.SetFloat("defS", defS);
        PlayerPrefs.SetFloat("MagAttk", magicAttkS);
        PlayerPrefs.SetFloat("MagDef", magicDefS);
        PlayerPrefs.SetInt("expS", expS);
        PlayerPrefs.SetInt("MaxExp", maxEXPS);
        PlayerPrefs.SetInt("lvlS", lvlS);
    }
示例#12
0
    void LoadPlayers()
    {
        int playerCount = PlayerPrefManager.GetInt("game_playercount");

        players                 = new Player[playerCount];
        playerOffsets           = new float[playerCount];
        playerGameover          = new bool[playerCount];
        playerRespawnStartTimes = new float[playerCount];

        if (playerCount == 1)
        {
            playerOffsets[0] = 0;
        }
        else if (playerCount == 2)
        {
            playerOffsets[0] = 1;
            playerOffsets[1] = -1;
        }
        else
        {
            throw new UnityException("unsupported playercount");
        }

        for (int i = 0; i < players.Length; i++)
        {
            int playerNumber = i + 1;
            InstantiateAndInitializePlayer(playerNumber, out players[i]);
//			players[i].enabled = false;
//			players[i].SetRegularComponentsActive(false);
            players[i].gameObject.SetActive(false);
        }
    }
    public void SaveAndExit()
    {
        PlayerPrefManager.SetMasterVolume(volumeSlider.value);
        PlayerPrefManager.SetDifficulty((int)difficultySlider.value);

        levelManager.LoadLevel(levelToLoadOnSave);
    }
示例#14
0
    // get stored Player Prefs if they exist, otherwise go with defaults set on gameObject
    void refreshPlayerState()
    {
        highscore = PlayerPrefManager.GetHighscore();

        // save that this level has been accessed so the MainMenu can enable it
        PlayerPrefManager.UnlockLevel();
    }
示例#15
0
 void OnEnable()
 {
     for (int i = 0; i < poseButtons.Length; i++)
     {
         poseButtons[i].interactable = PlayerPrefManager.IsPoseBought(i);
     }
 }
示例#16
0
 public void SaveHighscore()
 {
     if (score > PlayerPrefManager.GetInt("game_highscore"))
     {
         PlayerPrefManager.SetInt("game_highscore", score);
     }
 }
示例#17
0
 private void Start()
 {
     PlayerPrefManager.UnlockLevel(2);
     print(PlayerPrefManager.IsLevelUnlocked(1));
     print(PlayerPrefManager.IsLevelUnlocked(2));
     fixedDT = Time.fixedDeltaTime;
 }
示例#18
0
 // play sound through the audiosource on the gameobject
 void PlaySound(AudioClip clip)
 {
     if (PlayerPrefManager.GetSoundEffect() == 1)
     {
         _audio.PlayOneShot(clip);
     }
 }
 public void SaveAndExit()
 {
     PlayerPrefManager.SetMasterVolume(volumeSlider.value);
     PlayerPrefManager.SetDifficulty(difficultySlider.value);
     print(PlayerPrefManager.GetDifficulty());
     levelManager.LoadLevel("01a Start");
 }
示例#20
0
 //uses game state to determine next level
 void DetermineNextStage()
 {
     if (GameManager.gameManager)
     {
         //handle stage progression when enough landmarks/scents have been encountered
         if (nextStageThroughProgressPossible())
         {
             //advance to end if suburbs have been completed
             if (PlayerPrefManager.GetSuburbsComplete())
             {
                 this.nextLevel = "GameComplete";
                 Debug.Log(this.nextLevel);
             }
             else
             {
                 this.nextLevel = "CityStart";
                 Debug.Log(this.nextLevel);
                 PlayerPrefManager.SetSuburbsComplete(true);
             }
         }
         //handle rng skip stage event
         else if (GameManager.gameManager.skipToNextStagePossible)
         {
         }
         //handle other rng events
         //else if(GameManager.gameManager){}
         //nothing happened, go on to next level as usual
         else
         {
             return;
         }
     }
 }
示例#21
0
 void Start()
 {
     AddSelfToPlayerPrefObserverList();
     key_interact   = PlayerPrefManager.GetString("key_interact");
     whiteTextColor = Color.white;
     blackTextColor = Color.black;
 }
示例#22
0
 void OnEnable()
 {
     for (int i = 0; i < backgroundButtons.Length; i++)
     {
         backgroundButtons[i].interactable = PlayerPrefManager.IsBackgroundBought(i);
     }
 }
示例#23
0
 void setKeyBind(string name, KeyCode kcode)
 {
     PlayerPrefManager.SetString(name, kcode.ToString());
     PlayerPrefManager.MessageKeybindObservers();
     callingButtonTextField.text = kcode.ToString();
     gameObject.SetActive(false);
 }
 public void HideAdButton()
 {
     if (PlayerPrefManager.GetBool("benedev.mansnothot.noads") == true)
     {
         adsButton.SetActive(false);
     }
 }
    // get stored Player Prefs if they exist, otherwise go with defaults set on gameObject
    void refreshPlayerState()
    {
        lives = PlayerPrefManager.GetLives();

        //An Attempt to Implement added Lives
        if (score == 1 && eLife1 == true)
        {
            GiveLife();
            refreshGUI();
            Debug.LogError("YOU HAVE TRIGGERED THE SCRIPT.");
            eLife1 = false;
        }
        if (score == 90)
        {
            GiveLife();
        }
        if (score == 155)
        {
            GiveLife();
        }

        // special case if lives <= 0 then must be testing in editor, so reset the player prefs
        if (lives <= 0)
        {
            PlayerPrefManager.ResetPlayerState(startLives, false);
            lives = PlayerPrefManager.GetLives();
        }
        score     = PlayerPrefManager.GetScore();
        highscore = PlayerPrefManager.GetHighscore();

        // save that this level has been accessed so the MainMenu can enable it
        PlayerPrefManager.UnlockLevel();
    }
    void Start()
    {
        if (instance == null)
        {
            instance = this.GetComponent <MainMenuManager>();
        }

        if (PlayerPrefManager.GetNoAdsPurchased() == true)
        {
            purchaseNoAdsButton.SetActive(false);
        }

        //has player gotten rid of ads?
        HideAdButton();

        if (PlayerPrefManager.GetSoundFX() == true)
        {
            SFX_Images[0].SetActive(false); // SFX off image
            SFX_Images[1].SetActive(true);  // SFX on image
        }
        else
        {
            SFX_Images[0].SetActive(true);  // SFX off image
            SFX_Images[1].SetActive(false); // SFX on image
        }
    }
示例#27
0
    public void OnClickAudioBtn()
    {
        int audioValue = PlayerPrefManager.GetAudio();

        PlayerPrefManager.SetAudio(audioValue == 0 ?1:0);
        SetAudioButton();
    }
    public void ToggleSFX()
    {
        if (PlayerPrefManager.GetSoundFX() == false)
        {
            //if soundFX is on and button sound is set
            if (PlayerPrefManager.GetSoundFX() == true && touchButtonSound)
            {
                GetComponent <AudioSource>().PlayOneShot(touchButtonSound);
            }


            //turn off SFX
            PlayerPrefManager.SetSoundFX(true);
            sfxOn = false;
            Debug.Log("SFX on");

            SFX_Images[0].SetActive(false);
            SFX_Images[1].SetActive(true);
        }
        else
        {
            //turn on SFX
            PlayerPrefManager.SetSoundFX(false);
            sfxOn = true;
            Debug.Log("SFX off");

            SFX_Images[0].SetActive(true);
            SFX_Images[1].SetActive(false);
        }
    }
示例#29
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        //show the default inspector stuff for this component
        DrawDefaultInspector();

        //get a reference to the GameManager script on this target gameObject
        GameManager myGM = (GameManager)target;

        //add a custom button to the Inspector component
        if (GUILayout.Button("Reset Player State"))
        {
            //if button pressed, then call function in script
            PlayerPrefManager.ResetPlayerState(myGM.startLives, false);
        }

        //add a custom button to the Inspector component
        if (GUILayout.Button("Reset Highscore"))
        {
            //if button pressed then call function in script
            PlayerPrefManager.SetHighscore(0);
        }

        //add a custom button to the Insspector component
        if (GUILayout.Button("Output Player State"))
        {
            PlayerPrefManager.ShowPlayerPrefs();
        }
    }
示例#30
0
    private void Update()
    {
        if (fade)
        {
            alphaColor      = Mathf.Lerp(fadeImage.color.a, 1, Time.deltaTime * 1.5f);
            fadeImage.color = new Color(0, 0, 0, alphaColor);
        }

        if (alphaColor > 0.95 && fade)
        {
            fade = false;
            StartScene();
        }

        if (player != null)
        {
            if (GameManager.gm.playerHP < 1)
            {
                PlayerPrefManager.SetScore((int)GameManager.gm.score);
                Instantiate(playerExplosionPrefab, player.transform.position, Quaternion.identity);
                Destroy(player);
                Change_scene();
                AudioSource.PlayClipAtPoint(explosion_sound, Camera.main.transform.position, 1.0f);
            }
        }
    }