private void PlaySound(string soundName) { if (audioSystem != null) { audioSystem.Play(soundName); } }
public void SpawnQuestNotification() { var go = Instantiate(notificationPrefab, gameObject.transform); go.GetComponentInChildren <TMP_Text>().text = $"Задание \"{quests.lastCompletedQuestName} \" выполнено!"; audioSystem.Play("QuestCompleted"); }
/// <summary> /// Perform a reaction on a solution. This assumes all reaction criteria have already been checked and are met. /// </summary> /// <param name="solution">Solution to be reacted.</param> /// <param name="reaction">Reaction to occur.</param> /// <param name="unitReactions">The number of times to cause this reaction.</param> private void PerformReaction(ReactionPrototype reaction, int unitReactions) { //Remove non-catalysts foreach (var reactant in reaction.Reactants) { if (!reactant.Value.Catalyst) { int amountToRemove = unitReactions * reactant.Value.Amount; TryRemoveReagent(reactant.Key, amountToRemove); } } //Add products foreach (var product in reaction.Products) { TryAddReagent(product.Key, (int)(unitReactions * product.Value), out int acceptedQuantity, true); } //Trigger reaction effects foreach (var effect in reaction.Effects) { effect.React(Owner, unitReactions); } //Play reaction sound client-side _audioSystem.Play("/Audio/effects/chemistry/bubbles.ogg", Owner.Transform.GridPosition); }
public void Play(ScheduledSound schedule) { if (!schedule.Play) { return; } Timer.Spawn((int)schedule.Delay + (_random.Next((int)schedule.RandomDelay)), () => { if (!schedule.Play) { return; // We make sure this hasn't changed. } if (_audioSystem == null) { _audioSystem = IoCManager.Resolve <IEntitySystemManager>().GetEntitySystem <AudioSystem>(); } _audioSystem.Play(schedule.Filename, Owner, schedule.AudioParams); if (schedule.Times == 0) { _schedules.Remove(schedule); return; } if (schedule.Times > 0) { schedule.Times--; } Play(schedule); }); }
protected void OnDamageTaken(int Health) { if (Health == CurrentHealth) { return; } if (Health < CurrentHealth) { AudioSystem.Play(HurtSound); if (AbilitySystem.HasActiveTag(TypeTag.Poison)) { StartCoroutine(PlayEffect(PoisonedEffect)); } else { StartCoroutine(PlayEffect(DamageEffect)); } } if (Health <= 0) { IsAlive = false; Grid.setOccupied((Vector3Int)GridPos, false); Animator.SetBool("Death", true); AudioSystem.Play(DeathSound); StartCoroutine(PlayEffect(DeathEffect)); } CurrentHealth = Health; }
public void Play(ScheduledSound schedule) { if (!schedule.Play) { return; } Timer.Spawn((int)schedule.Delay + (_random.Next((int)schedule.RandomDelay)), () => { if (!schedule.Play) { return; // We make sure this hasn't changed. } if (_audioSystem == null) { _audioSystem = EntitySystem.Get <AudioSystem>(); } _audioStreams.Add(schedule, _audioSystem.Play(schedule.Filename, Owner, schedule.AudioParams)); if (schedule.Times == 0) { return; } if (schedule.Times > 0) { schedule.Times--; } Play(schedule); }); }
private void Update() { if (Input.GetKeyDown(KeyCode.Space)) { AudioSystem.Play("Test"); } }
private void Awake() { instance = this; GameData.OnDataChanged += UpdateHud; pauseBtn.onClick.AddListener((() => { Main.PauseGame(); AudioSystem.Play(AudioLabel.Click); })); }
public void Cycle() { _currentTool = (_currentTool + 1) % _tools.Count; SetTool(); var current = _tools[_currentTool]; if (!string.IsNullOrEmpty(current.ChangeSound)) { _audioSystem.Play(current.ChangeSound, Owner); } }
private IEnumerator TPAudioPoolRepeatPlaying(int repeat) { while (repeat >= 0) { AudioSystem.Play("MyBundle", "Door", () => { ExampleHelper.MessageWithLines("TPAudioPool Sound 'Door' was played by MyBundle"); }); repeat--; yield return(ExampleHelper.WaitSecond); } }
IEnumerator TypeSentence(string sentence) { audioSystem.Play("Typing"); sentence = sentence.Replace("{PlayerName}", PlayerPrefs.GetString("PlayerName", "Лицеист")); text.text = ""; foreach (var letter in sentence) { text.text += letter; yield return(null); } }
private void Update() { if (!Visibility || !_canClose) { return; } if (Input.GetMouseButtonUp(0)) { AudioSystem.Play(AudioLabel.Click); Main.ResumeGame(); return; } }
private void OnLevelWin(int inScore) { AudioSystem.Play(AudioLabel.LevelWin); _gameState.Pause(); _timeCounter.Stop(); var bonus = Mathf.RoundToInt(_timeCounter.TimeRatio * Settings.timeBonus); gameData.Score = bonus + inScore; StateManager.UpdateGameState( gameData.Score > gameData.Leaderboards.lastRankScore ? States.Winning : States.Menu ); }
protected IEnumerator ApplyEffectVisualized(AbilitySystem Owner, AbilitySystem Target) { RotateThowaradsTarget(Owner); Owner.OwnerAgent.Animator.SetInteger("AbilityIndex", AbilityIndex); Owner.OwnerAgent.Animator.SetTrigger("Ability"); yield return(new WaitForSeconds(MomentOfExecution)); AudioSystem.Play(SoundEffect); yield return(PlayParticleSystemFromSelfToTarget(Owner)); Debug.Log("PlayParticleSystemFromSelfToTarget1"); if (Target != null) { ApplyEffectToTarget(Owner, Target); } }
public bool AttackBy(AttackByEventArgs eventArgs) { if (!eventArgs.AttackWith.HasComponent <WrenchComponent>()) { return(false); } if (!Owner.TryGetComponent(out PhysicsComponent physics)) { return(false); } physics.Anchored = !physics.Anchored; _audioSystem.Play("/Audio/items/ratchet.ogg", Owner); return(true); }
public static void StartNewGame() { AudioSystem.Play(AudioLabel.NewGame); StateManager.UpdateGameState(States.Game); _instance._timeCounter.Stop(); _instance._timeCounter.Start(Settings.levelTime); if (_instance._isFirstRun) { _instance.FirstStart(); _instance._isFirstRun = false; return; } _instance._isRun = true; _instance._gameState.NewGame(); }
private void PlayFootstepSound(GridCoordinates coordinates) { // Step one: figure out sound collection prototype. var grid = coordinates.Grid; var tile = grid.GetTile(coordinates); // If the coordinates have a catwalk, it's always catwalk. string soundCollectionName; var catwalk = false; foreach (var maybeCatwalk in grid.GetSnapGridCell(tile.GridTile, SnapGridOffset.Center)) { if (maybeCatwalk.Owner.HasComponent <CatwalkComponent>()) { catwalk = true; break; } } if (catwalk) { // Catwalk overrides tile sound.s soundCollectionName = "footstep_catwalk"; } else { // Walking on a tile. var def = (ContentTileDefinition)tile.TileDef; if (def.FootstepSounds == null) { // Nothing to play, oh well. return; } soundCollectionName = def.FootstepSounds; } // Ok well we know the position of the var soundCollection = _prototypeManager.Index <SoundCollectionPrototype>(soundCollectionName); var file = _footstepRandom.Pick(soundCollection.PickFiles); _audioSystem.Play(file, coordinates); }
public void TakeDamage(int damage) { if (quests.restCharges == 0) { damage = 0; } currentHp -= damage; // if (gameObject.CompareTag("Stress")) // { // var stress = gameObject.GetComponent<StressEnemy>(); // StartCoroutine(stress.StopMovingForSeconds(shaking._time)); // } shaking.Begin(); Debug.Log(currentHp); audioSystem.Play("HitEnemy"); }
public Sound PlaySound(string soundFile, string polyphonicGroup = null, float pan = 0, int polyphonicMinInterval = 50, float pitch = 1, float priority = 0.5f, float volume = 1.0f, bool looped = false) { if (polyphonicGroup != null) { DateTime value; var now = DateTime.Now; if (effectTimestamps.TryGetValue(polyphonicGroup, out value) && (now - value).Milliseconds < polyphonicMinInterval) { return(new Sound()); } effectTimestamps[polyphonicGroup] = now; } var path = soundFile; var sound = AudioSystem.Play("Audio/Sounds/" + path, AudioChannelGroup.Effects, looped, priority, 0, false, volume, pan); if (pitch != 1) { sound.Pitch = pitch; } return(sound); }
IEnumerator EffectVisualized(AbilitySystem Owner, AbilitySystem Target) { RotateThowaradsTarget(Owner); Owner.OwnerAgent.Animator.SetInteger("AbilityIndex", AbilityIndex); Owner.OwnerAgent.Animator.SetTrigger("Ability"); yield return(new WaitForSeconds(MomentOfExecution)); AudioSystem.Play(SoundEffect); float time = 0; Vector3 OriginalPos = Owner.OwnerAgent.transform.position; Vector3 NewPos = Grid.CellToWorld((Vector3Int)Owner.CurrentTarget); GameObject projectile = null; RenderLayer RL = null; if (Projectile != null) { projectile = Instantiate(Projectile, OriginalPos, Quaternion.identity); RL = projectile.GetComponent <RenderLayer>();; } while (time < ProjectileFlyTime) { time += Time.deltaTime; float heigt = Mathf.Lerp(0, ProjectileArcHeight, time / ProjectileFlyTime); if (projectile != null && RL != null) { projectile.transform.position = Vector3.Lerp(OriginalPos, NewPos, time / ProjectileFlyTime) + Vector3.forward * heigt; if (RL != null) { RL.Height = heigt; } } yield return(null); } CoroutineRunner.Instance.StartCoroutine(PlayParticleSystemOnTarget(Owner)); if (Target != null) { ApplyEffectToTarget(Owner, Target); } }
private void StartNewGame() { AudioSystem.Play(AudioLabel.Click); Main.StartNewGame(); }
//This is required. It's 'cook'. private void wzhzhzh() { if (!HasContents) { return; } _busy = true; // Convert storage into Dictionary of ingredients var solidsDict = new Dictionary <string, int>(); foreach (var item in _storage.ContainedEntities) { if (solidsDict.ContainsKey(item.Prototype.ID)) { solidsDict[item.Prototype.ID]++; } else { solidsDict.Add(item.Prototype.ID, 1); } } // Check recipes FoodRecipePrototype recipeToCook = null; foreach (var r in _recipeManager.Recipes) { if (!CanSatisfyRecipe(r, solidsDict)) { continue; } recipeToCook = r; } var goodMeal = (recipeToCook != null) && (_currentCookTimerTime == (uint)recipeToCook.CookTime) ? true : false; SetAppearance(MicrowaveVisualState.Cooking); _audioSystem.Play(_startCookingSound, Owner, AudioParams.Default); Timer.Spawn((int)(_currentCookTimerTime * _cookTimeMultiplier), () => { if (goodMeal) { SubtractContents(recipeToCook); } else { VaporizeReagents(); VaporizeSolids(); } var entityToSpawn = goodMeal ? recipeToCook.Result : _badRecipeName; _entityManager.SpawnEntity(entityToSpawn, Owner.Transform.GridPosition); _audioSystem.Play(_cookingCompleteSound, Owner, AudioParams.Default); SetAppearance(MicrowaveVisualState.Idle); _busy = false; UpdateUserInterface(); }); UpdateUserInterface(); }
bool TryProcessStep(ConstructionStep step, IEntity slapped) { switch (step) { case ConstructionStepMaterial matStep: if (!slapped.TryGetComponent(out StackComponent stack) || !MaterialStackValidFor(matStep, stack) || !stack.Use(matStep.Amount)) { return(false); } if (matStep.Material == MaterialType.Cable) { AudioSystem.Play("/Audio/items/zip.ogg", Transform.LocalPosition); } else { AudioSystem.Play("/Audio/items/deconstruct.ogg", Transform.LocalPosition); } return(true); case ConstructionStepTool toolStep: switch (toolStep.Tool) { case ToolType.Crowbar: if (slapped.HasComponent <CrowbarComponent>()) { AudioSystem.Play("/Audio/items/crowbar.ogg", Transform.LocalPosition); return(true); } return(false); case ToolType.Welder: if (slapped.TryGetComponent(out WelderComponent welder) && welder.TryUse(toolStep.Amount)) { if (random.NextDouble() > 0.5) { AudioSystem.Play("/Audio/items/welder.ogg", Transform.LocalPosition); } else { AudioSystem.Play("/Audio/items/welder2.ogg", Transform.LocalPosition); } return(true); } return(false); case ToolType.Wrench: if (slapped.HasComponent <WrenchComponent>()) { AudioSystem.Play("/Audio/items/ratchet.ogg", Transform.LocalPosition); return(true); } return(false); case ToolType.Screwdriver: if (slapped.HasComponent <ScrewdriverComponent>()) { if (random.NextDouble() > 0.5) { AudioSystem.Play("/Audio/items/screwdriver.ogg", Transform.LocalPosition); } else { AudioSystem.Play("/Audio/items/screwdriver2.ogg", Transform.LocalPosition); } return(true); } return(false); case ToolType.Wirecutters: if (slapped.HasComponent <WirecutterComponent>()) { AudioSystem.Play("/Audio/items/wirecutter.ogg", Transform.LocalPosition); return(true); } return(false); default: throw new NotImplementedException(); } default: throw new NotImplementedException(); } }
private void GoToLeaderBoardState() { AudioSystem.Play(AudioLabel.Click); StateManager.UpdateGameState(States.LeaderBoards); }
public void OnFootstep() { Debug.Log("Footstep"); AudioSystem.Play("Footstep"); }
public void Push(Vector2 force) { rb.AddForce(force, ForceMode2D.Impulse); AudioSystem.Play("Attack2"); }
private IEnumerator beforeStart() { AudioSystem.Play(Setter.setting.audioStart); SceneSystem.ChangeScene("BeforeStart"); yield return(new WaitForSeconds(2)); }
// ReSharper disable once InconsistentNaming // ReSharper disable once IdentifierTypo private void wzhzhzh() { if (!_hasContents) { return; } _busy = true; // Convert storage into Dictionary of ingredients var solidsDict = new Dictionary <string, int>(); foreach (var item in _storage.ContainedEntities) { if (solidsDict.ContainsKey(item.Prototype.ID)) { solidsDict[item.Prototype.ID]++; } else { solidsDict.Add(item.Prototype.ID, 1); } } var failState = MicrowaveSuccessState.RecipeFail; foreach (var id in solidsDict.Keys) { if (_recipeManager.SolidAppears(id)) { continue; } failState = MicrowaveSuccessState.UnwantedForeignObject; break; } // Check recipes FoodRecipePrototype recipeToCook = null; foreach (var r in _recipeManager.Recipes.Where(r => CanSatisfyRecipe(r, solidsDict) == MicrowaveSuccessState.RecipePass)) { recipeToCook = r; } var goodMeal = (recipeToCook != null) && (_currentCookTimerTime == (uint)recipeToCook.CookTime); SetAppearance(MicrowaveVisualState.Cooking); _audioSystem.Play(_startCookingSound, Owner, AudioParams.Default); Timer.Spawn((int)(_currentCookTimerTime * _cookTimeMultiplier), () => { if (_lostPower) { return; } if (failState == MicrowaveSuccessState.UnwantedForeignObject) { VaporizeReagents(); EjectSolids(); } else { if (goodMeal) { SubtractContents(recipeToCook); } else { VaporizeReagents(); VaporizeSolids(); } if (recipeToCook != null) { var entityToSpawn = goodMeal ? recipeToCook.Result : _badRecipeName; _entityManager.SpawnEntity(entityToSpawn, Owner.Transform.GridPosition); } } _audioSystem.Play(_cookingCompleteSound, Owner, AudioParams.Default.WithVolume(-1f)); SetAppearance(MicrowaveVisualState.Idle); _busy = false; _uiDirty = true; }); _lostPower = false; _uiDirty = true; }
private void OnGameOver() { AudioSystem.Play(AudioLabel.GameOver); StateManager.UpdateGameState(States.Menu); }