IEnumerator LoadLevelAsync(string sceneName) { AsyncOperation operation = SceneManager.LoadSceneAsync(sceneName); operation.allowSceneActivation = false; bool isLoaded = false; text.text = "Loading..."; while (!operation.isDone) { float progress = Mathf.Clamp01(operation.progress / 0.9f); fillBar.SetFill(progress); if (operation.progress >= 0.9f) { if (!isLoaded) { // set Text text.text = "Push <Enter> to start, sucka!"; textAnimator.SetTrigger("IsDone"); isLoaded = true; } if (Input.GetButtonDown("Enter")) { operation.allowSceneActivation = true; } } yield return(null); } }
// Update is called once per frame void Update() { if (Input.GetAxis((JoystickControlls.RIGHT_TRIGGER[playerID])) > 0.0f && timer <= 0.0f && ammoInClip > 0) { for (int i = 0; i < FIRE_POINTS.Length; i++) { Shoot(i); } if (isSingle) { timer = Mathf.Infinity; } else { timer = fireTime; } ammoInClip--; UI_HANDLER.SetUIAmmo(playerID, ammoInClip + "/" + ammo); } else if (Input.GetButton(JoystickControlls.X[playerID]) && !isReloading) { if (ammoInClip < clipSize && ammo > 0) { StartCoroutine(Reload(RELOAD_TIME)); } } if (isReloading) { currentReloadTime += Time.deltaTime; reloadBar.SetFill(Mathf.Lerp(0.0f, 1.0f, currentReloadTime / RELOAD_TIME)); } if (isSingle) { if (Input.GetAxis(JoystickControlls.RIGHT_TRIGGER[playerID]) == 0.0f) { timer = 0.0f; } } timer -= Time.deltaTime; recoil -= Time.deltaTime; recoil = Mathf.Max(0.0f, recoil); }
public void UpdateHealth(int h, int max) { playerHealthBar.SetFill((float)h / max); }