//Called whenever the player touches a coin public Boolean getCoin(FlxObject Coin, FlxObject Player) { Coin.kill(); score.text = "SCORE: " + (coins.CountDead() * 100); if (coins.CountLiving() == 0) { status.text = "Find the exit."; exit.Exists = true; } return(true); }
public override void update() { /* * if(_pad.Visible) * _pad.update(); */ //save off the current score and update the game state int oldScore = FlxG.score; base.update(); //collisions with environment FlxG.collide(_blocks, _objects); FlxG.overlap(_hazards, _player, overlapped); FlxG.overlap(_bullets, _hazards, overlapped); //check to see if the player scored any points this frame bool scoreChanged = oldScore != FlxG.score; //Jammed message if ((FlxG.keys.justPressed(Keys.C) /*|| _pad.buttonB.status == FlxButton.Pressed*/) && _player.flickering) { _jamTimer = 1; _gunjam.Visible = true; } if (_jamTimer > 0) { if (!_player.flickering) { _jamTimer = 0; } _jamTimer -= FlxG.elapsed; if (_jamTimer < 0) { _gunjam.Visible = false; } } if (!_fading) { //Score + countdown stuffs if (scoreChanged) { _scoreTimer = 2; } _scoreTimer -= FlxG.elapsed; if (_scoreTimer < 0) { if (FlxG.score > 0) { if (FlxG.score > 100) { FlxG.score -= 100; } else { FlxG.score = 0; _player.kill(); } _scoreTimer = 1; scoreChanged = true; //Play loud beeps if your score is low float volume = 0.35f; if (FlxG.score < 600) { volume = 1.0f; } _sfxCount.Volume = volume; _sfxCount.play(true); } } //Fade out to victory screen stuffs if (_spawners.CountLiving() <= 0) { _fading = true; FlxG.fade(Color.Black, 3, onVictory); } } //actually update score text if it changed if (scoreChanged) { if (!_player.Alive) { FlxG.score = 0; } _score.text = "" + FlxG.score; } }