//methods: //constructor public SceneManager() { //init the scenes mScenes = new List <GameScene>(); mCurrentScene = 0;//by default we start in scene zero mCrossSceneData = new CrossSceneData(); }
public void update(float deltaTime, KeyboardState keys, SceneManager sceneManager, SoundManager soundManager, int inScreenWidth, int inScreenHeight, ref CrossSceneData data) { //call update method on the player mPlayer.Update(deltaTime, keys, inScreenWidth, inScreenHeight, soundManager); //calc enemy movements if (numStepsSoFar >= numStepsPerRow) { numStepsSoFar = 0; //reset the number of steps walkDir = !walkDir; //reverse the direction of walking //move all enemies down a bit for (int i = 0; i < mEnemies.Count(); i++) { mEnemies[i].offsetPosition(0.00f, inScreenHeight * 10f * deltaTime); } } else { numStepsSoFar++;// increment the number of steps } if (walkDir) { //walk left for (int i = 0; i < mEnemies.Count(); i++) { mEnemies[i].offsetPosition(100f * deltaTime, 0); } } else { //walk right for (int i = 0; i < mEnemies.Count(); i++) { mEnemies[i].offsetPosition(-100f * deltaTime, 0); } } //enemy logic for (int i = 0; i < mEnemies.Count(); i++) { //check for bullet intersection mEnemies[i].Update(1.0f / 60.0f); if (mPlayer.getBullet().IntersectsWith(mEnemies[i]) && (!mPlayer.getBullet().isDestroyed() && mEnemies[i].mIsDead == false)) { mPlayer.getBullet().destroyBullet(); mEnemies[i].mIsDead = true;//destroy enemy data.score += 100; //mPlayer.isOnScreen = false; } //check if the enemy is too close if (mEnemies[i].GetPos().Y > inScreenHeight * 0.7f) { Console.WriteLine("Game over"); sceneManager.selectNextScene(deltaTime, keys, sceneManager, soundManager, inScreenWidth, inScreenHeight, ref data); return; } } //update barricades for (int i = 0; i < mBarricades.Count; i++) { mBarricades[i].Update(deltaTime); } }
public void onSwitchTo(float deltaTime, KeyboardState keys, SceneManager sceneManager, SoundManager soundManager, int inScreenWidth, int inScreenHeight, ref CrossSceneData data) { //load the game: //load enemies }
public void selectSceneByID(int ID, float deltaTime, KeyboardState keys, SceneManager sceneManager, SoundManager soundManager, int inScreenWidth, int inScreenHeight, ref CrossSceneData data) { mCurrentScene = ID; mScenes[mCurrentScene].onSwitchTo(deltaTime, keys, sceneManager, soundManager, inScreenWidth, inScreenHeight, ref data); }
public void update(float deltaTime, KeyboardState keys, SceneManager sceneManager, SoundManager soundManager, int inScreenWidth, int inScreenHeight, ref CrossSceneData data) { //if we have endured the required amount of time, transition to next scene if (mEnduredScreenTime >= mScreenTime) { sceneManager.selectNextScene(deltaTime, keys, sceneManager, soundManager, inScreenWidth, inScreenHeight, ref data); } mEnduredScreenTime += (deltaTime);//increment the endured splash time }
public void onSwitchTo(float deltaTime, KeyboardState keys, SceneManager sceneManager, SoundManager soundManager, int inScreenWidth, int inScreenHeight, ref CrossSceneData data) { //when switching back to the main menue, reset health and score data.score = 0; data.health = 0; }
public void update(float deltaTime, KeyboardState keys, SceneManager sceneManager, SoundManager soundManager, int inScreenWidth, int inScreenHeight, ref CrossSceneData data) { //if we have endured the required amount of time, transition to next scene if (keys.IsKeyDown(Keys.Enter)) { sceneManager.selectNextScene(deltaTime, keys, sceneManager, soundManager, inScreenWidth, inScreenHeight, ref data); } mPressStartPos.X = (inScreenWidth - mMessageFont.MeasureString(mMessageString).X) / 2; mPressStartPos.Y = inScreenHeight * 0.2f;// inScreenHeight - (inScreenHeight * 0.2f); }
public void update(float deltaTime, KeyboardState keys, SceneManager sceneManager, SoundManager soundManager, int inScreenWidth, int inScreenHeight, ref CrossSceneData data) { if (keys.IsKeyDown(Keys.Enter)) { //go back to the main menue sceneManager.selectSceneByID(1, deltaTime, keys, sceneManager, soundManager, inScreenWidth, inScreenHeight, ref data); } }
public void onSwitchTo(float deltaTime, KeyboardState keys, SceneManager sceneManager, SoundManager soundManager, int inScreenWidth, int inScreenHeight, ref CrossSceneData data) { //init the scores list mScores = new List <scores>(); mScore.updateText("Score: " + data.score.ToString()); //position the score text on the screen Vector2 scorePos = new Vector2( (inScreenWidth - mScore.getFont().MeasureString(mScore.getText()).X) / 2, //calc x pos inScreenHeight * 0.2f); //calx y pos - top 20% of screen mScore.updatePos(scorePos); scorePos = new Vector2( (inScreenWidth - mContinueText.getFont().MeasureString(mContinueText.getText()).X) / 2, //calc x pos inScreenHeight * 0.8f); //calx y pos - at bottom 20% of screen mContinueText.updatePos(scorePos); }