public void Attack(InputAction.CallbackContext context) { if (context.ReadValueAsButton()) { if (canAttack == true && currentUses > 0) { AudioSingleton.PlaySFX(SoundEffect.SpraySalt); this.gameObject.GetComponentInChildren <Animator>().SetTrigger("Attack"); StartCoroutine("AttackTimeFrame"); StartCoroutine("AttackCooldown"); currentUses--; if (currentUses == 2) { saltThree.SetActive(false); } else if (currentUses == 1) { saltTwo.SetActive(false); } else { saltOne.SetActive(false); } } } }
public void StateStart() { eventsListener.OnRoarEnd += OnRoarEnd; timeLeftToRoar = 0; animator.SetState(PigmanAnimatorState.Roar); AudioSingleton.PlaySound(AudioSingleton.Instance.clips.roar); }
private void OnTriggerEnter2D(Collider2D collision) { PlayerUnitController unit = InteractiveHelpers.GetPlayer(collision); PlayerBaseStats stats = unit.di.stats; PlayerRespawnHandler respawnHandler = unit.mainController.di.respawnHandler; bool playSound = false; foreach ((SlimeType type, bool acceptsType) in checkpointFor.GetPairEnumerable()) { if (acceptsType && stats.HasType(type)) { bool updated = respawnHandler.SetCheckpoint(type, this); if (updated) { playSound = true; } if (!segmentMember.Segment) { segmentMember.Segment = unit.di.camera.CameraSegment; } } } if (playSound) { AudioSingleton.PlaySound(AudioSingleton.Instance.clips.checkpoint); } }
public override void ControlUpdate() { if (isAttacking) { return; } if (hasSword && input.sword.IsPressed()) { AudioSingleton.PlaySound(AudioSingleton.Instance.clips.swordSwing); input.sword.Use(); animator.PlayAttack(); isAttacking = true; OnIsAttackingChange(isAttacking); isGuarding = false; OnIsGuardingChange(isGuarding); } else { bool currentlyIsGuarding = hasShield && input.shield.IsHeld(); if (currentlyIsGuarding != isGuarding) { isGuarding = currentlyIsGuarding; OnIsGuardingChange(isGuarding); } } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.GetComponent <PlayerPathMover>() != null && canKill == true) { Debug.Log("Collided With Player"); AudioSingleton.PlaySFX(SoundEffect.LifeLost); if (PlayerLives.Lives > 1) { Score.score -= 30; StartCoroutine(DownPlayer(collision.gameObject)); //SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); } else { PlayerLives.Lives = 3; SceneManager.LoadScene(10); AudioSingleton.PlayBGM(BackgroundMusic.MainMenu); } } if (collision.GetComponent <Ingredients>()) { if (collision.GetComponent <Ingredients>().GetFalling() == true && canDie == true) { AudioSingleton.PlaySFX(SoundEffect.EnemySquished); Score.score += 20; Down(); } } }
public void StartParry() { OnAttackInterrupt(); animator.SetState(PigmanAnimatorState.Parry); phase = PigmanAttackPhase.Parry; parryTimeLeft = RandomRange.FromVector(data.parryTime); AudioSingleton.PlaySound(AudioSingleton.Instance.clips.parry); }
public void ShowSettings() { AudioSingleton.PlaySFX(SoundEffect.CloseCredits); titlePanel.SetActive(false); settingsPanel.SetActive(true); titleAnimator.SetTrigger("MinimizeTitle"); controlEventSystem.SetSelectedGameObject(settingsDefaultFocus); }
public void StartState() { vulnerability.SetInvulnerable(); yeetTimeLeft = yeetTime; unmergeTimeLeft = unmergeTime; physics.velocity.bounciness = yeetedBounciness; AudioSingleton.PlaySound(AudioSingleton.Instance.clips.yeet); }
private void AdjustSFX(float value) { AudioSingleton.SFXVolume = value; if (Time.time - lastSFXTime > 1f) { lastSFXTime = Time.time; AudioSingleton.PlaySFX(testEffect); } }
public void StartState() { physics.force.SetForce(value: pushForce, duration: paralyzeDuration, curve: hitForceCurve.Evaluate); AudioSingleton.PlaySound(AudioSingleton.Instance.clips.playerHit); if (vulnerability.IsVulnerable()) { vulnerability.SetInvulnerable(invulnerableTime); } }
public void ShowCredits() { AudioSingleton.PlaySFX(SoundEffect.OpenCredits); creditsPanel.SetActive(true); titlePanel.SetActive(false); titleAnimator.SetTrigger("MinimizeTitle"); creditsScroll.StartScrolling(); controlEventSystem.SetSelectedGameObject(creditsDefaultFocus); }
void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); }
public void ShowTitle() { titlePanel.SetActive(true); AudioSingleton.PlaySFX(SoundEffect.CloseCredits); instructionsPanel.SetActive(false); creditsPanel.SetActive(false); settingsPanel.SetActive(false); titleAnimator.SetTrigger("MaximizeTitle"); creditsScroll.StopScrolling(); controlEventSystem.SetSelectedGameObject(titleDefaultFocus); }
private void Awake() { if (_instance != null && _instance != this) { Destroy(this.gameObject); } else { _instance = this; } }
void Awake() { if (i == null) { i = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } }
private void StartStage(string stageName) { inGame = true; IsPaused = false; SceneManager.LoadScene(stageName); AudioSingleton.PlayBGM(BackgroundMusic.Gameplay); pauseAnimator.SetBool("isPaused", false); titleAnimator.SetBool("isPaused", false); Time.timeScale = 1f; menuCanvas.GetComponent <GraphicRaycaster>().enabled = false; controlEventSystem.SetSelectedGameObject(null); }
private void OnTriggerExit2D(Collider2D collider) { PushBlock block = InteractiveHelpers.GetBlock(collider); if (block) { isPressed = false; spriteRenderer.enabled = true; pressEmitter.Emit(isPressed); //trigger.CallTriggerAction(isPressed); AudioSingleton.PlaySound(AudioSingleton.Instance.clips.button); } }
private void PerformDoubleJump() { if (debug) { Debug.Log("[PlayerJumpAbility] PerformDoubleJump"); } //sound.PlayJump(); //jumpParticles.Play(); AudioSingleton.PlaySound(AudioSingleton.Instance.clips.jump); physics.velocity.Y = DoubleJumpVelocity; jumpInProgress = true; doubleJumped = true; }
public void PerformJump(Direction2H wallSlideDirection, float moveInput) { if (debug) { Debug.Log("[PlayerWallSlideJump] PerformJump"); } Vector2 jumpNormalVelocity = GetJumpNormalVelocity(wallSlideDirection, moveInput); Vector2 jumpVelocity = JumpWorldVelocity(jumpNormalVelocity); AudioSingleton.PlaySound(AudioSingleton.Instance.clips.jump); physics.velocity.Value = jumpVelocity; }
// Update is called once per frame void Update() { if (currentConveyor != null) { isFalling = false; MoveOnConveyer(); } //If object is moving below map, then remove it else if (transform.position.y < -7) { AudioSingleton.PlaySFX(SoundEffect.GarbageBin); Destroy(this.gameObject); } }
private void PerformJump() { if (debug) { Debug.Log("[PlayerJumpAbility] PerformJump"); } // sound.PlayJump(); // jumpParticles.Play(); AudioSingleton.PlaySound(AudioSingleton.Instance.clips.jump); physics.velocity.Y = MaxJumpVelocity; coyoteJumpTimeLeft = 0; jumpInProgress = true; physics.IsGrounded = false; input.jump.Use(); }
private void Start() { if (instance == null) { instance = this; source = this.GetComponent <AudioSource>(); source.Play(); } else { Destroy(this.gameObject); } DontDestroyOnLoad(this); }
public void Fall() { if (storedPlayer != null) { InteractedWith?.Invoke(); storedPlayer.gameObject.GetComponent <Animator>().SetTrigger("Push"); } StartCoroutine(ToggleCollider(notTriggerCollider)); currentConveyor = null; isFalling = true; this.GetComponent <Rigidbody2D>().gravityScale = gravityScale; nextPosition = new Vector2(0, this.transform.position.y - distanceBetweenConveyers); AudioSingleton.PlaySFX(SoundEffect.DropIngredient); }
private void RemovePressingUnit(PlayerUnitController unit) { pressing.Remove(unit); if (pressing.Count == 0 && needsConstantWeight) { AudioSingleton.PlaySound(AudioSingleton.Instance.clips.button); isPressed = false; spriteRenderer.enabled = true; //trigger.CallTriggerAction(isPressed); pressEmitter.Emit(isPressed); } if (unit.di.stats.OnChange != null) { unit.di.stats.OnChange -= OnPressingAssemblyStatsChange; } }
private void CheckIngredient(Ingredients ingredient) { bool ingredientFound = false; //This is used when multiple ingredients are added at the same time. When one completes the order, the others must be bad ingredients, and so deduct points if (ingredientsNeeded.Count == 0) { Debug.Log("-10 Points"); } else { foreach (string x in ingredientsNeeded) { if (ingredient.GetName() == x) { ingredientFound = true; } } if (ingredientFound == true) { int ingredientIndex = ingredientsNeeded.IndexOf(ingredient.GetName()); ingredientsNeeded.Remove(ingredient.GetName()); Color opaque = new Color(0, 230, 0, 1); ingredientCheckBoxes[ingredientIndex].GetComponent <SpriteRenderer>().color = opaque; ingredientCheckBoxes.Remove(ingredientCheckBoxes[ingredientIndex]); orderManager.AddPoints(10); if (ingredientsNeeded.Count == 0) { orderManager.AddPoints(20); AudioSingleton.PlaySFX(SoundEffect.OrderComplete); orderManager.SpawnNewOrder(this.transform.position); Destroy(this.gameObject); } else { AudioSingleton.PlaySFX(SoundEffect.CorrectIngredient); } } else { orderManager.SubtractPoints(10); AudioSingleton.PlaySFX(SoundEffect.WrongIngredient); } } }
// Use this for initialization void Awake() { if(Instance == null) { //If I am the first instance, make me the Singleton Instance = this; DontDestroyOnLoad(this); } else { //If a Singleton already exists and you find //another reference in scene, destroy it! if(this != Instance) { Destroy(this.gameObject); } } }
public void OnSlimeMerge(SlimeType typeToMerge) { if (typeToMerge == SlimeType.King) { throw new Exception("Cannot merge slime type king"); } if (assemblySelectable.IsActive) { if (assemblySelectable.Stats.HasType(typeToMerge)) { // double collision call (controller & otherController) return; } PlayerUnitSelectable selectableToMerge = selectables.Get(typeToMerge); bool selectAssembly = selectableToMerge.IsSelected; selectableToMerge.SetInactiveAndDeselect(); assemblySelectable.MergeInside(typeToMerge); assemblySelectable.SetActive(); if (selectAssembly) { assemblySelectable.Select(); } } else { PlayerUnitSelectable selectableToMerge = selectables.Get(typeToMerge); bool selectAssembly = selectableToMerge.IsSelected; selectableToMerge.SetInactiveAndDeselect(); PlayerUnitSelectable kingSelectable = selectables.Get(SlimeType.King); selectAssembly = selectAssembly || kingSelectable.IsSelected; kingSelectable.SetInactiveAndDeselect(); assemblySelectable.MergeInside(typeToMerge); assemblySelectable.SetActive(); if (selectAssembly) { assemblySelectable.Select(); } } AudioSingleton.PlaySound(AudioSingleton.Instance.clips.merge); OnMergeChange(); }
private void OnTriggerEnter2D(Collider2D collision) { PlayerUnitController unit = InteractiveHelpers.GetPlayer(collision); if (unit && interactionPredicate.CanInteract(unit)) { if (!isPressed) { isPressed = true; //trigger.CallTriggerAction(isPressed); pressEmitter.Emit(isPressed); AudioSingleton.PlaySound(AudioSingleton.Instance.clips.button); } pressing.Add(unit); spriteRenderer.enabled = false; if (unit.di.stats.OnChange != null) { unit.di.stats.OnChange += OnPressingAssemblyStatsChange; } } }
public void SpawnNewOrder(Vector3 orderLocation) { ordersCompleted++; if (ordersCompleted >= ordersNeeded) { AudioSingleton.PlaySFX(SoundEffect.LevelComplete); if (SceneManager.GetActiveScene().buildIndex != 3) { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); } else { SceneManager.LoadScene(4); } } ordersRemainingText.text = (ordersNeeded - ordersCompleted).ToString(); //Won't spawn a new order if completing all the ones on screen is enough to finish the level Debug.Log("Orders Needed: " + ordersNeeded); Debug.Log("Orders completed: " + ordersCompleted); Debug.Log("Orders On Screen: " + ordersOnScreen); StartCoroutine(WaitToSpawn(orderLocation)); }
private void Update() { if (detect.HasAnyPlayer()) { if (!hasPuffed) { hasPuffed = true; puffTimeLeft = physics.puffDelay; AudioSingleton.PlaySound(AudioSingleton.Instance.clips.puff); animator.SetState(SnailAnimatorState.Puff); } } else if (puffTimeLeft > 0) { puffTimeLeft -= Time.deltaTime; } else { hasPuffed = false; animator.SetState(SnailAnimatorState.Walk); } }
private void Start() { AudioSingleton.PlayBGM(BackgroundMusic.MainMenu); }
public void OnEnable() { _instance = this; LoadPrefs(); }