private void getCollisionPlayer() { if (HitTest(_level.player)) { SoundChannel soundChannel = new SoundChannel(2); Sound pickup = new Sound("coin.wav"); pickup.Play(false, 2); _level.thisgame.playerCoins++; _level.player.addPoints(40); Destroy(); } }
private void getEnding(bool pLevelWon) { SoundChannel soundChannel = new SoundChannel(2); if (pLevelWon) { Sprite background = new Sprite("youwon.png"); AddChild(background); Sound youWonSound = new Sound("youwin.mp3"); youWonSound.Play(false, 2); } else { Sprite background = new Sprite("gameover.png"); AddChild(background); Sound gameOverSound = new Sound("gameover.wav"); gameOverSound.Play(false, 2); } }
private void getCollisionPlayer() { if (HitTest(_level.player)) { if (_level.player.bulletCounter < 2f) { _level.player.bulletCounter = 2f; } else if (_level.player.bulletCounter == 2f) { _level.player.bulletCounter = 3f; } SoundChannel soundChannel = new SoundChannel(2); Sound reload = new Sound("reloadgun.mp3"); reload.Play(false, 2); _level.player.bulletCounter = 3f; this.Destroy(); } }
//gethit public void HitByBullet(float pBulletDamage, PlayerDirection pDirection) { SoundChannel soundChannel = new SoundChannel(2); Sound hit = new Sound("hurt.wav"); hit.Play(false, 2); if (_state == EnemyState.death) return; if (_health <= 0f) { _state = EnemyState.death; _level.player.addPoints((int)_points); } else if (_health > 0f) { directionHit = pDirection; _health -= pBulletDamage; _hitTimer = pBulletDamage; _state = EnemyState.hit; _level.player.addPoints(10); } }
/// <summary> /// Initializes a new instance of the <see cref="GXPEngine.Player"/> class. /// Sprite: http://opengameart.org/content/mv-platformer-male-32x64 /// </summary> public Player(int lives) : base("Sprites/ninja_full.png", 10, 3) { _lives = lives; _moveSpeed = 4; _frame = 0.0f; _grounded = false; SetFrame (1); //http://opengameart.org/content/platformer-sounds-terminal-interaction-door-shots-bang-and-footsteps new Sound ("Audio/start.ogg").Play(); //http://opengameart.org/content/platformer-sounds-terminal-interaction-door-shots-bang-and-footsteps _footStepSound = new Sound ("Audio/steps_platform.ogg", true); _footStepChannel = _footStepSound.Play (true); //http://opengameart.org/content/level-up-power-up-coin-get-13-sounds _coinPickupSound = new Sound ("Audio/Coin01.aif"); //http://www.freesound.org/people/semccab/sounds/154403/ _slideSound = new Sound ("Audio/slide.wav", true); _slideChannel = _slideSound.Play (true); }
private void shootBullet() { if (aimDirection == PlayerDirection.up) { recoil(aimDirection); } else if (aimDirection == PlayerDirection.down) { recoil(aimDirection); } else if (aimDirection == PlayerDirection.left) { recoil(aimDirection); } else if (aimDirection == PlayerDirection.right) { recoil(aimDirection); } PlayerBullet bullet = new PlayerBullet(aimDirection, _level); _level.backgroundLayer.AddChild(bullet); bullet.SetXY(x, y - (height / 2)); SoundChannel soundChannel = new SoundChannel(2); Sound shootsound = new Sound("shoot.wav"); shootsound.Play(false, 2); _level.thisgame.shakeScreen(); }