public static void Update() { CombatCtrl.selectedChar = selectedChar; if (Mouse.GetState().LeftButton == ButtonState.Pressed && !KeyboardMouseUtility.AnyButtonsPressed()) { selectedChar = CombatProcessor.heroCharacters.Find(c => c.spriteGameSize.Contains(GameProcessor.EditorCursorPos)); secondaryChar = null; } if (selectedChar != null) { if (Mouse.GetState().RightButton == ButtonState.Pressed && !KeyboardMouseUtility.AnyButtonsPressed()) { secondaryChar = CombatProcessor.heroCharacters.Find(c => c.spriteGameSize.Contains(GameProcessor.EditorCursorPos)); Vector2 temp = new Vector2(-1); if (availableTiles.Find(t => t.mapPosition.Contains(GameProcessor.EditorCursorPos)) != null) { temp = (GameProcessor.EditorCursorPos / 64).ToPoint().ToVector2() * 64; } if (secondaryChar != null) { temp = secondaryChar.position; } if (temp != new Vector2(-1)) { /* * if (secondaryChar != null) * { * secondaryChar.position = selectedChar.position; * } * * selectedChar.position = temp;*/ if (CombatProcessor.zone.Contains(GameProcessor.EditorCursorPos) && !PathMoveHandler.bIsBusy) { // allPossibleNodes = PathFinder.NewPathSearch(PlayerController.selectedSprite.position, GameProcessor.EditorCursorPos, zoneTiles); CombatProcessor.allPossibleNodes = PathFinder.NewPathSearch(selectedChar.position, GameProcessor.EditorCursorPos, CombatProcessor.radiusTiles); PathMoveHandler.Start(selectedChar, CombatProcessor.allPossibleNodes); } else if (CombatProcessor.zone.Contains(GameProcessor.EditorCursorPos) && PathMoveHandler.bIsBusy) { PathMoveHandler.SkipPathMovement(); CombatProcessor.allPossibleNodes = PathFinder.NewPathSearch(selectedChar.position, GameProcessor.EditorCursorPos, CombatProcessor.radiusTiles); PathMoveHandler.Start(selectedChar, CombatProcessor.allPossibleNodes); } } } } }
public void RightButtonPlayerAction() { if (selectedCharTurn != null && !selectedCharTurn.bIsCompleted) { BaseCharacter selectedChar = selectedCharTurn.character; #region Right Button Logic Vector2 temp = new Vector2(-1); if (selectedCharTurn.returnCompleteArea().Find(t => t.mapPosition.Contains(GameProcessor.EditorCursorPos)) != null) { temp = (GameProcessor.EditorCursorPos / 64).ToPoint().ToVector2() * 64; } if (temp != new Vector2(-1)) // if (temp != new Vector2(-1) && !selectedChar.spriteGameSize.Contains(temp)) { if (CombatProcessor.zone.Contains(GameProcessor.EditorCursorPos) && !PathMoveHandler.bIsBusy) { CombatProcessor.allPossibleNodes = PathFinder.NewPathSearch(selectedChar.position, GameProcessor.EditorCursorPos, selectedCharTurn.returnCompleteArea()); PathMoveHandler.Start(selectedChar, CombatProcessor.allPossibleNodes); bPlayerMustSelectAction = true; BattleGUI.InitializePopUpMenu(); //FinalizeCharacterRound(); } else if (CombatProcessor.zone.Contains(GameProcessor.EditorCursorPos) && PathMoveHandler.bIsBusy) { PathMoveHandler.SkipPathMovement(); CombatProcessor.allPossibleNodes = PathFinder.NewPathSearch(selectedChar.position, GameProcessor.EditorCursorPos, selectedCharTurn.returnCompleteArea()); PathMoveHandler.Start(selectedChar, CombatProcessor.allPossibleNodes); } } #endregion } if (selectedCharTurn == null) { foreach (var item in CombatProcessor.zoneTiles) { if (item.mapPosition.Contains(KeyboardMouseUtility.gameMousePos)) { GameProcessor.GenerateCameraInstant(KeyboardMouseUtility.gameMousePos, 3, GameProcessor.zoom); } } } }
internal void UpdateEnemyLogic(CharacterTurn gts) { if (!PathMoveHandler.bIsBusy) { PathMoveHandler.SkipPathMovement(); } if (gts != null && !LUA.LuaExecutionList.DemandOverride() && !PathMoveHandler.bIsBusy && !bTest && BattleGUI.TurnEffectsList.Find(te => te.bMustShow) == null) { if (bPlayerTurnEnemyOverriden) { gts = currentEnemy; } if (GameProcessor.cameraFollowTarget != gts.character) { GameProcessor.cameraFollowTarget = gts.character; } bTest = true; //randomEnemy = GamePlayUtility.Randomize(0, CombatProcessor.heroCharacters.Count - 1); selectedCharTurn = null; currentEnemy = gts; AIUtility.AIPreCalculate(gts.returnCompleteArea(), gts); //AIUtility.Report(AIBehaviour.ProcessBehaviour(currentEnemy.character,AIUtility.possibleAITargets)); BaseCharacter target = null; var temp = AIBehaviour.ProcessBehaviour(currentEnemy.character, AIUtility.possibleAITargets); if (temp.Count != 0) { target = AIUtility.SelectTargetBasedOnBehaviour(temp); } var playableMap = GameProcessor.loadedMap.possibleTilesGameZoneForEnemy(CombatProcessor.zoneTiles, currentEnemy.character); var beep = new KeyValuePair <List <List <BasicTile> >, List <BasicAbility> >(); if (target != null) { // var beep = AIUtility.returnTilesToAttackFrom(CombatProcessor.zoneTiles,gts.character,target); beep = AIUtility.returnTilesToAttackFrom(gts.returnCompleteArea(), playableMap, gts.character, target); while (beep.Key.Count == 0 && beep.Value.Count == 0 && AIUtility.possibleAITargets.Count - 1 > 0) { AIUtility.possibleAITargets.Remove(target); target = AIUtility.SelectTargetBasedOnBehaviour(AIBehaviour.ProcessBehaviour(currentEnemy.character, AIUtility.possibleAITargets)); beep = AIUtility.returnTilesToAttackFrom(playableMap, playableMap, gts.character, target); } } if (target != null && beep.Key.Count == 0 && beep.Value.Count == 0) { target = null; } gts.ReGenerateTurn(playableMap); List <Node> allPossibleNodes; if (target != null) { //allPossibleNodes = PathFinder.NewPathSearch(gts.character.position, target.position + new Vector2(64, 0), playableMap); var enemyFavor = AIUtility.returnFavoredAttackAndPosition(beep, gts.character, target); if (enemyFavor.Key != null) { allPossibleNodes = PathFinder.NewPathSearch(gts.character.position, enemyFavor.Key.mapPosition.Location.ToVector2(), playableMap); } else { allPossibleNodes = null; } AITarget = target; AIbtba = enemyFavor; } else { List <int> amountOfCharsForEachGroup = new List <int>(); List <float> percentagesForEachGroup = new List <float>(); int totalChars = 0; foreach (var item in gts.parentTS.targetGroups) { int tempCount = item.charactersInGroup.FindAll(c => c.IsAlive()).Count; totalChars += tempCount; amountOfCharsForEachGroup.Add(tempCount); } foreach (var item in amountOfCharsForEachGroup) { percentagesForEachGroup.Add(((float)item / (float)totalChars) * 100); } TurnSet targetGroup = null; int tempIndex = 0; while (targetGroup == null) { int randomNumber = GamePlayUtility.Randomize(0, 100); if (percentagesForEachGroup[tempIndex] >= randomNumber) { targetGroup = targetGroups[tempIndex]; } tempIndex++; if (tempIndex > percentagesForEachGroup.Count) { targetGroup = targetGroups[0]; } } BaseCharacter randomCharacter = targetGroup.charactersInGroup.FindAll(c => c.IsAlive())[GamePlayUtility.Randomize(0, targetGroup.charactersInGroup.FindAll(c => c.IsAlive()).Count)]; allPossibleNodes = PathFinder.NewPathSearch(gts.character.position, randomCharacter.position + new Vector2(64, 0), playableMap); } if (allPossibleNodes != null) { CombatProcessor.what = new List <Node>(allPossibleNodes); var NodesWithinRange = MapListUtility.findEqualNodesToTileList(allPossibleNodes, gts.returnCompleteArea()); PathMoveHandler.Start(gts.character, NodesWithinRange); } //FinalizeEnemyRound(); } if (gts != null && !PathMoveHandler.bIsBusy && bTest && !GameProcessor.bStartCombatZoom) { //THIS IS THE VERY LAST LINE BEFORE AN ENEMY HAS IT'S TURN COMPLETED if (!AIbtba.Equals(default(KeyValuePair <BasicTile, BasicAbility>))) { if ((AIbtba.Key == null || AIbtba.Key.mapPosition.Location.ToVector2() == gts.character.position) && AIbtba.Value.abilityCanHitTargetInRange(gts.character, AITarget) && AIbtba.Value.IsAbilityAvailable(gts.character.trueSTATChart())) { FaceCharacterInCorrectDirection(gts.character, AITarget); GameProcessor.StartBattleSoon(gts.character, AITarget, gts.character.AbilityList().IndexOf(AIbtba.Value)); //GameProcessor.StartBattleSoon(gts.character, AITarget, gts.character.AbilityList().IndexOf(gts.character.AbilityList().Find(ba => ba.abilityName.Equals(AIbtba.Value.abilityName)))); } else { if (!currentEnemy.character.attackedAsAI) { LastDitchEffortAttack(); } else { FinalizeEnemyRound(); } } } else { if (!currentEnemy.character.attackedAsAI) { LastDitchEffortAttack(); } else { FinalizeEnemyRound(); } } // } else if (gts == null) { if (bPlayerTurnEnemyOverriden) { bPlayerTurnEnemyOverriden = false; } } }