public void collectItem(Item item) { if (item is Key) { keyCounter++; MusicManager.PlaySound(AssetManager.SoundName.Key); } if (item is RedItem) { redItemCounter++; MusicManager.PlaySound(AssetManager.SoundName.ItemPick); } if (item is BlueItem) { blueItemCounter++; MusicManager.PlaySound(AssetManager.SoundName.ItemPick); } if (item is GreenItem) { greenItemCounter++; MusicManager.PlaySound(AssetManager.SoundName.ItemPick); } if (item is ScoreItem) { scoreCounter = scoreCounter - 5; } }
private void UpdateBots(float deltaTime, Map map, List <Vector2i> botPosList) { foreach (Bot it in botList) { it.Update(deltaTime, map, controllid, botPosList); if (!it.isAlive) { deleteList.Add(it); //zerstoere Bot MusicManager.PlaySound(AssetManager.SoundName.DeleteBot); if (it.id == controllid) { controllid = 0; } } else { if (controllid == it.id) //Setzt den Focus auf aktuellen Bot { currentFocus = it.sprite.Position + new Vector2f(it.sprite.Size.X / 2f, it.sprite.Size.Y / 2f); } } Check(it); //Überprüft ob Red,Blue, Green in der Liste ist DestroyBotForPoints(it); } botList.RemoveAll(deleteList.Contains); deleteList = new List <Bot>(); }
public void InitializeTeleport(Transporter porter, bool _blueBotPorting, Vector2i target) { teleporterWaypoints = new List <Vector2>(); teleporting = true; blueBotPorting = _blueBotPorting; Vector2i startPos = (blueBotPorting) ? botList.Find(b => b.id == 2).mapPosition : mapPosition; teleSpritePos = new Vector2(startPos.X * sizePerCell + 0.5f * sizePerCell, startPos.Y * sizePerCell + sizePerCell * 0.5f); if (blueBotPorting) { GraphicHelper.SetAlpha(0, botList.Find(b => b.id == 2).sprite); } else { GraphicHelper.SetAlpha(0, sprite); } if (Math.Abs(target.X - startPos.X) > Math.Abs(target.Y - startPos.Y)) { teleporterWaypoints.Add(new Vector2(target.X * sizePerCell + sizePerCell * 0.5f, startPos.Y * sizePerCell + sizePerCell * 0.5f)); } else { teleporterWaypoints.Add(new Vector2(startPos.X * sizePerCell + sizePerCell * 0.5f, target.Y * sizePerCell + sizePerCell * 0.5f)); } teleporterWaypoints.Add(new Vector2(target.X * sizePerCell + sizePerCell * 0.5f, target.Y * sizePerCell + sizePerCell * 0.5f)); MusicManager.PlaySound(AssetManager.SoundName.Teleport); }
override protected void Execute(Map map, Player player) { foreach (MapManipulation mani in mapManilList) { if (!player.getListOfBotPositions().Contains(mani.position)) { mani.execute(map); } } //An und aus Sounds MusicManager.PlaySound(AssetManager.SoundName.LeverNormal); }
override public void Update(Player player, Map map, float deltaTime) { if (player.getListWithPlayerAndBlueBot().Contains(position)) { if (!active) { Execute(map, player); active = !active; MusicManager.PlaySound(AssetManager.SoundName.BlueLever); } } else { if (active) { Execute(map, player); active = !active; } } }
public void CreateBot() { MusicManager.PlaySound(AssetManager.SoundName.CreateBot); }
public int Update(float deltaTime, ManageStars.Rating rating, int curIndex, List <Tutorial> tutorials) { if (finished) { endAnimation.UpdateFrame(deltaTime); endText.Update(deltaTime); if (KeyboardInputManager.Downward(Keyboard.Key.Space)) { mapStatus = 1; } } else { background = new Sprite(AssetManager.backgroundTextures[0]); background.Position = new Vector2f(0, 0); getBackground(curIndex); mapStatus = 0; playerScore = player.scoreCounter; map.Update(deltaTime, player.keyCounter); player.Update(deltaTime, map); itemList.Update(map, player, deltaTime); trapHandler.Update(map, player, deltaTime); levelution.Update(player, map, deltaTime); transporterHandler.Update(player, deltaTime); checkTutorialNeed(rating, curIndex, tutorials); if (currentTutorial != null) { currentTutorial.Update(deltaTime); } if (KeyboardInputManager.Upward(Keyboard.Key.T)) { return(3); } if (KeyboardInputManager.IsPressed(Keyboard.Key.LShift) && KeyboardInputManager.IsPressed(Keyboard.Key.LControl) && KeyboardInputManager.Upward(Keyboard.Key.Y)) { mapStatus = 1; } if (map.CellIsGoal(player.mapPosition) && player.keyCounter >= keysToUnlock) { endSprite = new Sprite(AssetManager.GetTexture(AssetManager.TextureName.LevelInfo)); endSprite.Position = new Vector2f(450, 220); GraphicHelper.SetAlpha(200, endSprite); SetEndMedal(); endMedal.Position = endSprite.Position + new Vector2f(150, 100); endAnimation = new AnimatedSprite(AssetManager.GetTexture(AssetManager.TextureName.SpaceBar), 0.2f, 3); endAnimation.Position = (Vector2)endSprite.Position + new Vector2(125, 200); endText = new SuperText("Congratulations", FontLoader.Instance.LoadFont("Assets/Fonts/fixedsys.ttf"), 0.1f); MusicManager.PlaySound(AssetManager.SoundName.Winning); endText.Position = (Vector2)endSprite.Position + new Vector2(20, 25); endText.CharacterSize = 40; finished = true; addScoreFromBots(); CheckLevel(); Logger.Instance.Write("\n" + "Rating: " + playerScore + "\n" + "Bronze: " + ratingNumbers[0] + "\n" + "Silber: " + ratingNumbers[1] + "\n" + "Gold: " + ratingNumbers[2] + "\n" + "Sie haben " + CheckLevel() + " erreicht", Logger.level.Info); } if (KeyboardInputManager.Upward(Keyboard.Key.Back)) { MusicManager.StopSound(); foreach (Tutorial tut in tutorials) { if (tut.index == curIndex) { tut.shown = false; } } mapStatus = 2; } guiLevelNumber.DisplayedString = "" + (curIndex + 1); } return(mapStatus); }
public GameState Update(RenderWindow win, float deltaTime) { gameName.Update(deltaTime); foreach (Button b in buttonList) { b.Update(deltaTime, win, currentScreenPosition); } UpdateButtonAlphas(); if (stopwatch1.ElapsedMilliseconds > 200) { int index = -1; debugRect.Position = new Vector2f(-1000, -1000); // moves this out of the picture... if (settingNewProfile) { List <char> charList = KeyboardInputManager.getCharInput(); if (newProfileName && KeyboardInputManager.getCharInput().Count > 0) { currentInput = ""; newProfileName = false; } foreach (char c in charList) { if (currentInput.Length <= 16) { currentInput += c; } } if (KeyboardInputManager.Downward(Keyboard.Key.Back)) { if (currentInput != "") { currentInput = currentInput.Remove(currentInput.Length - 1); } } UpdateSelectedProfileText(currentInput, deltaTime); if ((KeyboardInputManager.IsPressed(Keyboard.Key.Escape) || Mouse.IsButtonPressed(Mouse.Button.Left)) && settingNewProfile) { settingNewProfile = false; stopwatch.Restart(); UpdateActiveProfileText(); return(GameState.MainMenu); } if (KeyboardInputManager.Downward(Keyboard.Key.Return)) { if (currentInput != "" && currentInput != "[Enter Name]" && profiles.GetProfileNames().Contains(currentInput) == false) { profiles.setProfile(currentInput, ProfileConstants.activeProfile); settingNewProfile = false; UpdateActiveProfileText(); return(GameState.LoadLevelState); } else { Logger.Instance.Write("ProfileName cannot be empty", Logger.level.Info); } } } else if (KeyboardInputManager.Downward(Keyboard.Key.Up) || KeyboardInputManager.Downward(Keyboard.Key.Down) || KeyboardInputManager.Downward(Keyboard.Key.Right) || KeyboardInputManager.Downward(Keyboard.Key.Left)) { bool soundactiv = false; if (KeyboardInputManager.Downward(Keyboard.Key.Up) && currentScreenPosition.Y > 0) { soundactiv = true; currentScreenPosition.Y -= 1; if (currentScreenPosition.X == 2) { currentScreenPosition.X = 1; } else if (currentScreenPosition.X == 1 && currentScreenPosition.Y == 2) { currentScreenPosition.X = 0; } } if (KeyboardInputManager.Downward(Keyboard.Key.Down) && currentScreenPosition.Y < 3) { soundactiv = true; currentScreenPosition.Y += 1; if (currentScreenPosition.Y == 3 && currentScreenPosition.X == 1) { currentScreenPosition.X = 2; } } if (KeyboardInputManager.Downward(Keyboard.Key.Right) && currentScreenPosition.X < 1) { soundactiv = true; currentScreenPosition.X += 1; } else if (KeyboardInputManager.Downward(Keyboard.Key.Right) && currentScreenPosition.X < 3 && currentScreenPosition.Y == 3) { soundactiv = true; currentScreenPosition.X = 2; } if (KeyboardInputManager.Downward(Keyboard.Key.Left) && currentScreenPosition.X > 0) { soundactiv = true; currentScreenPosition.X -= 1; } if (soundactiv) { MusicManager.PlaySound(AssetManager.SoundName.MenueClick); } else { MusicManager.PlaySound(AssetManager.SoundName.Wall); } } else if (KeyboardInputManager.Downward(Keyboard.Key.Return)) //Wurde die LinkeMaustaste gedrückt? { //Console.WriteLine("Der Index in der SwitchAnweisung: " + index); switch (IndexFromScreenPos()) //Bin mit der Maus über den Index: SwitchCaseWeg { //bearbeitet das aktuelle TextFeld //start case 0: ProfileConstants.activeProfile = MemoryMaze.profiles.one; if (profiles.ProfileExists(MemoryMaze.profiles.one)) { return(GameState.LoadLevelState); } else { currentInput = "[Enter Name]"; settingNewProfile = true; newProfileName = true; return(GameState.MainMenu); } case 3: profiles.deleteProfile(MemoryMaze.profiles.one); UpdateProfilePercentage(); break; case 1: ProfileConstants.activeProfile = MemoryMaze.profiles.two; if (profiles.ProfileExists(MemoryMaze.profiles.two)) { return(GameState.LoadLevelState); } else { currentInput = "[Enter Name]"; settingNewProfile = true; newProfileName = true; return(GameState.MainMenu); } case 4: profiles.deleteProfile(MemoryMaze.profiles.two); UpdateProfilePercentage(); break; case 2: ProfileConstants.activeProfile = MemoryMaze.profiles.three; if (profiles.ProfileExists(MemoryMaze.profiles.three)) { return(GameState.LoadLevelState); } else { currentInput = "[Enter Name]"; settingNewProfile = true; newProfileName = true; return(GameState.MainMenu); } case 5: profiles.deleteProfile(MemoryMaze.profiles.three); UpdateProfilePercentage(); break; case 6: return(GameState.Tutorial); case 7: return(GameState.Credits); case 8: profiles.saveManageProfiles(); return(GameState.None); case 9: funactivJoh = true; stopwatch.Restart(); break; default: break; } } } if (!settingNewProfile) { UpdateAllProfilesTexts(); } UpdateMainTitle(deltaTime); foreach (SuperText s in superTextList) { s.Update(deltaTime); } return(GameState.MainMenu); }
public GameState Update(RenderWindow win, float deltaTime) { int index = -1; lastScreen.Update(deltaTime); nextScreen.Update(deltaTime); foreach (LevelSelectButton l in mainButtonList) { l.Update(deltaTime, win, currentScreenPosition); } SetCurrentLevelInfo(); levelInfo.Update(deltaTime, currentScreenPosition); leftButton.Update(deltaTime, win, currentScreenPosition); rightButton.Update(deltaTime, win, currentScreenPosition); if (stopwatch.ElapsedMilliseconds > 500) { if (Keyboard.IsKeyPressed(Keyboard.Key.Escape)) { stars.lastSelectedLevel = currentLevel; stars.saveManageStars(profiles.getActiveProfileName()); return(GameState.MainMenu); } if (sliding) { SlideMap(deltaTime); return(GameState.LoadLevelState); } bool soundactiv = false; if (KeyboardInputManager.Downward(Keyboard.Key.Up) || KeyboardInputManager.Downward(Keyboard.Key.Down)) { int bottomLength = 1; if (KeyboardInputManager.Downward(Keyboard.Key.Up) && currentScreenPosition.Y != 0) { soundactiv = true; currentScreenPosition.Y = 0; currentScreenPosition.X = GetPositionOnCurrentLevelScreen(); } if (KeyboardInputManager.Downward(Keyboard.Key.Down) && currentScreenPosition.Y != 1) { soundactiv = true; currentScreenPosition.Y = 1; float help = (float)currentScreenPosition.X * (float)bottomLength / (float)(mainButtonList.Count - 1); currentScreenPosition.X = (int)Math.Round(help); } } if ((KeyboardInputManager.Downward(Keyboard.Key.Left) || KeyboardInputManager.Downward(Keyboard.Key.Right)) & currentScreenPosition.Y == 1) { int bottomLength = 1; if (KeyboardInputManager.Downward(Keyboard.Key.Right) && currentScreenPosition.X < bottomLength) { soundactiv = true; currentScreenPosition.X += 1; } if (KeyboardInputManager.Downward(Keyboard.Key.Left) && currentScreenPosition.X > 0) { soundactiv = true; currentScreenPosition.X -= 1; } } if ((KeyboardInputManager.Downward(Keyboard.Key.Left) || KeyboardInputManager.Downward(Keyboard.Key.Right)) && currentScreenPosition.Y == 0) { if (KeyboardInputManager.Downward(Keyboard.Key.Left)) { if (currentLevel > 0) { soundactiv = true; currentLevel--; currentScreenPosition.X -= 1; if (currentScreenPosition.X < 0) { InitiateSlide(false); currentScreenPosition.X = GetPositionOnCurrentLevelScreen(); } } } else { if (stars.levelIsUnlocked(currentLevel + 1)) { soundactiv = true; currentLevel++; currentScreenPosition.X = GetPositionOnCurrentLevelScreen(); if (GetPositionOnCurrentLevelScreen() == 0) { InitiateSlide(true); } } } if (soundactiv) { MusicManager.PlaySound(AssetManager.SoundName.MenueClick); } else if (KeyboardInputManager.Downward(Keyboard.Key.Up) || KeyboardInputManager.Downward(Keyboard.Key.Down) || KeyboardInputManager.Downward(Keyboard.Key.Right) || KeyboardInputManager.Downward(Keyboard.Key.Left)) { MusicManager.PlaySound(AssetManager.SoundName.Wall); } return(GameState.LoadLevelState); } if (soundactiv) { MusicManager.PlaySound(AssetManager.SoundName.MenueClick); } else if (KeyboardInputManager.Downward(Keyboard.Key.Up) || KeyboardInputManager.Downward(Keyboard.Key.Down) || KeyboardInputManager.Downward(Keyboard.Key.Right) || KeyboardInputManager.Downward(Keyboard.Key.Left)) { MusicManager.PlaySound(AssetManager.SoundName.Wall); } if (KeyboardInputManager.Downward(Keyboard.Key.Return) && currentScreenPosition.Y == 0) { return(StartLevelIfUnlocked()); } if (KeyboardInputManager.Downward(Keyboard.Key.Return) && currentScreenPosition.Y == 1) //Wurde die LinkeMaustaste gedrückt? { switch (currentScreenPosition.X) //Bin mit der Maus über den Index: SwitchCaseWeg { //bearbeitet das aktuelle TextFeld // case 0: CanSlide(false); return(GameState.LoadLevelState); case 1: CanSlide(true); return(GameState.LoadLevelState); default: return(GameState.LoadLevelState); } } else { if (index != -1) { IntRect curRect = rectList[index]; debugRect.Position = new Vector2f(curRect.Left, curRect.Top); debugRect.Size = new Vector2f(curRect.Width, curRect.Height); debugRect.FillColor = Color.Cyan; } } } return(GameState.LoadLevelState); }
public void Update(float deltaTime, Map map) { if (teleporting) { UpdateBots(deltaTime, map, getListOfBotPositions()); UpdateSpritePosition(map); Teleporting(deltaTime); currentFocus = teleSpritePos; } else if (isAlive == true) { if (controllid != 0) { SwitchToGhostPlayer(); } UpdateBots(deltaTime, map, getListOfBotPositions()); if (KeyboardInputManager.Downward(Keyboard.Key.Space)) { ghostaktiv = true; } if (iserstellt) { ghostPlayer.Update(deltaTime, map, this); currentFocus = new Vector2(ghostPlayer.mapPosition.X * sizePerCell + sizePerCell * 0.5f, ghostPlayer.mapPosition.Y * sizePerCell + sizePerCell * 0.5f); UpdateSpritePosition(map); } else { if (id == controllid) { Vector2i move = GetMove(); if (map.CellIsWalkable(mapPosition + move)) { mapPosition = mapPosition + move; if (move.X != 0 || move.Y != 0) //ProSchritt wird der Counter um 1 erhöht { scoreCounter++; } } else if (map.MoveIsPossible(mapPosition, move, this.getListOfBotPositions())) { map.MoveBlock(mapPosition, move); mapPosition = mapPosition + move; scoreCounter++; } else { MusicManager.PlaySound(AssetManager.SoundName.Wall); } UpdateSpritePosition(map); currentFocus = sprite.Position + new Vector2f(sprite.Size.X / 2f, sprite.Size.Y / 2f); } } //Create GhostPlayer if (ghostaktiv && (!iserstellt) && controllid == 0) { ghostPlayer = new GhostPlayer(mapPosition, map); iserstellt = true; } if (!ghostaktiv) { ghostPlayer = null; iserstellt = false; } //Destroy GhostPlayer else if (KeyboardInputManager.Upward(Keyboard.Key.Space) || iserstellt && ghostPlayer.GetCount() == 0) { ghostPlayer = null; ghostaktiv = false; iserstellt = false; } //Target controll manager SwitchTarget(); UpdateSpritePosition(map); } else { //SPieler ist tod if (!_musicPlayed) { MusicManager.PlaySound(AssetManager.SoundName.VirusDetected); _musicPlayed = true; } playerdetected.Position = new Vector2f(235, 200); playerdetected.Color = Color.Red; playerdetected.Style = Text.Styles.Bold; restartGame.Position = new Vector2f(285, 350); restartGame.Color = Color.Red; restartGame.Style = Text.Styles.Bold; } }