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(); } }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // HandleDeath() //---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- void HandleDeath() { if (isHit) { _deadSound.Play(); LateDestroy(); LateRemove(); isHit = false; Globals.EnemyIsDead = false; Globals.playerScore = Globals.playerScore + 10; } }
public InfoScreen(MyGame mygame) : base("HUD/info page (1).png") { _backgroundChanel = _backgroundMusic.Play(); _backgroundChanel.Volume = 0.5f; _mygame = mygame; this.width = game.width; this.height = game.height; _startButton.x = _width * 0.6f; _startButton.y = _height * 0.99f; _quitButton.x = _width * 0.8f; _quitButton.y = _height * 0.99f; AddChild(_startButton); AddChild(_quitButton); }
void overlap() { if (colected == false) { if (Input.GetMouseButtonDown(button: 0)) { if (Input.mouseX > this.x && Input.mouseX < this.x + this.width && Input.mouseY > this.y && Input.mouseY < this.y + this.height) { colectCoin.Play(); colected = true; _level.currencySystem.AddMoney(value); this.LateDestroy(); } } } }
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); } }
void Update() { if (visible == true) { foreach (Fish fish in fishList) { if (MyGame.CheckMouseInRectClick(fish.buyToUnlock)) { if (_level.currencySystem.money >= fish.coinValue) { if (fish.isUnlocked == false) { buyFish.Play(); _level.currencySystem.RemoveMoney(fish.coinValue); fish.Unlock(); _level.journal.AddFish(fish); } } } } } }
//void makeTutorialDissapear() //{ // if (_tutorial != null) // { // _tutorial.BecomeInvisible(); // } //} //void makeTutorialAppear() //{ // if (_tutorial != null) // { // _tutorial.BecomeVisible(); // // _tutorial.maxFrameToChange++; // } //} //void ChangeTutorialMaxFrame() //{ // if (_tutorial != null) // { // _tutorial.maxFrameToChange=tutorialIndex; // } //} //void ChangeTutorialFrame() //{ // if (_tutorial != null) // { // _tutorial.currentFrame++; // } //} void buyAquarium() { //Console.WriteLine(_tutorial.visible); if (MyGame.CheckMouseInRectClick(clickToBuy)) { if (level.currencySystem.money >= priceOfAquarium) { clickToBuy.LateDestroy(); isBought = true; AddChild(inv); level.currencySystem.RemoveMoney(priceOfAquarium); repairAquarium.Play(); //if (_tutorial.visible == true) //{ // ChangeTutorialFrame(); //} //tutorialIndex += 1; //ChangeTutorialMaxFrame(); } } }
/// <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); }
public MainMenu(MyGame mygame) : base("HUD/menu.png") { _backgroundChanel = _backgroundMusic.Play(); _backgroundChanel.Volume = 0.5f; _mygame = mygame; this.width = game.width; this.height = game.height; _startButton.x = game.width * 0.35f; _startButton.y = game.height * 0.75f; _infoButton.x = game.width * 0.55f; _infoButton.y = game.height * 0.75f; _quitButton.x = game.width * 0.75f; _quitButton.y = game.height * 0.75f; AddChild(_startButton); AddChild(_infoButton); AddChild(_quitButton); }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // startMusic() //---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- void startMusic() { _music = new Sound("background_music_main_menu.mp3", true, true); _musicChannel = _music.Play(); _musicChannel.Volume = 0.2f; }
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(); }
private void handleInputHuman() { if (!Input.GetKey(Key.LEFT_SHIFT)) { if ((Input.GetKeyDown(Key.W)) && _landed == true) { _velocity.y -= _jump; _landed = false; } if (Input.GetKey(Key.A)) { _velocity.x = Utils.Clamp(_velocity.x - _speed, -5 - _topSpeed, 5 + _topSpeed); this.Mirror(true, false); left = true; walkAnimationHuman(); } if (Input.GetKey(Key.D)) { _velocity.x = Utils.Clamp(_velocity.x + _speed, -5 - _topSpeed, 5 + _topSpeed); this.Mirror(false, false); left = false; walkAnimationHuman(); } if ((!Input.GetKey(Key.A)) && (!Input.GetKey(Key.D)) && (!Input.GetKey(Key.W)) && (!Input.GetKey(Key.SPACE)) && _attackAnimation == false) { idleTimer++; if (idleTimer > 10) { idleHuman(); } } else { idleTimer = 0; } if ((Input.GetKeyDown(Key.SPACE)) && _cooldown == 0) { Projectile fireball = new Projectile(this); _backgroundChanel = _backgroundMusic.Play(); _backgroundChanel.Volume = 0.5f; _level.AddChild(fireball); _cooldown = 120; if ((!Input.GetKey(Key.A)) && (!Input.GetKey(Key.D))) { _attackAnimation = true; } } else { if (_cooldown != 0) { _cooldown--; } } if (_attackAnimation == true) { if ((!Input.GetKey(Key.A)) && (!Input.GetKey(Key.D))) { HumanAttack(); } } } }