Esempio n. 1
0
 public void SetMenuData(int lives, PlayerController.WeaponTypes weaponType, PlayerController.WeaponsStruct[] weaponsData)
 {
     // save player data for menu setup
     this.playerLives       = lives;
     this.playerWeaponType  = weaponType;
     this.playerWeaponsData = weaponsData;
 }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        if (canSelectWeapon)
        {
            // move up on weapons and play sound
            if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                playerWeaponType = FindNextWeapon("Up");
                UpdateWeaponLetters();
                SoundManager.Instance.Play(menuSelectClip);
            }

            // move down on weapons and play sound
            if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                playerWeaponType = FindNextWeapon("Down");
                UpdateWeaponLetters();
                SoundManager.Instance.Play(menuSelectClip);
            }

            // flash weapon letter (no timescale, no coroutine)
            letterFlashTimer -= Time.unscaledDeltaTime;
            if (letterFlashTimer <= 0)
            {
                // toggle the alpha on the letter's canvas group
                float alpha = Letters[(int)playerWeaponType].GetComponent <CanvasGroup>().alpha;
                Letters[(int)playerWeaponType].GetComponent <CanvasGroup>().alpha = (alpha == 1f) ? 0f : 1f;
                // reset the flashing timer
                letterFlashTimer = letterFlashDelay;
            }
        }
    }
Esempio n. 3
0
 public void PauseGame(bool pauseMusic = true)
 {
     // if we can pause the game and it isn't already paused
     if (canPauseGame && !isGamePaused)
     {
         isGamePaused   = true;
         timeScale      = Time.timeScale;
         Time.timeScale = 0;
         if (pauseMusic)
         {
             SoundManager.Instance.MusicSource.Pause();
         }
         SoundManager.Instance.Play(assetPalette.pauseMenuClip);
         // get current player weapon type and save it
         if (player != null)
         {
             playerWeaponType = player.GetComponent <PlayerController>().playerWeapon;
         }
         // this is optional if you want to display an on-screen message
         //  save previous message if any
         messageText            = screenMessageText.text;
         screenMessageText.text = "PAUSED";
     }
     else if (isGamePaused && !inWeaponsMenu)
     {
         // if the game is paused then unpause it, but not when in weapons menu
         isGamePaused   = false;
         Time.timeScale = timeScale;
         if (pauseMusic)
         {
             SoundManager.Instance.MusicSource.Play();
         }
         // use player's SwitchWeapon instead of TeleportPlayer
         //TeleportPlayer(true, false);
         if (player != null)
         {
             player.GetComponent <PlayerController>().SwitchWeapon(playerWeaponType);
         }
         // this is optional if you did display an on-screen message
         //   restore previous message if any
         screenMessageText.text = messageText;
     }
 }
Esempio n. 4
0
    public void OnWeaponsMenuExit()
    {
        // show the HUD Canvas, Player, and everything else
        if (HUDCanvas != null)
        {
            HUDCanvas.SetActive(true);
        }
        if (player != null)
        {
            player.GetComponent <PlayerController>().HidePlayer(false);
        }
        HideEverything(false);

        // get the player's selected weapon (overrides existing and sets in PauseGame)
        playerWeaponType = WeaponsMenu.GetComponent <WeaponsMenu>().GetWeaponSelection();

        // not in the weapons menu anymore
        inWeaponsMenu = false;

        // unpause the game
        PauseGame(pauseMusic);
    }