// Update is called once per frame void Update() { if (this.name == EventSystem.current.currentSelectedGameObject.name) { if ((Input.GetKeyDown(GameConstants.R) || Input.GetKeyDown(GameConstants.L)) && ((optionSelected == 0) || (optionSelected == settingOptions.Length - 1))) { soundEffect.PlaySoundEffect("Wrong"); } if (Input.GetKeyDown(GameConstants.L) && (optionSelected != 0)) { soundEffect.PlaySoundEffect("SettingsSlider"); optionSelected--; settingText.GetComponent <Texts>().SetText(settingOptions[optionSelected]); if (optionSelected == 0) { leftArrow.SetActive(false); } rightArrow.SetActive(true); SetArrows(); } if (Input.GetKeyDown(GameConstants.R) && (optionSelected != settingOptions.Length - 1)) { soundEffect.PlaySoundEffect("SettingsSlider"); optionSelected++; settingText.GetComponent <Texts>().SetText(settingOptions[optionSelected]); if (optionSelected == settingOptions.Length - 1) { rightArrow.SetActive(false); } leftArrow.SetActive(true); SetArrows(); } } }
private bool ChooseCharacter(string charName) { if (!CharacterAlreadyChosen(charName)) { soundEffect.PlaySoundEffect("ConfirmCharSel"); chosenChars++; switch (chosenChars) { case 1: firstChosenCharacter.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Textures_and_Sprites/Menus/Interface/CharacterSelectionMenu/CharacterProfile/" + characterSeries + "/" + charName + "/" + "Chosen" + charName + "Background"); CurrentFightStats.SetSelectedCharacterPlayer1(charName, 0); break; case 2: secondChosenCharacter.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Textures_and_Sprites/Menus/Interface/CharacterSelectionMenu/CharacterProfile/" + characterSeries + "/" + charName + "/" + "Chosen" + charName + "Background"); CurrentFightStats.SetSelectedCharacterPlayer1(charName, 1); break; case 3: thirdChosenCharacter.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Textures_and_Sprites/Menus/Interface/CharacterSelectionMenu/CharacterProfile/" + characterSeries + "/" + charName + "/" + "Chosen" + charName + "Background"); CurrentFightStats.SetSelectedCharacterPlayer1(charName, 2); loadScene.LoadByIndex(8); break; } return(true); } soundEffect.PlaySoundEffect("Wrong"); return(false); }
void Update() { Scene currentScene = SceneManager.GetActiveScene(); if (Input.GetKeyDown(GameConstants.BACK)) { switch (currentScene.buildIndex) { case 2: soundEffect.PlaySoundEffect("Back"); LoadByIndex(1); break; ///Versus case 3: case 4: case 5: soundEffect.PlaySoundEffect("Back"); LoadByIndex(2); break; ///VSCPU, CPUVSCPU, PVP } } }
void applyDamage() { if (!immune) { soundEffectPlayer.PlaySoundEffect("moon_comet_hit", 0.5f); healthBarSliderMoon.value -= 0.2f; } }
public void ClosePopUp() { popUpWindow.SetActive(false); myEventSystem = EventSystem.current; myEventSystem.SetSelectedGameObject(previouslySelectedObject); image.color = new Color(image.color.r, image.color.g, image.color.b, 0f); soundEffect.PlaySoundEffect("Back"); }
void OnTriggerEnter2D(Collider2D col) { if (col.gameObject.tag == "Moon") { soundEffectPlayer.PlaySoundEffect("get_immune", 0.5f); col.gameObject.BroadcastMessage("setImmune"); GameObject.FindGameObjectWithTag("Sun").BroadcastMessage("setImmuneSun"); this.gameObject.SetActive(false); } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(GameConstants.BACK)) { switch (currentPopUp) { case PopUp.None: soundEffect.PlaySoundEffect("Back"); loadScene.LoadByIndex(1); break; case PopUp.Controls: case PopUp.Language: case PopUp.Version: PopUpInactive(); break; } } }
void OnGUI() { Event e = Event.current; if (e.isKey && waitForInput && e.keyCode != KeyCode.Return && e.keyCode != KeyCode.Escape && e.keyCode != KeyCode.None) //None must be checked because when the key is lifted, it sends a None event.// { bool buttonAssigned; buttonAssigned = GameConstants.CheckButtonExists(e.keyCode); if (!buttonAssigned) { soundEffect.PlaySoundEffect("Confirm"); typeof(GameConstants).GetField(buttonToChange).SetValue(null, e.keyCode); GameConstants.ReloadButtonsAsigned(); currentButtonSelected.GetComponent <Button>().interactable = true; EventSystem.current.SetSelectedGameObject(currentButtonSelected); waitForInput = false; ShowButtons(); } if (e.type == EventType.KeyUp && waitForInput) /////Has to be played when key up, otherwise it replays the sound effect constantly while pressed { soundEffect.PlaySoundEffect("Wrong"); } } }
public void SendScoreToCustomer() { GameObject coffee = Instantiate(coffeePF); coffee.transform.position = transform.position + new Vector3(.5f, 0, 0); coffee.GetComponent <Fade>().init(); coffee.GetComponent <Fade>().setShow(true); coffee.GetComponent <ILerpable>().lerpTo(coffee.transform.position + new Vector3(0f, 1.25f, 0), 3.0f); ClearScore(); soundEffectPlayer.PlaySoundEffect(coffeeFillSound); if (customerManager.customersServed + 1 < customerManager.customersPerDay) { Core.core.ExecuteAfterTime(1f, () => { board.unlockBoard(); }); } Core.core.ExecuteAfterTime(coffeeDuration, () => { coffee.GetComponent <FadeOnDestroy>().Destroy(); SendScoreToCustomerDelayed(); }); }
public void PlayButtonSoundEffect(string currentSoundEffect) { soundEffect.PlaySoundEffect(currentSoundEffect); }
private void Update() { timebetweenshot += Time.deltaTime; if (timer > 0) { timer -= Time.deltaTime; } if (timer < 0) { if (!immunityOff) { Debug.Log("immunity off now set to true"); soundEffectPlayer.PlaySoundEffect("stop_immune", 0.5f); inputFlipped = inputFlipState; immunityOff = true; } } if (healthBarSlider.value <= 0) { // go to game over scene Debug.Log("Sun - Game Over"); } // Input for movement if (!inputFlipped) { if (Input.GetKey(KeyCode.UpArrow)) { rb.AddForce(movement); } else if (Input.GetKey(KeyCode.DownArrow)) { rb.AddForce(-movement); } } else { if (Input.GetKey(KeyCode.UpArrow)) { rb.AddForce(-movement); } else if (Input.GetKey(KeyCode.DownArrow)) { rb.AddForce(movement); } } // Getting mouse position and then making sure that the sun faces the mouse with it's "up" vector mousePosition = Input.mousePosition; Vector3 diff = Camera.main.ScreenToWorldPoint(mousePosition) - transform.position; diff.Normalize(); float rotZ = Mathf.Atan2(diff.y, diff.x) * Mathf.Rad2Deg; transform.rotation = Quaternion.Euler(0f, 0f, rotZ - 90); // Fire if (Input.GetMouseButtonDown(0) && timebetweenshot > 0.5f) { Fire(mousePosition); timebetweenshot = 0f; } // Ensure that the x position of the sun is the same as the start if (transform.position.x != startPosition.x) { transform.position = new Vector3(startPosition.x, transform.position.y); } }