private void PlayAudio(PlayAudioEvent paei) { //Change the music type if (paei.musicType == MusicType.MENU) { music.Stream = musicList[0]; music.Play(); } if (paei.uiSoundsType == UISoundsType.CLICK) { //If the target is not the map it must be one of the blobs so we want to play the impactsplat sound soundEffects.Stream = soundEffectsList[1]; soundEffects.Play(); } if (paei.soundEffectType == SoundEffectType.HIT) { if (playerReference == null) { playerReference = GetNode <Node>("../RedBlob"); } soundEffects.Position = ((Node2D)playerReference).Position; //Check the target is not the map if (!paei.AudioTarget.IsInGroup("Map")) { //If the target is not the map it must be one of the blobs so we want to play the impactsplat sound soundEffects.Stream = soundEffectsList[0]; soundEffects.Play(); } } }
private void _on_BuildButton_pressed() { Index index = new Index((int)Position.x, (int)Position.y); if (turretIndexes.ContainsKey(index)) { int turrentCost = turretIndexes[index].GetCost(); Turret turret = turretIndexes[index]; if (player.GetSpendingMoney() >= turrentCost) { turret.Upgrade(); buildSound.Play(); player.Spend(turrentCost); } } else { if (player.GetSpendingMoney() >= 150) { buildSound.Play(); player.Spend(150); Turret turret = (Turret)TurretScene.Instance(); turret.Position = Position; mainNode.AddChild(turret); turretIndexes.Add(index, turret); } } Visible = false; buildButton.Disabled = false; }
public void OnMovingDownMenuReady() { musicPlayer.Play(); if (previousLevelResult == null) { previousLevelResult = new LevelResult(); previousLevelResult.waveNum = 1; } MovingDown movingDown = (MovingDown)FindNode("MovingDown", true, false); movingDown.OnLevelCompleted(previousLevelResult, this); }
private void Shoot() { Vector2 dir = new Vector2(); dir.x = Input.GetJoyAxis(0, 2); dir.y = Input.GetJoyAxis(0, 3); if (Ammo > 0f) { Bullet bullet = _bulletScene.Instance() as Bullet; GetNode("/root/World/BulletHolder").AddChild(bullet); bullet.Position = Position; // if (!IsInputModeController) // { bullet.LookAt(GetGlobalMousePosition()); bullet.Direction = Position.DirectionTo(GetGlobalMousePosition()); // } // else // { // bullet.LookAt(dir); // bullet.Direction = dir; // } _shootSound.Play(); Ammo--; } }
public override void _Ready() { MusicMenu = (AudioStreamPlayer2D)GetNode("MusicMenu"); MusicPlay = (AudioStreamPlayer2D)GetNode("MusicPlay"); MusicMenu.Play(); animOnOffMusic = (AnimatedSprite)GetNode("Menu/MusicOnOf"); StatusmusicOn = 1; MusicOnOfLabel = (Label)GetNode("Menu/MusicOnOf/MusicStatus"); player = (KinematicBody2D)GetNode("Player"); npc = (PackedScene)ResourceLoader.Load("res://Scene/NPCJatuh1.tscn"); NpcTimer = (Timer)GetNode("NpcTimer"); NpcTimer.Stop(); WaveLabel = (Label)GetNode("GUI/WaveLabel"); PanelGameOver = (Panel)GetNode("GameOver"); PanelGameOver.Visible = false; AboutPanel = (Node2D)GetNode("Menu/About"); AboutTween = (Tween)GetNode("Menu/About/Tween"); meteor = (PackedScene)ResourceLoader.Load("res://Scene/Meteor.tscn"); MeteorTimer = (Timer)GetNode("MeteorTimer"); player.Visible = false; }
public void _on_btn_start_button_down() { minusNyawa = 0; NpcTimer.Start(); player.Visible = true; MeteorTimer.Start(); var menuGui = (Node2D)GetNode("Menu"); menuGui.Visible = false; MusicMenu.Stop(); MusicPlay.Play(); ambulance(); }
public void Play() { if (_delay > 0f) { if (OS.GetTicksMsec() < _nextAllowedPlayTime) { return; } _nextAllowedPlayTime = OS.GetTicksMsec() + _delay; } switch (_type) { case SoundType.NORMAL: _sound.Play(); break; case SoundType.RANDOM_SOUND_CSHARP: _soundRnd.PlayRandomSound(); break; case SoundType.RANDOM_SOUND_GD: _node.Call(GD_RANDOM_SOUND_FUNCTION_NAME); break; } }
private void _on_Area2D_area_entered(object area) { Node areaNode = ((Node)area); Node parent = areaNode.GetParent(); if (parent.Name.Contains("Health")) { healSound.Play(); currentHealth += 10; currentHealth = Math.Min(maxHealth, currentHealth); healParticleEffect.Emitting = true; healthBar.UpdateHealthBarPercentage(currentHealth / maxHealth * 100); parent.QueueFree(); } else if (parent.Name.Contains("Points")) { moneyGained.Play(); Spend(-10); parent.QueueFree(); } else if (parent.Name.Contains("Damage")) { damage += 20; inGameUI.SetWeaponDamage(damage); parent.QueueFree(); } }
public void OnCoinBodyEntered(Godot.Object body) { m_AudioStreamPlayer2D.Play(); Hide(); EmitSignal("Hit"); m_CollisionShape2D.Disabled = true; }
public void OnHit(Unit attacker, int damage) { if (_isDead) { return; } if (_hurtSound != null) { _soundPlayer.Stream = _hurtSound; _soundPlayer.Play(); } MoveAndSlide(attacker.Position.DirectionTo(Position) * BumpStrength); Health -= damage; if (Health < 1) { Die(); return; } if (StunDurationMs > 0) { _stunUntil = OS.GetTicksMsec() + StunDurationMs; } }
private void _get_input() { // GD.Print("attackstun: " +attackstun); if (Input.IsActionJustPressed("ui_up") && _check_is_grounded()) { // GD.Print("I got input 1"); velocity.y = jump_velocity; } if (Input.IsActionJustPressed("ui_down") && _check_is_grounded() && animNode.GetAnimation() != "Cat_attack") { // GD.Print("I got input 2"); attack = true; attackstun = meleeTime; myAudio.Play(0); //Hier noch nicht time setzen, sonst kommt erst der schups und dann die Animation //attackstun wird am Ender der Animation gesetzt //und dann der Char nach vorne gespusht } move_direction = -Convert.ToInt32(Input.IsActionPressed("ui_left")) + Convert.ToInt32(Input.IsActionPressed("ui_right")); if ((move_direction != attack_move_direction) && move_direction != 0) { attack_move_direction = move_direction; } }
public virtual void _OnHit(float newHealth, float maxHealth) { Hit.Play(); if (CurrentState == State.Dead) { return; } HealthBar.Health = newHealth / maxHealth; if (HealthBarAnimationPlayer.CurrentAnimation == "Show") { HealthBarAnimationPlayer.Seek(0.2f); } else { HealthBarAnimationPlayer.Play("Show"); } if (newHealth <= 0) { Kill(); } }
// Mine explosion and sound. public void PlayMineExplosionAnimAndSound(Vector2 position) { animations.Position = position; sound.Play(); animations.Play("mine_explosion"); animations.SetFrame(0); }
public override void PostProcess(float delta) { if (juni.UpHeld) { juni.velocity.y = -125f; juni.transitionState(new ClimbState(juni)); } else if (!juni.DownHeld) { juni.velocity.y = 25f; if (slide_sound.Playing) { slide_sound.Stop(); } juni.MotionParticles.CurrentMotion = JuniMotionParticles.JuniMotion.NONE; } else { // Holding down, do slide sound. Gravity controls motion if (!slide_sound.Playing) { slide_sound.Play(); } juni.MotionParticles.CurrentMotion = JuniMotionParticles.JuniMotion.CLIMB; } if (juni.JumpEdge) { juni.velocity.x = juni.FacingRight ? -130f : 130f; juni.executeJump(); } }
public void CheckPickUp() { if (tmpKey != keyCount || tmpDiax != diaxCount) { AudioStreamPlayer2D asp2d = this.GetNode <AudioStreamPlayer2D>("pickup"); asp2d.Play(); } }
public void _on_GameOver_visibility_changed() { if (minusNyawa == 3) { AudioStreamPlayer2D MusicGameOver = (AudioStreamPlayer2D)GetNode("MusicGameOver"); MusicGameOver.Play(); } }
public void _on_PlayerArea_area_entered(Godot.Area2D area) { if (area.Name == "CoinArea") { scorePlayerNode += 1; CoinSound.Play(); } }
private void Shoot() { if (Input.IsActionJustReleased("shoot") && _canShoot && !Input.IsActionPressed("block")) { _shootAudio.Play(); _canShoot = false; EmitSignal(nameof(OnShoot), _missile, Position); } }
public void GameOver(Area2D area) { PauseMode = PauseModeEnum.Process; _isDead = true; area.QueueFree(); _deathAudio.Play(); _anim.Play("death"); EmitSignal(nameof(OnHit)); }
private void _on_DeadZoom_body_entered(Node body) { if (!body.GetGroups().Contains("Player")) { return; } body.QueueFree(); _fallSfx.Play(); _timer.Start(); }
private void ExplosionSound() { var audio = new AudioStreamPlayer2D(); audio.Stream = GD.Load("res://assets/audio/sfx/AsteroidExplosion.wav") as AudioStream; audio.PitchScale = 1; audio.Position = Position; GetParent().AddChild(audio); audio.Play(0); }
private void _on_AnimatedSprite_frame_changed() { if (sprite.Animation.Contains("walk")) { if (sprite.Frame % 2 == 1) { walkSound.Play(); } } }
private void PlayEnemyDeathSound(string name) { try { soundPlayer.Stream = (GD.Load <AudioStream>("res://sfx/enemies/" + name + ".mp3")); soundPlayer.Play(); } catch (Exception e) { GD.PrintErr(e.Message); } }
public void PreExplode() { GetNode("Shape1").QueueFree(); GetNode("Shape2").QueueFree(); GetNode("Shape3").QueueFree(); Mode = ModeEnum.Static; AudioStreamPlayer2D soundExplode = GetNode("SoundExplode") as AudioStreamPlayer2D; soundExplode.Play(); }
public void LivesDown() { m_Hurt.Play(); m_Lives -= 1; m_HUD.UpdateLives(m_Lives); if (m_Lives <= 0) { GetTree().Quit(); } }
public void OnHit(Area2D area) { if (area is Missile) { area.QueueFree(); _deathAudio.Play(); _anim.Play("death"); GetNode <CollisionShape2D>("CollisionShape2D").SetDeferred("disabled", true); EmitSignal(nameof(OnDestroy)); } }
public async void PlayStream(Sounds.Type sound) { AudioStreamPlayer2D Sound = new AudioStreamPlayer2D(); Sound.Stream = Sounds.sounds[sound]; Sound.VolumeDb = Sounds.soundAjust[sound]; AddChild(Sound); Sound.Play(); await ToSignal(Sound, "finished"); Sound.QueueFree(); }
private void PlayEffect(string effect) { if (effect == "get-point") { _asp_effect.Stream = (AudioStream)GD.Load("res://Audio/get-point.wav"); } else if (effect == "die") { _asp_effect.Stream = (AudioStream)GD.Load("res://Audio/die.wav"); } _asp_effect.Play(); }
private Vector2 ProcessJumpMovement(PlayerInputInteraction playerInputInteraction, Vector2 linearVelocity, float step) { if (!this.jumping && playerInputInteraction.Jump) { linearVelocity.y = -JUMP_VELOCITY; this.jumping = true; this.stoppingJump = false; AudioStreamPlayer2D soundJump = GetNode("SoundJump") as AudioStreamPlayer2D; soundJump.Play(); } return(linearVelocity); }
private void BulletCollider(Bullet contactCollidedBullet, Physics2DDirectBodyState bodyState, Vector2 contactLocalNormal) { Mode = ModeEnum.Rigid; this.state = STATE_DYING; bodyState.AngularVelocity = Mathf.Sign(contactLocalNormal.x) * ANGULAR_VELOCITY_CONSTANT; Friction = FRICTION_CONSTANT; contactCollidedBullet.Disable(); AudioStreamPlayer2D soundHit = GetNode("SoundHit") as AudioStreamPlayer2D; soundHit.Play(); }