/* * Draws the choosen popup with the buttons */ public void DisplayPopUp(SpectrumEnums.popUpId id) { // maybe a popup manager, to dispose popups after being x. switch (id) { case SpectrumEnums.popUpId.win: displayedPopUp = new PopUp(game, this, player, SpectrumEnums.popUpId.win); break; case SpectrumEnums.popUpId.lose: displayedPopUp = new PopUp(game, this, player, SpectrumEnums.popUpId.lose); break; case SpectrumEnums.popUpId.custom: displayedPopUp = new PopUp(game, this, player, SpectrumEnums.popUpId.custom, "Not enough Ink", "You need to collect all the ink\n in order to proceed to the next level.\nGoogoos (enemies) also give ink!"); break; case SpectrumEnums.popUpId.musicSettings: displayedPopUp = new PopUp(game, this, player, SpectrumEnums.popUpId.musicSettings); break; case SpectrumEnums.popUpId.deleteSaveFile: displayedPopUp = new PopUp(game, this, player, SpectrumEnums.popUpId.deleteSaveFile); break; case SpectrumEnums.popUpId.gameAnalytics: displayedPopUp = new PopUp(game, this, player, SpectrumEnums.popUpId.gameAnalytics); break; default: break; } displayedPopUp.Draw(spriteBatch); }
public Button(Vector2 position, Game game, SpectrumEnums.buttons buttonId = SpectrumEnums.buttons.levelSelection) { this.texManager = ((Spectrum)game).texManager; this.currentbuttonId = buttonId; this.game = game; scale = 1; textureUp = texManager.getButtonTextureNormal(buttonId); textureDown = texManager.getButtonTextureClicked(buttonId); textureOver = texManager.getButtonTextureHover(buttonId); activeTexture = textureUp; int scaledTexWidth = (int)(textureUp.Width * scale); int scaledTexHeight = (int)(textureUp.Height * scale); origin = new Vector2(textureUp.Width / 2f, textureUp.Height / 2f); recPosition = new Rectangle((int)position.X - (int)origin.X, (int)position.Y - (int)origin.Y, textureUp.Width, textureUp.Height); center = new Vector2(position.X + recPosition.Width / 2f, position.Y + recPosition.Height / 2f); this.position = position; }
/* * Draws the choosen popup with the buttons */ public void DisplayPopUp(SpectrumEnums.popUpId id) { // maybe a popup manager, to dispose popups after being x. switch (id) { case SpectrumEnums.popUpId.win: displayedPopUp = new PopUp(game, this, player, SpectrumEnums.popUpId.win); break; case SpectrumEnums.popUpId.lose: displayedPopUp = new PopUp(game, this, player, SpectrumEnums.popUpId.lose); break; case SpectrumEnums.popUpId.custom: displayedPopUp = new PopUp(game, this, player, SpectrumEnums.popUpId.custom, "Not enough Ink", "You need to collect all the ink in order to proceed to the next level."); break; default: break; } displayedPopUp.Draw(spriteBatch); }
public Button(Vector2 position, Game game, SpectrumEnums.icons iconId = SpectrumEnums.icons.close) { this.texManager = ((Spectrum)game).texManager; this.currentIconId = iconId; this.currentbuttonId = SpectrumEnums.buttons.None; this.game = game; // this.padlock = texManager.getPadlockTexture(); isIcon = true; textureUp = texManager.getUITexture(iconId); textureDown = textureUp; textureOver = textureUp; activeTexture = textureUp; int scaledTexWidth = (int)(textureUp.Width * scale); int scaledTexHeight = (int)(textureUp.Height * scale); // TODO fix scaling problem origin = new Vector2(scaledTexWidth / 2f, scaledTexHeight / 2f); recPosition = new Rectangle((int)position.X - (int)origin.X, (int)position.Y - (int)origin.Y, scaledTexWidth, scaledTexHeight); center = new Vector2(position.X + recPosition.Width / 2f, position.Y + recPosition.Height / 2f); this.position = position; }
/* * Returns icon texture with given id */ public Texture2D getUITexture(SpectrumEnums.icons icon) { switch(icon) { case SpectrumEnums.icons.life: return lifeTex; case SpectrumEnums.icons.cont: return continueTex; case SpectrumEnums.icons.down: return downTex; case SpectrumEnums.icons.home: return homeTex; case SpectrumEnums.icons.left: return leftTex; case SpectrumEnums.icons.muteMusic: return muteMusicTex; case SpectrumEnums.icons.muteFX: return muteFXTex; case SpectrumEnums.icons.pause: return pauseTex; case SpectrumEnums.icons.play: return playTex; case SpectrumEnums.icons.retry: return retryTex; case SpectrumEnums.icons.right: return rightTex; case SpectrumEnums.icons.settings: return settingsTex; case SpectrumEnums.icons.tick: return tickTex; case SpectrumEnums.icons.up: return upTex; case SpectrumEnums.icons.fx: return fxTex; case SpectrumEnums.icons.close: return closeTex; case SpectrumEnums.icons.music: return musicTex; } return lifeTex; }
/* * Returns splashScreen texture with the given id */ public Texture2D getSplashScreen(SpectrumEnums.splashScreen screen) { switch (screen) { case SpectrumEnums.splashScreen.start: return startSplash; } return startSplash; }
public Texture2D getButtonTextureHover(SpectrumEnums.buttons button) { switch (button) { case SpectrumEnums.buttons.startGame: return startH; case SpectrumEnums.buttons.continueGame: return continueH; case SpectrumEnums.buttons.levelSelection: return levelSelectH; case SpectrumEnums.buttons.settings: return settingsH; case SpectrumEnums.buttons.exitGame: return exitH; case SpectrumEnums.buttons.delteSaveFile: return newFileH; case SpectrumEnums.buttons.act1: return act1H; case SpectrumEnums.buttons.act2: return act2H; case SpectrumEnums.buttons.act3: return act3H; case SpectrumEnums.buttons.act4: return act4H; case SpectrumEnums.buttons.act5: return act5H; case SpectrumEnums.buttons.epilog: return actEH; case SpectrumEnums.buttons.prolog: return actPH; case SpectrumEnums.buttons.musicSettings: return soundH; } return startH; }
public void setRefLevel(SpectrumEnums.Levels level) { refLevel = level; Spectrum.lastLevelInGame = level; }
public void setRefAct(SpectrumEnums.Act act) { refAct = act; }
/* * Saves, Loads or Deletes a saveFile */ private void UpdateSavingLoadingOrDeleting(SpectrumEnums.SaveLoadOrDelete saveLoadOrDelete) { switch (savingState) { case SpectrumEnums.SavingState.ReadyToSelectStorageDevice: asyncResult = StorageDevice.BeginShowSelector(PlayerIndex.One, null, null); savingState = SpectrumEnums.SavingState.SelectingStorageDevice; break; case SpectrumEnums.SavingState.SelectingStorageDevice: if (asyncResult.IsCompleted) { storageDevice = StorageDevice.EndShowSelector(asyncResult); savingState = SpectrumEnums.SavingState.ReadyToOpenStorageContainer; } break; case SpectrumEnums.SavingState.ReadyToOpenStorageContainer: if (storageDevice == null || !storageDevice.IsConnected) { savingState = SpectrumEnums.SavingState.ReadyToSelectStorageDevice; } else { asyncResult = storageDevice.BeginOpenContainer("SpectrumSaveGame", null, null); savingState = SpectrumEnums.SavingState.OpeningStorageContainer; } break; case SpectrumEnums.SavingState.OpeningStorageContainer: if (asyncResult.IsCompleted) { storageContainer = storageDevice.EndOpenContainer(asyncResult); if (saveLoadOrDelete == SpectrumEnums.SaveLoadOrDelete.save) { savingState = SpectrumEnums.SavingState.ReadyToSave; } else if (saveLoadOrDelete == SpectrumEnums.SaveLoadOrDelete.load) { savingState = SpectrumEnums.SavingState.ReadyToLoad; } else { savingState = SpectrumEnums.SavingState.ReadyToDelete; } } break; case SpectrumEnums.SavingState.ReadyToLoad: if (storageContainer == null) { savingState = SpectrumEnums.SavingState.ReadyToOpenStorageContainer; } else { Load(); storageContainer.Dispose(); storageContainer = null; savingState = SpectrumEnums.SavingState.NotSaving; } break; case SpectrumEnums.SavingState.ReadyToDelete: if (storageContainer == null) { savingState = SpectrumEnums.SavingState.ReadyToOpenStorageContainer; } else { try { DeleteExisting(); } catch (IOException e) { // error } finally { storageContainer.Dispose(); storageContainer = null; savingState = SpectrumEnums.SavingState.NotSaving; } } break; case SpectrumEnums.SavingState.ReadyToSave: if (storageContainer == null) { savingState = SpectrumEnums.SavingState.ReadyToOpenStorageContainer; } else { try { DeleteExisting(); Save(); } catch (IOException e) { // error } finally { storageContainer.Dispose(); storageContainer = null; savingState = SpectrumEnums.SavingState.NotSaving; } } break; } }
/* * Action if a navigation button is pressed * will lead back to the previous gameState */ public void goBackAction(SpectrumEnums.GameState previousGameState) { Spectrum.currentGameState = previousGameState; }
public SpectrumEnums.Levels getNextLevel(SpectrumEnums.Levels level) { switch(level) { case SpectrumEnums.Levels.LevelP_0: return SpectrumEnums.Levels.LevelP_1; case SpectrumEnums.Levels.LevelP_1: return SpectrumEnums.Levels.LevelP_2; case SpectrumEnums.Levels.LevelP_2: return SpectrumEnums.Levels.Level1_0; case SpectrumEnums.Levels.Level1_0: return SpectrumEnums.Levels.Level1_1; case SpectrumEnums.Levels.Level1_1: return SpectrumEnums.Levels.Level2_0; case SpectrumEnums.Levels.Level2_0: return SpectrumEnums.Levels.Level2_1; case SpectrumEnums.Levels.Level2_1: return SpectrumEnums.Levels.Level3_0; case SpectrumEnums.Levels.Level3_0: return SpectrumEnums.Levels.Level3_1; case SpectrumEnums.Levels.Level3_1: return SpectrumEnums.Levels.Level4_0; case SpectrumEnums.Levels.Level4_0: return SpectrumEnums.Levels.Level4_1; case SpectrumEnums.Levels.Level4_1: return SpectrumEnums.Levels.Level5_0; case SpectrumEnums.Levels.Level5_0: return SpectrumEnums.Levels.Level5_1; case SpectrumEnums.Levels.Level5_1: return SpectrumEnums.Levels.LevelE_0; case SpectrumEnums.Levels.LevelE_0: Spectrum.currentGameState = SpectrumEnums.GameState.GameOver; return SpectrumEnums.Levels.LevelE_0; } return SpectrumEnums.Levels.LevelP_0; }
/* * Returns popup texture with given id */ public Texture2D getUITexture(SpectrumEnums.popUpId popUp) { switch (popUp) { case SpectrumEnums.popUpId.lose: return youLosePopUpTex; case SpectrumEnums.popUpId.custom: case SpectrumEnums.popUpId.deleteSaveFile: case SpectrumEnums.popUpId.musicSettings: case SpectrumEnums.popUpId.gameAnalytics: return neutralPopUpTex; case SpectrumEnums.popUpId.win: return youWinPopUpTex; case SpectrumEnums.popUpId.mainMenu: return getTextureDependingOnProgress(); case SpectrumEnums.popUpId.levelSelection: return getTextureDependingOnProgress(); } return getTextureDependingOnProgress(); }
/* * Returns icon texture with given id */ public Texture2D getUITexture(SpectrumEnums.icons icon) { switch(icon) { case SpectrumEnums.icons.life: return lifeTex; case SpectrumEnums.icons.cont: return continueTex; case SpectrumEnums.icons.down: return downTex; case SpectrumEnums.icons.home: case SpectrumEnums.icons.inGameHome: return homeTex; case SpectrumEnums.icons.left: return leftTex; case SpectrumEnums.icons.muteMusic: return muteMusicTex; case SpectrumEnums.icons.muteFX: return muteFXTex; case SpectrumEnums.icons.pause: return pauseTex; case SpectrumEnums.icons.play: return playTex; case SpectrumEnums.icons.retry: return retryTex; case SpectrumEnums.icons.right: return rightTex; case SpectrumEnums.icons.settings: return settingsTex; case SpectrumEnums.icons.tick: return tickTex; case SpectrumEnums.icons.up: return upTex; case SpectrumEnums.icons.fx: return volumeNoBars; case SpectrumEnums.icons.volumeDownFX: return volumeDown; case SpectrumEnums.icons.volumeUpFX: return fxTex; case SpectrumEnums.icons.close: return closeTex; case SpectrumEnums.icons.music: return musicTex; case SpectrumEnums.icons.volumeUpMusic: return soundBars; case SpectrumEnums.icons.volumeDownMusic: return soundDown; case SpectrumEnums.icons.confirm: return tickTex; case SpectrumEnums.icons.abort: return closeTex; case SpectrumEnums.icons.questionmark: return questionMark; case SpectrumEnums.icons.empty: return empty; } return lifeTex; }
/* * Returns button texture with given id */ public Texture2D getButtonTextureNormal(SpectrumEnums.buttons button) { switch (button) { case SpectrumEnums.buttons.startGame: return startN; case SpectrumEnums.buttons.continueGame: return continueN; case SpectrumEnums.buttons.levelSelection: return levelSelectN; case SpectrumEnums.buttons.settings: return settingsN; case SpectrumEnums.buttons.exitGame: return exitN; case SpectrumEnums.buttons.delteSaveFile: return newFileN; case SpectrumEnums.buttons.act1: return act1N; case SpectrumEnums.buttons.act2: return act2N; case SpectrumEnums.buttons.act3: return act3N; case SpectrumEnums.buttons.act4: return act4N; case SpectrumEnums.buttons.act5: return act5N; case SpectrumEnums.buttons.epilog: return actEN; case SpectrumEnums.buttons.prolog: return actPN; case SpectrumEnums.buttons.musicSettings: return soundN; } return startN; }
/* * Returns button texture with given id */ public Texture2D getUITexture(SpectrumEnums.buttons button) { switch (button) { case SpectrumEnums.buttons.levelSelection: return buttonExample; } return buttonExample; }
/* * Returns popup texture with given id */ public Texture2D getUITexture(SpectrumEnums.popUpId popUp) { switch (popUp) { case SpectrumEnums.popUpId.lose: return youLosePopUpTex; case SpectrumEnums.popUpId.custom: return neutralPopUpTex; case SpectrumEnums.popUpId.win: return youWinPopUpTex; case SpectrumEnums.popUpId.mainMenu: return menuTex; case SpectrumEnums.popUpId.levelSelection: return getTextureDependingOnProgress(); } return menuTex; }
/* * Action if a navigation Button is pressed */ public void goToAction(SpectrumEnums.Act act) { Spectrum.currentAct = act; }
/* * Initializes Startvalues */ public void setStartValues(Vector3 pos, Vector3 dir, Vector3 up, Quaternion rot, SpectrumEnums.Orientation ori) { this.startPosition = pos; currentPosition = startPosition; // this.startDirection = dir; this.startUp = up; this.startOrientation = ori; this.startRotation = rot; velocity = Vector3.Zero; accelerationVector = currentDirection * acceleration; friction = -currentDirection * frictionValue; }
/* * Action used to load a given level */ public void loadLevelAction(SpectrumEnums.Levels level) { closePopUpAction(); Spectrum.currentLevel = level; Spectrum.currentGameState = SpectrumEnums.GameState.LoadLevel; Spectrum.lastPlayedLevel = level; ((Spectrum)game).getCurrentActFromCurrentLevel(); ((Spectrum)game).saveToSaveFile(); }
public void setRefGameState(SpectrumEnums.GameState gameState) { refGameState = gameState; }
//================== Music Settings Bars =====================// public PopUp(Game game, ScreenManager screenManager, Bubble player, SpectrumEnums.popUpId style = SpectrumEnums.popUpId.custom, string headline = "", string text = "") { this.position = new Vector2(game.Window.ClientBounds.Width / 2f, game.Window.ClientBounds.Height / 2f); this.game = game; this.texManager = ((Spectrum)game).texManager; this.screenManager = screenManager; this.player = player; this.headlineFont = screenManager.modelManager.getHeadlineFont(); this.textFont = screenManager.modelManager.getTextFont(); this.buttonHandler = screenManager.modelManager.buttonHandler; popUpTexture = texManager.getUITexture(style); currentStyle = style; switch (style) { case SpectrumEnums.popUpId.custom: this.headline = headline; this.text = text; break; case SpectrumEnums.popUpId.win: this.headline = "Congratulations!"; this.text = "You beat the level! \n You can go on with the next level \nor play again."; break; case SpectrumEnums.popUpId.lose: this.headline = "Game over"; this.text = "You lose, try again!"; break; } origin = new Vector2(popUpTexture.Width / 2f, popUpTexture.Height / 2f); center = new Vector2(position.X + recPosition.Width / 2f, position.Y + recPosition.Height / 2f); recPosition = new Rectangle((int)position.X - (int)origin.X, (int)position.Y - (int)origin.Y, popUpTexture.Width, popUpTexture.Height); setButtons(); }
public void loadLevel(SpectrumEnums.Levels level) { currentLevel = level; Spectrum.lastPlayedLevel = level; models.Add(new SkySphere(skySphereModel, game, ((Spectrum)Game).camera, this)); ((Spectrum)game).getCurrentActFromCurrentLevel(); levelCreator.loadLevel(currentLevel); mapResolution = levelCreator.getCurrentMapResolution(); ((Spectrum)game).getCurrentActFromCurrentLevel(); ((Spectrum)game).soundManager.playMusic(); Vector3 startPosition = levelCreator.getStartPosition(); Vector3 startDirection = Vector3.Zero; Vector3 startUp = Vector3.Zero; enemies = levelCreator.getEnemies(); countLevelInk(); Vector3 dim = levelCreator.getCurrentMapResolution(); OctTree octree = new OctTree(-2, -2, -2, (dim.Z * 2) + 2, (dim.Y * 2) + 2, (dim.X * 2) + 2); foreach(BasicCube cube in worldMap) { octree.Insert(cube); } foreach (Googoo enemy in enemies) { enemy.setAStar(worldMap, mapResolution); enemy.setOctTree(octree); enemy.InitializePathfinding(); } player = new Bubble(bubbleModel, game, ((Spectrum)Game).camera, octree, startPosition, startDirection, startUp, worldMap, screenManager); player.setLives(levelCreator.getLivesInLevel()); models.Add(player); }
/* * Returns cube texture for given cube */ public Texture2D getCubeTexture(SpectrumEnums.Cubes cube) { switch (cube) { case SpectrumEnums.Cubes.Start: return startTexture; case SpectrumEnums.Cubes.Goal: return goalTexture; case SpectrumEnums.Cubes.Grass: return grassTexture; case SpectrumEnums.Cubes.Ice: return iceTexture; case SpectrumEnums.Cubes.Mud: return mudTexture; case SpectrumEnums.Cubes.Lava: return lavaTexture; case SpectrumEnums.Cubes.Cobblestone: return cobbleTexture; case SpectrumEnums.Cubes.Sponge: return spongeTexture; case SpectrumEnums.Cubes.Error: return errorTexture; } return errorTexture; }
public BasicCube(Model model, Game game, SpectrumEnums.Cubes face, Camera camera, Vector3 offset, ModelManager modelManager) : base(model, game) { effect = ((Spectrum)game).grayEffect; this.camera = camera; this.game = game; this.texManager = ((Spectrum)game).texManager; cubeM = model; this.offset = offset; translation = Matrix.CreateTranslation(offset); this.modelManager = modelManager; texture = texManager.getCubeTexture(face); boundingBox = GetBoundingBox(); this.left = offset.X - 1; this.right = offset.X + 1; this.down = offset.Y - 1; this.top = offset.Y + 1; this.rear = offset.Z - 1; this.front = offset.Z + 1; switch(face) { case SpectrumEnums.Cubes.Start: posXFace = new StartFace(this, modelManager, 0); negXFace = new StartFace(this, modelManager, 1); posYFace = new StartFace(this, modelManager, 2); negYFace = new StartFace(this, modelManager, 3); posZFace = new StartFace(this, modelManager, 4); negZFace = new StartFace(this, modelManager, 5); break; case SpectrumEnums.Cubes.Goal: posXFace = new GoalFace(this, modelManager, 0); negXFace = new GoalFace(this, modelManager, 1); posYFace = new GoalFace(this, modelManager, 2); negYFace = new GoalFace(this, modelManager, 3); posZFace = new GoalFace(this, modelManager, 4); negZFace = new GoalFace(this, modelManager, 5); break; case SpectrumEnums.Cubes.Grass: posXFace = new NeutralFace(this, modelManager, 0); negXFace = new NeutralFace(this, modelManager, 1); posYFace = new NeutralFace(this, modelManager, 2); negYFace = new NeutralFace(this, modelManager, 3); posZFace = new NeutralFace(this, modelManager, 4); negZFace = new NeutralFace(this, modelManager, 5); break; case SpectrumEnums.Cubes.Ice: posXFace = new IceFace(this, modelManager, 0); negXFace = new IceFace(this, modelManager, 1); posYFace = new IceFace(this, modelManager, 2); negYFace = new IceFace(this, modelManager, 3); posZFace = new IceFace(this, modelManager, 4); negZFace = new IceFace(this, modelManager, 5); break; case SpectrumEnums.Cubes.Mud: posXFace = new MudFace(this, modelManager, 0); negXFace = new MudFace(this, modelManager, 1); posYFace = new MudFace(this, modelManager, 2); negYFace = new MudFace(this, modelManager, 3); posZFace = new MudFace(this, modelManager, 4); negZFace = new MudFace(this, modelManager, 5); break; case SpectrumEnums.Cubes.Lava: posXFace = new LavaFace(this, modelManager, 0); negXFace = new LavaFace(this, modelManager, 1); posYFace = new LavaFace(this, modelManager, 2); negYFace = new LavaFace(this, modelManager, 3); posZFace = new LavaFace(this, modelManager, 4); negZFace = new LavaFace(this, modelManager, 5); break; case SpectrumEnums.Cubes.Cobblestone: posXFace = new NeutralFace(this, modelManager, 0); negXFace = new NeutralFace(this, modelManager, 1); posYFace = new NeutralFace(this, modelManager, 2); negYFace = new NeutralFace(this, modelManager, 3); posZFace = new NeutralFace(this, modelManager, 4); negZFace = new NeutralFace(this, modelManager, 5); break; case SpectrumEnums.Cubes.Sponge: posXFace = new SpongeFace(this, modelManager, 0); negXFace = new SpongeFace(this, modelManager, 1); posYFace = new SpongeFace(this, modelManager, 2); negYFace = new SpongeFace(this, modelManager, 3); posZFace = new SpongeFace(this, modelManager, 4); negZFace = new SpongeFace(this, modelManager, 5); break; case SpectrumEnums.Cubes.Error: posXFace = new NeutralFace(this, modelManager, 0); negXFace = new NeutralFace(this, modelManager, 1); posYFace = new NeutralFace(this, modelManager, 2); negYFace = new NeutralFace(this, modelManager, 3); posZFace = new NeutralFace(this, modelManager, 4); negZFace = new NeutralFace(this, modelManager, 5); break; default: posXFace = new NeutralFace(this, modelManager, 0); negXFace = new NeutralFace(this, modelManager, 1); posYFace = new NeutralFace(this, modelManager, 2); negYFace = new NeutralFace(this, modelManager, 3); posZFace = new NeutralFace(this, modelManager, 4); negZFace = new NeutralFace(this, modelManager, 5); break; } }
public Texture2D getButtonTextureClicked(SpectrumEnums.buttons button) { switch (button) { case SpectrumEnums.buttons.startGame: return startC; case SpectrumEnums.buttons.continueGame: return continueC; case SpectrumEnums.buttons.levelSelection: return levelSelectC; case SpectrumEnums.buttons.settings: return settingsC; case SpectrumEnums.buttons.exitGame: return exitC; case SpectrumEnums.buttons.delteSaveFile: return newFileC; case SpectrumEnums.buttons.act1: return act1C; case SpectrumEnums.buttons.act2: return act2C; case SpectrumEnums.buttons.act3: return act3C; case SpectrumEnums.buttons.act4: return act4C; case SpectrumEnums.buttons.act5: return act5C; case SpectrumEnums.buttons.epilog: return actEC; case SpectrumEnums.buttons.prolog: return actPC; case SpectrumEnums.buttons.musicSettings: return soundC; } return startC; }