/// <summary> /// патрулирует местность, При абнаружении цели гонится за ней /// </summary> private void PatrollAndAttack() { if (_fow.Target != null) { _isAngry = true; } if (_isAngry) { if (!_sound.SoundIsPlaying("DogAgro")) { _sound.Play("DogAgro"); } MoveToTarget(); if (_fow.Target == null) { if (keepFolowing) { StartCoroutine(KeepFolowing(1)); } } } else { if (!_sound.SoundIsPlaying("DogMove")) { _sound.Play("DogMove"); } Patrol(); } }
public void Smack() { if (RagdollSound) { RagdollSound.Play(); } }
private void LateUpdate() { if (_fow.Target != null) { _isAngry = true; } if (_isAngry) { if (!_sound.SoundIsPlaying("FlyingRobotAlarm")) { _sound.Play("FlyingRobotAlarm"); } LookAtTarget(); goToAttack = true; //GoToAttackPos(); Attack(); if (_fow.Target == null) { if (keppFolowing) { StartCoroutine(KeepFolowing(2)); } } } else { if (!_sound.SoundIsPlaying("FlyingRobotSearching")) { _sound.Play("FlyingRobotSearching"); } goToAttack = false; //Patrol(); } }
protected SoundComponent LoadAndPlay(string fileName, Vector3 Position, KBusAudio bus = null, float DelayTime = 0f, float Duration = -1f) { SoundComponent source = GetAudioSource3D(fileName); if (source == null) { return(null); } if (bus != null) { if (bus.Add(source) == false) { if (PushToPool != null) { PushToPool.Invoke(source.transform); } else { Destroy(source.transform.gameObject); } return(null); } else { // Please Add All CallbackFunction // Do dùng cái Pool nên sợ Add thê nhiều lần // if (_Sound.callback == null) // :: Todo // Ignore add to Pool of KAudioCompoenent source._Sound.callback = () => { bus.Remove(source); if (PushToPool != null) { PushToPool.Invoke(source.transform); } else { Destroy(source.transform.gameObject); } }; } } source.gameObject.transform.localPosition = Position; if (Duration > 0) { source.Play(DelayTime, Duration); } else { source.Play(DelayTime); } return(source); }
void OnGetDamage(int damage) { if (ShieldActive.Value == false) { scoreComponent.incrementTimer = 0f; CurrentHP -= (float)damage; sound.Play("HurtFx"); if (CurrentHP <= 0) { playerDead.Raise(this.gameObject); CurrentHP = _health.MaxHP; } } }
void OnGetDamage(int damage) { if (ShieldActive.Value == false) { scoreComponent.incrementTimer = 0f; CurrentHP -= damage; sound.Play("HurtFx"); if (CurrentHP <= 0) { Instantiate(PlayerDeathPrefab, transform.position, Quaternion.identity); playerDead.Raise(gameObject); CurrentHP = _health.MaxHP; } } }
public override void Update() { base.Update(); if (transform.position.y < -5) { Reset(); } if (charging) { if (!begunCharge) { begunCharge = true; soundChargeBall.Play(); } } else { begunCharge = false; soundChargeBall.Stop(); } if (Input.GetKeyDown(Input.Keys.F12)) { if (gameObject.Parent) { Debug.Log("Parent of ball is: " + gameObject.Parent + " of " + gameObject.Parent.Parent.Name); } else { Debug.Log("Ball is not parented to anything."); } } }
void PlayTheme(string themeName) { if (!_music.SoundIsPlaying(themeName)) { _music.Play(themeName); } }
IEnumerator OnGoalCoroutine(Team teamThatScored) { endroundSound.Play(); ChadHud.Instance.OnGoal(teamThatScored, 5.0f); Time.TimeScale = 0.5f; yield return(new WaitForSecondsRealtime(2.0f)); ReplaySystem.recordGame = false; yield return(new WaitForSecondsRealtime(3.0f)); Time.TimeScale = 1.0f; ReplaySystem.StartReplay(teamThatScored); yield return(new WaitForSecondsRealtime(ReplaySystem.durationInSeconds + 1.0f)); ReplaySystem.recordGame = true; if (GoldenGoal) { OnMatchEnd(); } else { OnRoundEnd(); OnRoundStart(); } }
// this function will be called upon powerup use / collision after trown public override void OnActivate() { //Make sure powerups can only be activated once! if (activated) { return; } activated = true; ChadControls otherChad = null; if (_LastCollider) { otherChad = _LastCollider.gameObject.GetComponent <ChadControls>(); } if (otherChad) { // rustle his jimmies Ragdoll.ImpactParams param = new Ragdoll.ImpactParams(gameObject.transform.position, Vector3.Zero, 0.0f); param.bodyPartFactor[(int)Ragdoll.BODYPART.SPINE] = 0.88f; param.bodyPartFactor[(int)Ragdoll.BODYPART.RIGHT_LOWER_LEG] = 10.0f; param.bodyPartFactor[(int)Ragdoll.BODYPART.LEFT_LOWER_LEG] = 5.0f; param.bodyPartFactor[(int)Ragdoll.BODYPART.HEAD] = -2.0f; param.force = otherChad.transform.forward * otherChad.CurrentVelocity.y * 50.0f; otherChad.ActivateRagdoll(3.0f, param); SlipSound.Play(); } Explosion(); }
void OnCollisionEnter2D(Collision2D col) { sc.Play("Bounce"); if (col.gameObject.layer == 9) { Destroy(this.gameObject); } }
private void Collided(Entity other, Vector3 point) { if (other.Has <AircraftComponent>()) { Entity e = Entity.Instantiate(); e.Attach(new TransformComponent() { Position = point }); //e.Attach<GunBulletSmokeComponent>(); e.Attach(new LimitedLifeTimeComponent() { CountSpeed = 0.04f }); var soundComponent = new SoundComponent(BulletHitSound); soundComponent.VolumeFactor = 0.5f; e.Attach(soundComponent); soundComponent.Play(); var aircraft = other.Get <AircraftComponent>(); aircraft.Damage(Damage); if (this.ShootedByPlayer) { if (aircraft.Armor > 0) { Entity.SendMessage(Entity.Find("ui"), "notice", "Hit"); } else { Entity.SendMessage(Entity.Find("ui"), "notice", "Destroyed"); } } if (other.Name == "player") { Entity.SendMessage(Entity.Find("ui"), "notice", "Damaged"); } } else if (other.Has <GroundComponent>()) { Entity e = Entity.Instantiate(); e.Attach(new TransformComponent() { Position = point }); e.Attach <GunBulletSmokeComponent>(); e.Attach(new LimitedLifeTimeComponent() { CountSpeed = 0.04f }); var soundComponent = new SoundComponent(BulletHitSound); soundComponent.VolumeFactor = 0.5f; e.Attach(soundComponent); soundComponent.Play(); } Entity.Kill(this.Owner); }
void OnInteract(TriggerEventArgs e) { if (e.Sender.IsInteractble) { e.boolMeta = !e.boolMeta; _sound.Play("FX_Switch"); anim.SetBool("On", e.boolMeta); } }
public override void ChargeEffect() { base.ChargeEffect(); if (!hasPlayedChargeSound) { soundComponentChargeUp.Play(); hasPlayedChargeSound = true; soundcooldown = 5.0f; } }
public void Show(string message) { if (_canShow) { _sound.Play("FX_NotEnoughEnergy"); _message.text = message; anim.SetTrigger("Show"); _canShow = false; } }
protected override void OnCollisionEnter2D(Collision2D collision) { base.OnCollisionEnter2D(collision); if (collision.transform.CompareTag("Ground")) { _grounded = true; _GroundedSound.Play("FX_RobotGrounded"); Grounded?.Invoke(gameObject); } }
public override void Throw(Vector3 camPos, Vector3 direction) { RPCParticles(); SendRPC("RPCParticles"); direction.y += 0.2f; if (ThrowForce > ThrowForce66Procent) { soundFireThrow.Play(); } base.Throw(camPos, Vector3.Normalize(direction) * ThrowForce); }
virtual public void Throw(Vector3 camPos, Vector3 direction) { Vector3 pos = camPos; Drop(); transform.position = pos; transform.LookAt(transform.position + Vector3.Normalize(direction)); m_rigidBody.Position = transform.position; m_rigidBody.Rotation = transform.rotation; soundThrow.Play(); StartCoroutine(ThrowRoutine(direction)); OnThrow(); SendRPC("OnThrow"); }
/// <summary> /// This is main function /// </summary> /// <param name="fileName"></param> /// <param name="position"></param> /// <returns></returns> public SoundComponent PlayVoice(string fileName, Vector3 position) { SoundComponent source = GetAudioSource3D(fileName); if (source == null) { return(null); } source.gameObject.transform.localPosition = position; source.Play(); return(source); }
private void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("DurationBoolItem")) { var bonus = other.GetComponent <OnItem>().durationBoolItem; if (AvalaibleDurationItem.Find(item => item.name == bonus.name) == false) { AvalaibleDurationItem.Add(bonus); OnBonusChange.Raise(gameObject); sound.Play("ItemFx"); //BonusImages[BonusCount - 1].sprite = bonus.ItemIcon; } else { var ExistingBonus = AvalaibleDurationItem.Find(item => item.name == bonus.name); ExistingBonus._durationItemTimer = 0; sound.Play("ItemFx"); } if (bonus.ActivateBoolBonus[PlayerID].Value == false) { bonus._durationItemTimer = 0; bonus.Activate(bonus.ActivateBoolBonus[PlayerID]); sound.Play("ItemFx"); } Destroy(other.gameObject); } if (other.CompareTag("UntilDeathBoolItem")) { var bonus = other.GetComponent <OnItem>().untilDeathBool; if (AvalaibleUntilDeathItem.Find(item => item.name == bonus.name) == false) { AvalaibleUntilDeathItem.Add(bonus); OnBonusChange.Raise(gameObject); sound.Play("ItemFx"); //BonusImages[BonusCount - 1].sprite = bonus.ItemIcon; } bonus.Activate(bonus.ActivateBoolBonus[PlayerID]); Destroy(other.gameObject); } if (other.CompareTag("SpecialEffectItem")) { var bonus = other.GetComponent <OnItem>().specialEffectItem; bonus.GetList(); bonus.SpecialBonusEffect(this.transform); sound.Play("Inversion"); Destroy(other.gameObject); } if (other.CompareTag("InstantItem")) { var bonus = other.GetComponent <OnItem>().instantFloatItem; bonus.ActivateFloat(PlayerID); sound.Play("Points"); Destroy(other.gameObject); } }
public override void Start() { ExplosionSound = gameObject.AddComponent <SoundComponent>(); ExplosionSound.Type = SoundComponent.SoundType.Effect; ExplosionSound.Clip = Sound; ExplosionSound.Looping = true; ExplosionSound.Is3D = true; ExplosionSound.Volume = 0.5f; // 3D options ExplosionSound.MaxDistance = 100; ExplosionSound.MinDistance = 3; ExplosionSound.SpreadAngle = 0; ExplosionSound.Play(); }
private void Explosion() { // Play the vindaloo explosion sound ExplosionSound.Play(); emitterFire.EmitOneShot(35); emitterGravel.EmitOneShot(20); emitterSmoke.Emit = false; emitterSmoke.EmitOneShot(50); StartCoroutine(RemoveNextFrame()); _DespawnTimer = 0.0f; //Remove(); }
IEnumerator PlaySoundCoroutine(AudioClip clip, float startWait, float endWait) { playing = true; yield return(new WaitForSeconds(startWait)); MasterSound.Clip = clip; MasterSound.Play(); while (MasterSound.IsPlaying()) { yield return(null); } yield return(new WaitForSeconds(endWait)); playing = false; }
IEnumerator RoundStartCountdown(float duration) { ResetPlayers(); Ball.GetComponent <Ball>().Reset(); PowerupManager.ResetPowerups(); LocalChad.Locked = true; countdownSound.Play(); ChadHud.Instance.StartCountdown(duration); yield return(new WaitForSecondsRealtime(duration)); LocalChad.Locked = false; CameraMaster.instance.EnableSwitchTeam(); hasScored = false; }
public SoundComponent Play(string fileName, string soundFile, Vector3 position, bool isLoop = false, float DelayTime = 0f) { SoundComponent source = GetAudioSource3D(fileName); if (source == null) { return(null); } source.gameObject.transform.position = position; source.gameObject.transform.localPosition = Vector3.zero; source._Sound.DelayTime = DelayTime; source.Play(); return(source); }
private void Explosion() { //hide the train. StopAllCoroutines(); gameObject.transform.scale = Vector3.One; soundComponentTravel.Stop(); emitterThomasFace.EmitOneShot(1); emitterFire.EmitOneShot(40); emitterSpark.Emit = false; emitterSpark.EmitOneShot(200); soundComponentExplosion.Play(); StartCoroutine(KillTrain()); _DespawnTimer = 0.0f; }
public SoundComponent Play3D(string fileName, string soundFile, Transform transf, bool isLoop = false) { SoundComponent source = GetAudioSource3D(fileName); if (source == null) { return(null); } if (transf != null) { source.gameObject.transform.localPosition = transf.position; source.gameObject.transform.localRotation = transf.rotation; } else { source.gameObject.transform.localPosition = Vector3.zero; } source.Play(); return(source); }
public void Move(float move, bool crouch, bool jump, bool dash, float dashX, float dashY) { // If crouching, check to see if the character can stand up if (!crouch) { // If the character has a ceiling preventing them from standing up, keep them crouching if (Physics2D.OverlapCircle(m_CeilingCheck.position, k_CeilingRadius, m_WhatIsGround)) { crouch = true; } } //only control the player if grounded or airControl is turned on if (m_Grounded || m_AirControl) { // If crouching if (crouch) { if (!m_wasCrouching) { m_wasCrouching = true; OnCrouchEvent.Invoke(true); } // Reduce the speed by the crouchSpeed multiplier move *= m_CrouchSpeed; // Disable one of the colliders when crouching if (m_CrouchDisableCollider != null) { m_CrouchDisableCollider.enabled = false; } } else { // Enable the collider when not crouching if (m_CrouchDisableCollider != null) { m_CrouchDisableCollider.enabled = true; } if (m_wasCrouching) { m_wasCrouching = false; OnCrouchEvent.Invoke(false); } } // Move the character by finding the target velocity Vector3 targetVelocity = new Vector2(InvertHorizontalAxis.Value * move * 10f, m_Rigidbody2D.velocity.y); // And then smoothing it out and applying it to the character m_Rigidbody2D.velocity = Vector3.SmoothDamp(m_Rigidbody2D.velocity, targetVelocity, ref m_Velocity, m_MovementSmoothing); // // If the input is moving the player right and the player is facing left... // if (move > 0 && !m_FacingRight) // { // // ... flip the player. // Flip(); // } // // Otherwise if the input is moving the player left and the player is facing right... // else if (move < 0 && m_FacingRight) // { // // ... flip the player. // Flip(); // } } if (WallJumpActiveReference.Value) { if (!m_Grounded && isTouchingWall && jump || !m_Grounded && isTouchingWall && jump) { if (lastWall == wall) { Debug.Log("Meme mur bitch" + lastWall.name); } if (lastWall == null && wall == null) { Debug.Log("Murs sont null"); } Debug.Log("Wall " + wall + " lastWall " + lastWall); if (wall != null && wall != lastWall || wall != null && lastWall == null) { canDash = true; if (wall.position.x < transform.position.x) { //Debug.Log("Le mur est a gauche"); m_Rigidbody2D.velocity = Vector2.zero; Vector2 dir = Vector2.right + Vector2.up; dir.Normalize(); m_Rigidbody2D.AddForce(dir * m_JumpForce); isTouchingWall = false; sound.Play("JumpFx"); lastWall = wall; } else { m_Rigidbody2D.velocity = Vector2.zero; Vector2 dir = Vector2.left + Vector2.up; dir.Normalize(); m_Rigidbody2D.AddForce(dir * m_JumpForce); isTouchingWall = false; sound.Play("JumpFx"); lastWall = wall; } } } } if (jump && dash) { if (m_Grounded && DoubleJumpReference.Value == false) { sound.Play("JumpFx"); // Add a vertical force to the player. m_Grounded = false; m_Rigidbody2D.velocity = Vector2.zero; m_Rigidbody2D.AddForce(new Vector2(0f, m_JumpForce)); } if (!m_Grounded && DoubleJumpReference.Value && canDoubleJump) { Debug.Log("DoubleJump"); sound.Play("JumpFx"); m_Grounded = false; canDoubleJump = false; m_Rigidbody2D.velocity = Vector2.zero; m_Rigidbody2D.AddForce(new Vector2(0f, m_JumpForce * 0.75f)); } } if (m_Grounded && jump && DoubleJumpReference.Value == false && !dash) { Debug.Log("Jump"); sound.Play("JumpFx"); // Add a vertical force to the player. m_Grounded = false; m_Rigidbody2D.velocity = Vector2.zero; m_Rigidbody2D.AddForce(new Vector2(0f, m_JumpForce)); } if (DoubleJumpReference.Value && !dash) { if (!m_Grounded && jump && canDoubleJump) { Debug.Log("DoubleJump"); sound.Play("JumpFx"); m_Grounded = false; canDoubleJump = false; m_Rigidbody2D.velocity = Vector2.zero; m_Rigidbody2D.AddForce(new Vector2(0f, m_JumpForce)); } if (m_Grounded && jump) { Debug.Log("Jump"); sound.Play("JumpFx"); m_Rigidbody2D.velocity = Vector2.zero; m_Rigidbody2D.AddForce(new Vector2(0f, m_JumpForce)); m_Grounded = false; } } if (!jump && canDash && dash && DashActiveReference.Value) { Debug.Log("Dash"); sound.Play("DashFx"); m_Rigidbody2D.velocity = Vector2.zero; Vector2 dashDir = new Vector2(dashX, dashY); dashDir.Normalize(); if (dashDir == Vector2.zero) { dashDir = Vector2.up; } m_Rigidbody2D.AddForce(InvertHorizontalAxis.Value * dashDir * DashForce.Value, ForceMode2D.Force); canDash = false; } }
private void UpdateState() { switch (State) { case CAM_STATE.MAIN_MENU: TurnOnLights(); if (!MenuSound.IsPlaying()) { MenuSound.Play(); } MainMenu.SetUpScene(); Camera.fixedAspectRatio = true; Camera.orthographic = true; MainMenu.Canvas.isRendering = true; break; case CAM_STATE.JOIN_HOST: TurnOnLights(); if (!MenuSound.IsPlaying()) { MenuSound.Play(); } MainMenu.SetUpScene(); Camera.fixedAspectRatio = true; Camera.orthographic = true; JoinHost.Canvas.isRendering = true; break; case CAM_STATE.SELECT_TEAM: TurnOnLights(); if (!MenuSound.IsPlaying()) { MenuSound.Play(); } SelectTeam.SetUpScene(); SelectTeam.Canvas.isRendering = true; Camera.fixedAspectRatio = false; Camera.orthographic = false; break; case CAM_STATE.GAME: if (MenuSound.IsPlaying()) { MenuSound.Stop(); } TurnOffLights(); Hud.Canvas.isRendering = true; if (GUIScoreboard.Instance) { GUIScoreboard.Instance.enabled = true; } break; case CAM_STATE.EXIT_MENU: TurnOffLights(); ExitMenu.Canvas.isRendering = true; break; case CAM_STATE.HOST_MENU: if (!MenuSound.IsPlaying()) { MenuSound.Play(); } TurnOnLights(); HostMenu.SetUpScene(); Camera.fixedAspectRatio = false; Camera.orthographic = false; HostMenu.Canvas.isRendering = true; break; case CAM_STATE.OPTIONS_MENU: OptionsMenu.Canvas.isRendering = true; break; case CAM_STATE.LOADING_SCREEN: TurnOffLights(); LoadingScreen.Canvas.isRendering = true; break; case CAM_STATE.SCORE_SCREEN: if (GUIScoreScreen.Instance) { GUIScoreScreen.Instance.enabled = true; GUIScoreScreen.Instance.Canvas.isRendering = true; } break; } }
public override void OnThrow() { soundComponentTravel.Play(); emitterSpark.Emit = true; }