/// <summary> /// Trigger event. /// </summary> /// <returns>IEnumerator public override IEnumerator TriggerEvent() { canBeTriggered = false; Player.instance.playerUI.iconWrapper.Hide(); Player.instance.playerController.SetPlayerInEventMode(); _audio.PlaySound(0); // set up dialogue data. GameManager.instance.overWorldUI.dialogueBox.data = data; // play dialogue. GameManager.instance.overWorldUI.dialogueBox.Play(); while (GameManager.instance.overWorldUI.dialogueBox.playing) { yield return(new WaitForEndOfFrame()); } yield return(new WaitForSeconds(.1f)); Player.instance.playerController.SetPlayerOutOfEventMode(); yield return(new WaitForSeconds(.5f)); canBeTriggered = true; _event = null; }
/// <summary> /// Play enemy standard sound. /// </summary> protected override void PlayStandardSound() { if (_audio != null) { _audio.PlaySound(0); } }
/// <summary> /// Get damage. /// </summary> /// <param name="damage">float - how much damage the player has received</param> public void GetDamage(float damage) { // update player damage. float damageReceived = (damage / playerData.defense) + UnityEngine.Random.Range(0f, .3f); playerData.UpdateHitPoints(-damageReceived); // set player as invencible so it cannot get damage too fast for enemies - FPSInput class will remove invencible status automatically. playerInput.invencible = true; if (playerData.hitPoints > 0f) { // generate a radom number between all the damage sounds keys for player ( currently 2 ). int index = Random.Range(1, 3); // play damage audio. _audio.PlaySound(index); // display UI damage elements. if (GamePlayUI.instance != null) { GamePlayUI.instance.PlayerDamaged(); } } else { // player has no more hit points - gameover // TODO: Add game over call here. Debug.Log("Game Over"); } }
public override void Update(GameTime gameTime) { if (direction) { if (!playedSound && !start) { audioComponent?.PlaySound("lever"); playedSound = true; } parent.RotationZ += 8 * stepSize * (float)gameTime.ElapsedGameTime.TotalSeconds; if (parent.RotationZ > endRotation) { direction = false; playedSound = false; } } else { if (parent.RotationZ >= startRotation) { parent.RotationZ -= 8 * stepSize * (float)gameTime.ElapsedGameTime.TotalSeconds; if (!playedSound && !start) { audioComponent?.PlaySound("lever"); playedSound = true; } } else { playedSound = false; } start = false; } }
/// <summary> /// Hover by mouse logic. /// </summary> public void Hover() { if (!textAnim.displayed) { _audio.PlaySound(); textAnim.FadeIn(1f); // Standard fade speed. } }
/// <summary> /// On focus. /// </summary> private void OnFocus() { StartCoroutine(AwaitCursor()); audio.PlaySound(0); cursor.SetActive(true); textAnim.SetBool("Focus", true); onFocus = true; }
/// <summary> /// Run interact process coroutine. /// </summary> /// <returns>IEnumerator</returns> private IEnumerator RunInteractProcessRoutine() { _anim.SetBool("KeyPressed", true); if (_innmediate) { // display inmediate use interactable. _audio.PlaySound(0); yield return(new WaitForSeconds(.5f)); Hide(); yield return(new WaitForSeconds(.1f)); completed = true; _actionRoutine = null; yield break; } // update text and display fill progress image. actionLabelText.UpdateContent(_labelProgress); fillImage.gameObject.SetActive(true); // update action progress bar. while (Input.GetKey("f") && fillImage.fillAmount < 1f) { inProcess = true; fillImage.fillAmount += _fillSpeed * Time.deltaTime; yield return(new WaitForFixedUpdate()); } inProcess = false; actionLabelText.UpdateContent(_label); // set completed if action was actually completed. if (fillImage.fillAmount == 1f) { _audio.PlaySound(0); completed = true; yield return(new WaitForSeconds(.1f)); Hide(); _anim.SetBool("KeyPressed", false); } else { _anim.SetBool("KeyPressed", false); _audio.PlaySound(1); } // reset and remove fill image. fillImage.fillAmount = 0f; fillImage.gameObject.SetActive(false); _actionRoutine = null; }
/// <summary> /// Cristal hit by player actions. /// </summary> /// <param name="damage">float - damage received by hit impact.</param> public virtual void Hit(float damage) { resistance = resistance - damage; if (resistance > 0) { // play sound. _audio.PlaySound(); } }
/// <summary> /// Switch lintern on. /// </summary> private void SwitchOn() { if (linternData.currentBattery > 0f) { linternData.enabled = true; leftFocus.SwitchOn(); rightFocus.SwitchOn(); _audio.PlaySound(); } }
/// <summary> /// Hover in. /// This method is called /// from event system component. /// </summary> public void HoverIn() { _cursorIn = true; // display item temporally to tell the player than the item can be dropped here. if (DragHandler.itemHandled != null && DragHandler.itemHandled.type == ItemData.Type.basic) { _audio.PlaySound(0); _anim.SetBool("Hover", true); itemImage.sprite = DragHandler.itemHandled.sprite; } }
/// <sumamry> /// Display coroutine. /// </summary> /// <returns>IEnumerator</returns> private IEnumerator DisplayRoutine() { _audio.PlaySound(0); // display menu background and sections. background.FadeIn(); yield return(new WaitForSecondsRealtime(.3f)); menuNavigation.gameObject.SetActive(true); menuContent.gameObject.SetActive(true); displayed = true; _animRoutine = null; }
/// <summary> /// Hover logic. /// This method is triggered from /// event system component. /// </summary> public void HoverIn() { if (!empty && itemData != null) { _audio.PlaySound(0); _anim.SetBool("Hover", true); // update sidebar description data. if (_itemsSections != null) { _itemsSections.descriptionSection.UpdateSection(itemData.description_en, itemData.sprite, true); } } }
/// <summary> /// Trigger event. /// </summary> /// <returns>IEnumerator public override IEnumerator TriggerEvent() { canBeTriggered = false; Player.instance.playerUI.iconWrapper.Hide(); Player.instance.playerController.SetPlayerInEventMode(); _audio.PlaySound(1); if (localVars.GetVar(varToUnlock)) // already used. // set up dialogue data. { GameManager.instance.overWorldUI.dialogueBox.data = alreadyOnDialogueContent; // play dialogue. GameManager.instance.overWorldUI.dialogueBox.Play(); while (GameManager.instance.overWorldUI.dialogueBox.playing) { yield return(new WaitForEndOfFrame()); } } else { // set up dialogue data. GameManager.instance.overWorldUI.dialogueBox.data = dialogueContent; // play dialogue. GameManager.instance.overWorldUI.dialogueBox.Play(); while (GameManager.instance.overWorldUI.dialogueBox.playing) { yield return(new WaitForEndOfFrame()); } yield return(new WaitForSeconds(.5f)); _audio.PlaySound(0); localVars.SetVar(varToUnlock, true); yield return(new WaitForSeconds(.5f)); } Player.instance.playerController.SetPlayerOutOfEventMode(); yield return(new WaitForSeconds(.5f)); canBeTriggered = true; _event = null; }
/// <summary> /// Trigger event. /// </summary> /// <returns>IEnumerator</returns> public override IEnumerator TriggerEvent() { canBeTriggered = false; Player.instance.playerUI.iconWrapper.Hide(); Player.instance.playerController.SetPlayerInEventMode(); topCollider.enabled = false; bottomCollider.enabled = false; _audio.PlaySound(0); // _enterFromDown = IsEnteringFromDown(); Vector3 destination = (position == "bottom") ? bottomStair.position : topStair.position; Player.instance.playerController.SetOrientation(PlayerSpawnData.Orientation.up); if (_movingRoutine == null) { _movingRoutine = StartCoroutine(MovePlayerToStairPoint(destination)); } while (movingToPoint && _movingRoutine != null) { yield return(new WaitForFixedUpdate()); } climbing = true; // enable climbing controls here. while (climbing) { yield return(new WaitForFixedUpdate()); } yield return(new WaitForSeconds(.1f)); Player.instance.playerController.SetPlayerOutOfEventMode(); topCollider.enabled = true; bottomCollider.enabled = true; yield return(new WaitForSeconds(.5f)); canBeTriggered = true; _event = null; }
/// <summary> /// Jump player logic. /// </summary> private IEnumerator Jump() { // temporally disable ground checker. if (_groundCheckerRoutine == null) { _groundCheckerRoutine = StartCoroutine("DisableGrounding"); } grounded = false; // play jump sound. _audio.PlaySound(0); Vector3 movement = Vector3.zero; float jumpForce = (isRunning) ? jumpSpeed + runningJumpBoost : jumpSpeed; movement.y = jumpForce; while (!grounded) { movement.y -= (-gravity) * Time.deltaTime; _charController.Move(movement * Time.deltaTime); yield return(null); } _jump = null; }
/// <summary> /// Trigger event. /// </summary> /// <returns>IEnumerator public override IEnumerator TriggerEvent() { canBeTriggered = false; GameManager.instance.overWorldUI.UICover.FadeIn(); Player.instance.playerUI.iconWrapper.Hide(); Player.instance.playerController.SetPlayerInEventMode(); _audio.PlaySound(0); yield return(new WaitForSeconds(1.5f)); Player.instance.gameObject.transform.position = spawnToUse.position; Player.instance.playerController.SetOrientation(orientation); yield return(new WaitForSeconds(.5f)); GameManager.instance.overWorldUI.UICover.FadeOut(); Player.instance.playerController.SetPlayerOutOfEventMode(); yield return(new WaitForSeconds(.5f)); canBeTriggered = true; _event = null; }
/// <sumamry> /// Open chest coroutine. /// </summary> /// <returns>IEnumerator</returns> public IEnumerator OpenRoutine() { opened = true; // play sound. _audio.PlaySound(); // remove current chest particles. externalParticles.Stop(); // open chest. anim.SetBool("Open", true); yield return(new WaitForSeconds(.6f)); innerLight.SetActive(true); yield return(new WaitForSeconds(1.65f)); // play particle effects. foreach (ParticleSystem particles in openinigParticles) { particles.gameObject.SetActive(true); } // drop chest content into game scene. loot.DropLoot(); }
public override void Activate() { var board = Owner.Board; var ownerPos = Owner.Position; var from = board.TileAt(ownerPos); Point targetDir = new Point((Mathf.Clamp(Target.tile.Position.x - ownerPos.x, -1, 1)), (Mathf.Clamp(Target.tile.Position.y - ownerPos.y, -1, 1))); var instance = Instantiate(Resources.Load <GameObject> ("Prefabs/Projectile"), new Vector3((targetDir.x + ownerPos.x), (targetDir.y + ownerPos.y), -2), Quaternion.identity); if (Owner.dir != targetDir.ToDirection()) { var toTurn = from.GetDirection(Target.tile); Owner.AbilityComponent.TurnUnit(toTurn); } instance.AddComponent <ProjectileComponent> ().Initialize(targetDir, OnAbilityConnected); instance.AddComponent <DestinationComponent> ().Initialize(Target.tile.Position, OnAbilityConnected); AudioComponent.PlaySound(Sounds.BOMB_LAUNCHED); OnFinished(EnergyCost); }
/// <summary> /// Pause game and display pause screen. /// </summary> /// <returns>IEnumerator</returns> private IEnumerator PauseGameRoutine() { _audio.PlaySound(); Time.timeScale = 0; GameManager.instance.paused = true; GameManager.instance.LockGameMenu(); background.SetBool("Displayed", true); yield return(new WaitForSecondsRealtime(toWait)); pauseText.FadeIn(fadeSpeed); lineLeft.FadeIn(fadeSpeed); lineRight.FadeIn(fadeSpeed); _pauseRutine = null; }
public override void OnTrigger(GameObject triggered) { System.Diagnostics.Debug.WriteLine("Lina trafiona"); audioComponent.PlaySound("cut"); component.dropBridge = true; base.OnTrigger(null); }
public override void Activate() { if (Owner == null) { return; } if (Target == null) { Debug.Log(string.Format("No Target")); return; } var targetUnit = Target.tile.OccupiedBy; var from = Owner.Board.TileAt(Owner.Position); var toTurn = from.GetDirection(Target.tile); Owner.AbilityComponent.TurnUnit(toTurn); if (targetUnit != null) { OnAbilityConnected(targetUnit.gameObject); } var vfx = Instantiate(Resources.Load <GameObject> ("Prefabs/Player Impact Visual"), new Vector3(Target.tile.Position.x, Target.tile.Position.y, Layers.Foreground), Quaternion.identity); AudioComponent.PlaySound(Sounds.BITE); Destroy(vfx, 0.2f); OnFinished(EnergyCost); }
/// <summary> /// Hover. /// </summary> public void Hover() { if (_button.interactable) { _audio.PlaySound(0); } }
public override UnitState HandleInput(Controller controller) { var swappedAbility = SwapActiveAbility(controller); if (swappedAbility != null) { BoardVisuals.RemoveTilesFromHighlightsByUnit(Owner); CleanIndicator(); return(swappedAbility); } List <PathfindingData> tilesInRange = GetTilesInRange(); // handling a special case where the targetting is programmatic. // will ecentually need to accomodate for this in a more robust way using OOP if (abilityComponent.CurrentAbility.AutoTargets) { PathfindingData autoTarget = tilesInRange.FirstOrDefault( element => element.tile.IsOccupied() && element.tile.OccupiedBy.GetComponent <Monster> () ); if (autoTarget == null) { AudioComponent.PlaySound(Sounds.ERROR); onAbilityCanceled(); return(new PlayerIdleState(Owner)); } if (Owner.EnergyComponent.AdjustEnergy(-abilityComponent.CurrentAbility.EnergyCost) && abilityComponent.PrepAbility(tilesInRange, autoTarget)) { onAbilityCommited(Owner, abilityComponent.IndexOfCurrentAbility()); return(new PlayerActingState(Owner, tilesInRange, autoTarget)); } } Point mousePosition = BoardUtility.mousePosFromScreenPoint(); HighlightTiles(tilesInRange, mousePosition); // user clicks on a walkable tile which is in range.... if (controller.DetectInputFor(ControlTypes.CONFIRM)) { PathfindingData selectedTarget = tilesInRange.Find( element => element.tile.Position == mousePosition ); // transition to acting state if it's a valid selection // and we successfully prep our ability for use bool targetIsValid = selectedTarget != null && selectedTarget.tile.isWalkable; if (targetIsValid && Owner.EnergyComponent.AdjustEnergy(-abilityComponent.CurrentAbility.EnergyCost) && abilityComponent.PrepAbility(tilesInRange, selectedTarget)) { onAbilityCommited(Owner, abilityComponent.IndexOfCurrentAbility()); return(new PlayerActingState(Owner, tilesInRange, selectedTarget)); } } return(null); }
/// <summary> /// Play level up animation. /// </summary> public void PlayLevelUpAnim() { foreach (ParticleSystem levelUpParticleSys in levelUpParticles) { levelUpParticleSys.Play(); } levelUpAudio.PlaySound(); }
/// <summary> /// Hover by mouse logic. /// </summary> public void Hover() { if (!active && _button.interactable && !textAnim.displayed) { _audio.PlaySound(0); // Play first sound in the sound pool. textAnim.FadeIn(1f); // Standard fade speed; } }
/// <sumamry> /// Hit method. /// Called every time the gravity /// crystal is hit by player's projectile. /// </summary> private void Hit() { if (interactable) { if (activationHits > 0) { _anim.SetTrigger("Hit"); distorsion.Play(); particleHit.Play(); _audio.PlaySound(0); activationHits--; } else { // call enabled method here. Enabled(); } } }
public override void Activate() { if (Owner is Hero) { AudioComponent.PlaySound(Sounds.RUNNING); } // start a timer with a callback to transition to the next state StartCoroutine(Movement.Traverse(TilesInRange, Target, () => { OnDestinationReached(); })); }
/// <summary> /// Update is called every frame, if the MonoBehaviour is enabled. /// </summary> void Update() { if (GameManager.instance.inGamePlay && !GameManager.instance.isPaused) { // set the weapon animation. // SetAnimation(); // calculate point in the screen where the bullet is going to be shot at. UpdateShootingOriginPosition(); // check if weapon has cooled. CheckHeatedStatus(); // check if the user is clicking the left button mouse to shoot. if (Input.GetMouseButtonDown(0) && !plasmaGunData.heated && !player.isRunning) { Shoot(); } // display no ammo sound if the users tries to shoot and the plasma gun is heated. if (Input.GetMouseButtonDown(0) && plasmaGunData.heated) { // display no ammo sound. _audio.PlaySound(1); } if (Input.GetMouseButtonUp(0)) { _framesHolding = 0; } } else { // stop heated sound if game gets paused. if (_heatedRoutine != null) { heatedAudio.StopAudio(); _heatedRoutine = null; } } }
/// <summary> /// Display menu. /// </summary> /// <returns>IEnumerator</returns> public IEnumerator DisplayMenu() { inMenu = true; GameManager.instance.paused = true; Time.timeScale = 0; audio.PlaySound(0); background.FadeIn(); sectionCover.FadeIn(); yield return(new WaitForSecondsRealtime(.5f)); mainSection.gameObject.SetActive(true); mainSection.DisplaySections(); sectionCover.FadeOut(2f); yield return(new WaitForSecondsRealtime(.1f)); menuNavegable.MakeNavegable(); currentSection = "MainSection"; _displayRoutine = null; }
/// <summary> /// Play Enemy hit particle. /// </summary> public void DisplayHitParticles() { int key = UnityEngine.Random.Range(0, (particles.Length - 1)); if (_audio != null) { _audio.PlaySound(); } if (particles[key] != null) { // particles[key].Play(); } }