public static Vector2 CenterCamera(float tempX, float tempY) { if (SelectionUtility.HasMemberSelected()) { Vector2 centerOfScreen = new Vector2(1366 / 2 - SelectionUtility.primarySelectedCharacter.proximityIndicator.Width / 2, 768 / 2 - SelectionUtility.primarySelectedCharacter.proximityIndicator.Height / 2); int x = (int)(SelectionUtility.primarySelectedCharacter.position.X + SceneUtility.xAxis - centerOfScreen.X); int y = (int)(SelectionUtility.primarySelectedCharacter.position.Y + SceneUtility.yAxis - centerOfScreen.Y); SceneUtility.xAxis -= x; SceneUtility.yAxis -= y; tempX = SceneUtility.xAxis; tempY = SceneUtility.yAxis; return(new Vector2(tempX, tempY)); } return(new Vector2(tempX, tempY)); }
/// <summary> /// Handles general functionality, use CommandUpdate(Paused) for character controll /// </summary> /// <param name="gameTime"></param> private void NormalRunUpdate(GameTime gameTime) { if (buttonPressUtility.isPressed(Game1.openMenuString)) { if (!bShowPopUp) { bShowPopUp = true; KeyboardMouseUtility.bPressed = true; currentPauseChoice = 0; } } if (buttonPressUtility.isPressed(Game1.confirmString) && !KeyboardMouseUtility.AnyButtonsPressed()) { bFriendlyFire = !bFriendlyFire; foreach (var item in activeObjects) { item.bFriendlyFire = bFriendlyFire; } } if (SelectionUtility.HasMemberSelected()) { HandleHotBarKeys(gameTime); } if (buttonPressUtility.isPressedSub(Game1.moveUpString) && !KeyboardMouseUtility.AnyButtonsPressed()) { } //if (buttonPressUtility.isPressedSub(Game1.cameraMoveCenterString)) //{ // Vector2 tempVec = SceneUtility.CenterCamera(xAxis,yAxis); // xAxis = tempVec.X; // yAxis = tempVec.Y; //} if (buttonPressUtility.isPressedSub(Game1.moveLeftString) && !KeyboardMouseUtility.AnyButtonsPressed()) { /* * enemies.Add(new BasicEnemy(game.Content.Load<Texture2D>(@"Graphics\Characters\Hostile\BasicEnemy"), 1, CursorUtility.trueCursorPos, true)); * activeObjects.Clear(); * activeObjects.AddRange(enemies); * activeObjects.AddRange(heroes); */ } if (buttonPressUtility.isPressedSub(Game1.moveRightString) && !KeyboardMouseUtility.AnyButtonsPressed()) { /* * heroes.Add(new BasicHero(game.Content.Load<Texture2D>(@"Graphics\Characters\Friendly\BasicHero"), 1, CursorUtility.trueCursorPos, true)); * activeObjects.Clear(); * activeObjects.AddRange(enemies); * activeObjects.AddRange(heroes); */ } if (buttonPressUtility.isPressedSub(Game1.pauseString) && !KeyboardMouseUtility.AnyButtonsPressed()) { bPaused = true; KeyboardMouseUtility.bPressed = true; } if (buttonPressUtility.isPressedSub(Game1.debugInfoString) && !KeyboardMouseUtility.AnyButtonsPressed()) { if (SceneUtility.isWithinMap(CursorUtility.trueCursorPos)) { switch (tempH) { case 0: heroes.Add(new BasicHero(CharacterAssetsLoader.heroAssetsC1[(int)CharacterAssetsLoader.heroesC1.hero1], 1, CursorUtility.trueCursorPos, true)); heroes[heroes.Count - 1].rectangleToDraw = CharacterAssetsLoader.heroAssetsC1[(int)CharacterAssetsLoader.heroesC1.hero1].shapeTextureBounds; BasicTeamUtility.parties[(int)BasicTeamUtility.FriendlyParties.Party].Add(heroes[heroes.Count - 1]); activeObjects.Clear(); activeObjects.AddRange(enemies); activeObjects.AddRange(heroes); break; case 1: heroes.Add(new BasicHero(CharacterAssetsLoader.heroAssetsC1[(int)CharacterAssetsLoader.heroesC1.hero2], 1, CursorUtility.trueCursorPos, true)); heroes[heroes.Count - 1].rectangleToDraw = CharacterAssetsLoader.heroAssetsC1[(int)CharacterAssetsLoader.heroesC1.hero2].shapeTextureBounds; BasicTeamUtility.parties[(int)BasicTeamUtility.FriendlyParties.Party].Add(heroes[heroes.Count - 1]); heroes[heroes.Count - 1].stats.baseStats[(int)BasicStatChart.stats.MaxHealth] = 200; heroes[heroes.Count - 1].stats.baseStats[(int)BasicStatChart.stats.Health] = 200; heroes[heroes.Count - 1].stats.baseStats[(int)BasicStatChart.stats.MaxMana] = 30; heroes[heroes.Count - 1].stats.baseStats[(int)BasicStatChart.stats.Mana] = 30; heroes[heroes.Count - 1].stats.ResetCurrentStats(); heroes[heroes.Count - 1].activeSpells = new Spell[9] { SpellsAssetLoader.basicMissileFire, SpellsAssetLoader.basicMissileIce, default(Spell), default(Spell), default(Spell), default(Spell), default(Spell), default(Spell), default(Spell) }; activeObjects.Clear(); activeObjects.AddRange(enemies); activeObjects.AddRange(heroes); break; case 2: heroes.Add(new BasicHero(CharacterAssetsLoader.heroAssetsC1[(int)CharacterAssetsLoader.heroesC1.hero3], 1, CursorUtility.trueCursorPos, true)); heroes[heroes.Count - 1].rectangleToDraw = CharacterAssetsLoader.heroAssetsC1[(int)CharacterAssetsLoader.heroesC1.hero3].shapeTextureBounds; BasicTeamUtility.parties[(int)BasicTeamUtility.FriendlyParties.Party].Add(heroes[heroes.Count - 1]); heroes[heroes.Count - 1].stats.baseStats[(int)BasicStatChart.stats.MaxHealth] = 450; heroes[heroes.Count - 1].stats.baseStats[(int)BasicStatChart.stats.Health] = 450; heroes[heroes.Count - 1].stats.baseStats[(int)BasicStatChart.stats.MaxMana] = 0; heroes[heroes.Count - 1].stats.baseStats[(int)BasicStatChart.stats.Mana] = 0; heroes[heroes.Count - 1].stats.ResetCurrentStats(); heroes[heroes.Count - 1].activeSpells = new Spell[9] { SpellsAssetLoader.basicMissileGrass, SpellsAssetLoader.basicMissileArcane, default(Spell), default(Spell), default(Spell), default(Spell), default(Spell), default(Spell), default(Spell) }; activeObjects.Clear(); activeObjects.AddRange(enemies); activeObjects.AddRange(heroes); break; case 3: heroes.Add(new BasicHero(CharacterAssetsLoader.heroAssetsC1[(int)CharacterAssetsLoader.heroesC1.hero4], 1, CursorUtility.trueCursorPos, true)); heroes[heroes.Count - 1].rectangleToDraw = CharacterAssetsLoader.heroAssetsC1[(int)CharacterAssetsLoader.heroesC1.hero4].shapeTextureBounds; BasicTeamUtility.parties[(int)BasicTeamUtility.FriendlyParties.Party].Add(heroes[heroes.Count - 1]); heroes[heroes.Count - 1].stats.baseStats[(int)BasicStatChart.stats.MaxHealth] = 75; heroes[heroes.Count - 1].stats.baseStats[(int)BasicStatChart.stats.Health] = 75; heroes[heroes.Count - 1].stats.baseStats[(int)BasicStatChart.stats.MaxMana] = 200; heroes[heroes.Count - 1].stats.baseStats[(int)BasicStatChart.stats.Mana] = 200; heroes[heroes.Count - 1].stats.ResetCurrentStats(); heroes[heroes.Count - 1].activeSpells = new Spell[9] { SpellsAssetLoader.basicMissileDark, default(Spell), default(Spell), default(Spell), default(Spell), default(Spell), default(Spell), default(Spell), default(Spell) }; activeObjects.Clear(); activeObjects.AddRange(enemies); activeObjects.AddRange(heroes); break; } tempH++; } } foreach (var character in activeObjects) { character.Update(gameTime, activeObjects); character.bFriendlyFire = bFriendlyFire; } foreach (var character in activeObjects) { if (!character.bHasTarget) { if (character.GetType() == typeof(BasicEnemy) && heroes.Count != 0) { character.setTarget(heroes[heroes.Count - 1]); } else if (character.GetType() == typeof(BasicHero) && enemies.Count != 0) { character.setTarget(enemies[enemies.Count - 1]); } } } ClearNotRenderedActiveObjects(); ClearNotRenderedShapeObjects(); }
//************************ public override void Update(GameTime gameTime, Game1 game) { bool bHasTarget = SelectionUtility.HasMemberSelected(); if (!bShowPopUp && !bPaused) { base.Update(gameTime, game); CameraUpdate(); NormalRunUpdate(gameTime); if (bHasTarget) { CommandUpdate(); } SelectionUtility.Update(gameTime, activeObjects); MainGUI.Update(gameTime); } if (bShowPopUp && !bPaused) { ButtonControlPopUp(gameTime); } if (bPaused && !bShowPopUp) { SelectionUtility.Update(gameTime, activeObjects); MainGUI.Update(gameTime); PauseRunUpdate(); CameraUpdate(); if (bHasTarget) { CommandUpdatePaused(); } } if (bPaused && bShowPopUp) { ButtonControlPopUp(gameTime); } SceneUtility.xAxis = xAxis; SceneUtility.yAxis = yAxis; activeSceneObjects.Clear(); activeSceneObjects.AddRange(shapes); activeSceneObjects.AddRange(enemies); activeSceneObjects.AddRange(heroes); activeSceneShapeCollections.Clear(); activeSceneShapeCollections.Add(new IdentifiableShapeList("All Characters List", activeObjects)); activeSceneButtonCollections.Clear(); activeSceneButtonCollections.Add(new IdentifiableShapeList("Pop-up buttons List", pauseScreen.popUpButtons)); activeSceneCharactersCollections.Clear(); activeSceneCharactersCollections.Add(new IdentifiableShapeList("Enemies List", enemies)); activeSceneCharactersCollections.Add(new IdentifiableShapeList("Heroes List", heroes)); }