void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.GetComponent <StageObject> () != null && (other.gameObject.GetComponent <StageObject> ().ID == (int)IDList.ID.Box || other.gameObject.GetComponent <StageObject> ().ID == (int)IDList.ID.Gate)) { if (shooted) { if (other.gameObject.GetComponent <StageObject> ().ID == (int)IDList.ID.Box) { if (other.gameObject.GetComponent <Box> ().isMetallic) { _sfxManager.PlaySFX(metalBoxDestroyed, metalBoxDestroyedVolume); } else { _sfxManager.PlaySFX(boxDestroyed, boxDestroyedVolume); } other.gameObject.GetComponent <Box> ().DropItems(); } else if (other.gameObject.GetComponent <StageObject> ().ID == (int)IDList.ID.Gate) { _sfxManager.PlaySFX(gateDestroyed, gateDestroyedVolume); } GameObject.Destroy(other.gameObject, time); shooted = false; } } }
public void PutMask(GameObject mask) { _sfxManager.PlaySFX(MaskPlaceClip, MaskPlaceVolume); _currentMask = mask; mask.GetComponent <Collider2D> ().enabled = false; mask.transform.position = new Vector3(this.transform.position.x + XMaskOffset, this.transform.position.y + YMaskOffset, this.transform.position.z); }
private void FixedUpdate() { m_Grounded = false; // The player is grounded if a circlecast to the groundcheck position hits anything designated as ground // This can be done using layers instead but Sample Assets will not overwrite your project settings. Collider2D[] colliders = Physics2D.OverlapCircleAll(m_GroundCheck.position, k_GroundedRadius, _whatIsGround); for (int i = 0; i < colliders.Length; i++) { if (colliders [i].gameObject != gameObject) { m_Grounded = true; } } if (m_Grounded) { if (_lastGrounded == false) { _sfxManager.PlaySFX(LandingClip, LandingVolume); } _playerAnim.SetBool("Ground", true); } else { _playerAnim.SetBool("Ground", false); } _lastGrounded = m_Grounded; }
void OnCollisionEnter2D(Collision2D collider) { if (!collider.gameObject.CompareTag("Player")) { _sfxManager.PlaySFX(LandingClip, LandingVolume); } }
public static void PlayClip(params AudioClip[] clips) { if (__instance__ == null) { __instance__ = FindObjectOfType <SFXController>(); } if (SFXController.__instance__) { __instance__.PlaySFX(clips); } }
public void EnableMovement(bool value) { if (value) { _sfxManager.PlaySFX(EnemyEnabledClip, EnemyEnabledVolume); } else { _sfxManager.PlaySFX(EnemyDisabledClip, EnemyDisabledVolume); } _canMove = value; }
void Death() { _sfxManager.PlaySFX(DeathClip, DeathVolume); Time.timeScale = 0; _spriteRenderer.enabled = false; GameOverText.enabled = true; PlayerDead = true; }
private void OpeningGate() { if (_openRight) { if (transform.rotation.z < 0.705) { if (_isMoving == false && !_sfxManager.IsPlaying("gate")) { _sfxManager.PlaySFX(GateClip, GateVolume, "gate"); } transform.Rotate(Vector3.forward * _rotationSpeed * Time.deltaTime); _isMoving = true; } else { if (_isMoving == true && _sfxManager.IsPlaying("gate")) { _sfxManager.StopSound("gate"); } _open = false; _isMoving = false; } } else { if (transform.rotation.z > -0.705) { if (_isMoving == false && !_sfxManager.IsPlaying("gate")) { _sfxManager.PlaySFX(GateClip, GateVolume, "gate"); } transform.Rotate(Vector3.back * _rotationSpeed * Time.deltaTime); _isMoving = true; } else { if (_isMoving == true && _sfxManager.IsPlaying("gate")) { _sfxManager.StopSound("gate"); } _open = false; _isMoving = false; } } }
// Use this for initialization void Start() { _camera = Camera.main; _cameraTransform = this.gameObject.transform; _initialSize = _camera.orthographicSize; _sfxManager = GameObject.FindGameObjectWithTag("SFXManager").GetComponent <SFXController> (); _sfxManager.PlaySFX(StartLevelClip, StartLevelVolume); }
private void Pickup() { _pickedUp = true; _storedItem = _triggerObject.GetComponent <StageObject> ().Pickup(); if (_storedItem.GetComponent <StageObject> ().ID == (int)IDList.ID.Key) { _sfxManager.PlaySFX(KeyPickupClip, KeyPickupVolume); } else { _sfxManager.PlaySFX(PickupClip, PickupVolume); } InventoryIcon.enabled = true; InventoryIcon.sprite = _storedItem.GetComponent <SpriteRenderer> ().sprite; _storedItem.GetComponent <SpriteRenderer> ().enabled = true; _storedItem.transform.parent = this.transform.parent; _storedItem.SetActive(false); }
private void StageSwap() { _sfxManager.PlaySFX(SwitchClip, SwitchVolume); if (toggle) { _uiMask.sprite = HappyMask; _happyStage.SetActive(true); _sadStage.SetActive(false); } else { _uiMask.sprite = SadMask; _happyStage.SetActive(false); _sadStage.SetActive(true); } toggle = !toggle; }
public void StartClose() { _sfxManager.PlaySFX(EndLevelClip, EndLevelVolume); for (int i = 0; i < Interface.Length; i++) { Interface[i].SetActive(false); } _moving = true; _isShowing = true; _closing = true; _initialPosition = _cameraTransform.position; _destination = new Vector3(0, 0, -10); _startTime = Time.time; _journeyLenght = Vector3.Distance(_initialPosition, _destination); StartCoroutine(ChangeScene()); }
void Shoot() { if(_hasBall) { _sfxManager.PlaySFX (CannonClip, CannonVolume); GameObject clone = Instantiate (Bullet, _shootLocation, Quaternion.identity) as GameObject; Rigidbody2D cloneRB = clone.GetComponent<Rigidbody2D> (); SpriteRenderer cloneSR = clone.GetComponent <SpriteRenderer> (); cloneSR.sortingLayerName = "Interactive"; clone.transform.parent = this.gameObject.transform.parent; clone.GetComponent<CannonBall> ().shooted = true; cloneRB.AddRelativeForce (transform.TransformDirection (new Vector2( (Mathf.Cos (transform.rotation.z * Mathf.Deg2Rad) * BulletForce), (Mathf.Sin (transform.rotation.z * Mathf.Deg2Rad) * BulletForce) )), ForceMode2D.Impulse); _hasBall = false; } }
public override void Interact(ref GameObject other) { if (CanInteract(other)) { if (other.GetComponent <StageObject>().ID == (int)IDList.ID.Key) { InsertKey(); _player.RemoveItemFromInventory(); } else if (other.GetComponent <StageObject>().ID == (int)IDList.ID.Gear) { InsertGear(); if (_gears <= _maxGears) { _sfxManager.PlaySFX(InsertMechanismClip, InsertMechanismVolume); _player.RemoveItemFromInventory(); } } } }
public void PlayStep() { int RandomValue = UnityEngine.Random.Range(0, stepsList.Count); _sfxManager.PlaySFX(stepsList [RandomValue], StepsVolume); }