Beispiel #1
0
 void Start()
 {
     ThisScore = new ScoreFormat();
     ScoreName = transform.Find("Canvas/ScoreName").gameObject;
     ScoreName.GetComponent <InputField>().onEndEdit.AddListener(delegate { IsInput(ScoreName.GetComponent <InputField>()); });
     MusicVolSlider.GetComponent <Slider>().value = SaveLoad.musicVol;
     SFXVolSlider.GetComponent <Slider>().value   = SaveLoad.fXVol;
     Tips.SetActive(false);
     PauseScreen.SetActive(false);
     ScoreName.SetActive(false);
     AmmoCount = MaxAmmo;                             //set ammo
     EndUI.GetComponent <Text>().text = string.Empty; //initialised as blank to get rid of the filler text
     ExitGameButton.GetComponent <Button>().onClick.AddListener(ExitGame);
     StartCoroutine(StartAudio());                    //play music
     UpdateBarUI();
 }
Beispiel #2
0
    void Update()
    {
        if (PauseScreen.activeSelf)
        {
            SaveLoad.musicVol = MusicVolSlider.GetComponent <Slider>().value;
            SaveLoad.fXVol    = SFXVolSlider.GetComponent <Slider>().value;
        }
        Music.GetComponent <AudioSource>().volume = SaveLoad.musicVol;
        var ppp = ppb.colorGrading.settings;

        SaveLoad.hueShift        += 0.1f;
        ppp.basic.hueShift        = SaveLoad.hueShift;
        ppb.colorGrading.settings = ppp;
        if ((!GameStarted) && Input.anyKey) //player has started game
        {
            GameStarted = true;
            GameStartText.SetActive(false);
            LevelTime = Time.time;
        }
        if (GameStarted)
        {
            if (Input.GetKeyDown(KeyCode.Escape) && !ResettingScene && PlayerHealth > 0) //pause the game
            {
                PauseGame();
            }
            if (Time.timeScale != 0)                                                         //game isnt paused
            {
                AmmoRegenTimer += Time.deltaTime;                                            //wait for regen to start
                ShotCDTimer    += Time.deltaTime;                                            //shotspeed incrememnt
                if ((Time.time - LevelTime) >= (50 * OnLevel) + OnLevel && PlayerHealth > 0) //Level Up
                {
                    LevelUp();
                }
                if (InstructionsUI.transform.position.y < 40 && Time.timeSinceLevelLoad > 8)
                {
                    InstructionsUI.transform.position += Vector3.up / 50;
                }
                if (AmmoRegenTimer > AmmoWait && AmmoCount < MaxAmmo) //start regening ammo
                {
                    AmmoCount += 1.25f;
                }
                UpdateBarUI();
                if (PlayerHealth <= 0 && ResettingScene == false) //do the end game ui's
                {
                    EndGameUI();
                }
                else
                {
                    if (Input.GetKey(KeyCode.Space))
                    {
                        Fire();
                    }
                    if (Input.GetKey(KeyCode.LeftArrow))
                    {
                        Barrel.transform.GetChild(2).GetComponent <ParticleSystem>().Play();
                        BarrelRotate(Vector3.forward);
                    }
                    else if (Input.GetKey(KeyCode.RightArrow))
                    {
                        Barrel.transform.GetChild(1).GetComponent <ParticleSystem>().Play();
                        BarrelRotate(-Vector3.forward);
                    }
                    else
                    {
                        BarrelMoveSpeed = 100;
                    }
                }
            }
        }
    }