static public void Update(GameTime gt)
        {
            bBattleWon = objective.ObjectiveReached(encounterGroups);
            bIsRunning = bBattleWon;

            if (EncounterObjective.Lost(objective))
            {
                CombatProcessor.bLostBattle = true;
            }


            if (bBattleWon && !CombatProcessor.bAfterBattleScreen)
            {
                CombatProcessor.InitiateVictory();
            }
            else if (!bBattleWon)
            {
                LUA.LuaBScriptEvent.msTime = gt.ElapsedGameTime.Milliseconds;
                if (bGenerateLuaTurnInfo)
                {
                    turnSetInfo          = currentTurn().toLuaTurnSetInfo();
                    bGenerateLuaTurnInfo = false;
                }
                BattleScriptHandler.Execute(LUA.LuaBScriptEvent.EventType.updateEV, turnSetInfo);
                encounterGroups[currentGroupIndex].Update();
            }
        }
Beispiel #2
0
        public static bool Initialize(LuaScriptBattle lsb)
        {
            MapRegion mr = GameProcessor.loadedMap.mapRegions.Find(r => r.regionID == lsb.regionID);

            if (mr == null)
            {
                return(false);
            }
            MapZone mz = mr.regionZones.Find(z => z.zoneID == lsb.zoneID);

            if (mz == null)
            {
                return(false);
            }

            List <BasicTile> zoneTiles = new List <BasicTile>();

            TBAGW.Utilities.Sprite.BaseSprite controller = TBAGW.Utilities.Control.Player.PlayerController.selectedSprite;
            controller.position = new Vector2(((int)lsb.partySpawn.x) * 64, ((int)lsb.partySpawn.y) * 64);
            controller.spriteGameSize.Location = controller.position.ToPoint();
            controller.UpdatePosition();

            if (mz.zoneTiles.Count == 0)
            {
                zoneTiles    = GameProcessor.loadedMap.possibleTilesWithController(mz.returnBoundingZone(), TBAGW.Utilities.Control.Player.PlayerController.selectedSprite);
                mz.zoneTiles = zoneTiles;
            }
            else
            {
                zoneTiles = mz.zoneTiles;
            }

            var temp_loc = MapListUtility.returnMapRadius(2, zoneTiles, controller);

            //LUA.LuaScriptBattle.Initialize(lsb);
            foreach (var item in lsb.enemies)
            {
                item.ToEnemy(mz, temp_loc);
            }

            GameProcessor.EnableCombatStage();
            GameProcessor.mainControllerBeforeCombat = TBAGW.Utilities.Control.Player.PlayerController.selectedSprite;
            CombatProcessor.InitializeFromScript(new Vector2(lsb.partySpawn.x, lsb.partySpawn.y), mr, mz, lsb);

            return(true);
        }
        public SuperAdventure()
        {
            InitializeComponent();

            _questMessager   = new QuestMessager(this);
            _questProcessor  = new QuestProcessor(this);
            _combatMessager  = new CombatMessager(this);
            _combatProcessor = new CombatProcessor(this);
            player           = new Player(20, 1, 0, 1, 1, 1, 0, 10, 10);
            _charStatistics  = new CharacterStatistics(this);
            MoveTo(World.LocationByID(World.LOCATION_ID_HOME));
            SetInventoryUI();
            UpdatePlayerStats();
            dgvInventory.MouseWheel += new MouseEventHandler(dgvInventory_MouseWheel);
            dgvQuests.MouseWheel    += new MouseEventHandler(dgvQuests_MouseWheel);
            this.Move   += new EventHandler(MoveSubForm);
            this.Resize += new EventHandler(MoveSubForm);

            labelHitPoints.DataBindings.Add("Text", player, "CurrentHitPoints");
            labelLevel.DataBindings.Add("Text", player, "Level");
            labelGold.DataBindings.Add("Text", player, "Gold");
        }
 public void Setup()
 {
     cp = new CombatProcessor(new Hunter());
 }
 static public void Stop()
 {
     PlayerController.currentController = PlayerController.Controllers.NonCombat;
     CombatProcessor.LeaveCombat();
 }
        private static void SpriteSelectedControls(ActionKey key)
        {
            if (BattleGUI.bIsRunning && EncounterInfo.currentTurn().bIsPlayerTurnSet&& !EncounterInfo.currentTurn().bPlayerTurnEnemyOverriden)
            {
                //if (key.actionIndentifierString.Equals(Game1.confirmString) && !KeyboardMouseUtility.AnyButtonsPressed() && !BattleGUI.bChooseAbility && !BattleGUI.bIsAttacking)
                //{
                //    BattleGUI.bChooseAbility = true;
                //}


                if (!BattleGUI.bChooseAbility && BattleGUI.bIsAttacking && (key.actionIndentifierString.Equals(Game1.confirmString) || key.actionIndentifierString.Equals(Game1.openMenuString)) && !KeyboardMouseUtility.AnyButtonsPressed())
                {
                    EncounterInfo.currentTurn().FinalizeCharacterRound();

                    BattleGUI.End();
                }

                if ((key.actionIndentifierString.Equals(Game1.confirmString) || key.actionIndentifierString.Equals(Game1.openMenuString)) && !KeyboardMouseUtility.AnyButtonsPressed() && BattleGUI.ExecutableAbilitySelected() && BattleGUI.bChooseAbility)
                {
                    BattleGUI.PlayerChoiceMade();
                    // BattleGUI.bStartZoom = true;
                }

                if (!BattleGUI.bChooseAbility && key.actionIndentifierString.Equals(Game1.confirmString) && !BattleGUI.bIsAttacking && !KeyboardMouseUtility.AnyButtonsPressed() && BattleGUI.ExecutableAbilitySelected() && !BattleGUI.bChooseAbility)
                {
                    //BattleGUI.bChooseAbility = true;
                }



                if (BattleGUI.bChooseAbility)
                {
                    if (key.actionIndentifierString.Equals(Game1.moveUpString) && !KeyboardMouseUtility.AnyButtonsPressed())
                    {
                        BattleGUI.PlayerChoiceUpDown(-1);
                    }

                    if (key.actionIndentifierString.Equals(Game1.moveDownString) && !KeyboardMouseUtility.AnyButtonsPressed())
                    {
                        BattleGUI.PlayerChoiceUpDown(+1);
                    }
                }



                if (key.actionIndentifierString.Equals(Game1.debugInfoString) && !KeyboardMouseUtility.AnyButtonsPressed())
                {
                    BattleStats.Report(BattleGUI.gbc);
                }
            }
            else if (EncounterInfo.encounterGroups.Count != 0 && EncounterInfo.currentTurn() != null && (!EncounterInfo.currentTurn().bIsPlayerTurnSet || (EncounterInfo.currentTurn().bIsPlayerTurnSet&& EncounterInfo.currentTurn().bPlayerTurnEnemyOverriden)))
            {
                if ((key.actionIndentifierString.Equals(Game1.confirmString) || key.actionIndentifierString.Equals(Game1.openMenuString)) && !KeyboardMouseUtility.AnyButtonsPressed() && !BattleGUI.bStartZoom)
                {
                    if (GameProcessor.bMayEndCharacterTurn && EncounterInfo.currentTurn().bIsEnemyTurnSet&& EncounterInfo.currentTurn().currentEnemy.character.attackedAsAI)
                    {
                        EncounterInfo.currentTurn().FinalizeEnemyRound();
                    }
                    BattleGUI.End();
                }
            }
            else
            {
                if ((PlayerController.selectedSprite as BaseCharacter).IsAlive() && EncounterInfo.encounterGroups.Count > 0 && EncounterInfo.currentTurn() != null && EncounterInfo.currentTurn().bIsPlayerTurnSet&& !EncounterInfo.currentTurn().bPlayerMustSelectAction&& !EncounterInfo.currentTurn().groupTurnSet.Find(gts => gts.character == PlayerController.selectedSprite).bIsCompleted)
                {
                    #region
                    if (key.actionIndentifierString.Equals(Game1.moveUpString))
                    {
                        //PlayerController.selectedSprite.Move(new Vector2(0, -Speed));
                        //PathMoveHandler.SkipPathMovement();
                        if (!PathMoveHandler.bIsBusy)
                        {
                            selectedChar.rotationIndex       = (int)BaseCharacter.Rotation.Up;
                            CombatProcessor.allPossibleNodes = PathFinder.NewPathSearch(selectedChar.position, selectedChar.position - new Vector2(0, 64), CombatProcessor.radiusTiles);
                            if (CombatProcessor.allPossibleNodes.Count != 0)
                            {
                                //    EncounterInfo.currentTurn().selectedCharTurn.stepsSet++;
                                EncounterInfo.currentTurn().bRegenerateRadius = true;
                            }
                            PathMoveHandler.Start(selectedChar, CombatProcessor.allPossibleNodes);
                        }
                    }

                    if (key.actionIndentifierString.Equals(Game1.moveDownString))
                    {
                        //PlayerController.selectedSprite.Move(new Vector2(0, Speed));

                        //  PathMoveHandler.SkipPathMovement();
                        if (!PathMoveHandler.bIsBusy)
                        {
                            selectedChar.rotationIndex       = (int)BaseCharacter.Rotation.Down;
                            CombatProcessor.allPossibleNodes = PathFinder.NewPathSearch(selectedChar.position, selectedChar.position + new Vector2(0, 64), CombatProcessor.radiusTiles);
                            if (CombatProcessor.allPossibleNodes.Count != 0)
                            {
                                //   EncounterInfo.currentTurn().selectedCharTurn.stepsSet++;
                                EncounterInfo.currentTurn().bRegenerateRadius = true;
                            }
                            PathMoveHandler.Start(selectedChar, CombatProcessor.allPossibleNodes);
                        }
                    }

                    if (key.actionIndentifierString.Equals(Game1.moveLeftString))
                    {
                        //  PlayerController.selectedSprite.Move(new Vector2(-Speed, 0));

                        // PathMoveHandler.SkipPathMovement();
                        if (!PathMoveHandler.bIsBusy)
                        {
                            selectedChar.rotationIndex       = (int)BaseCharacter.Rotation.Left;
                            CombatProcessor.allPossibleNodes = PathFinder.NewPathSearch(selectedChar.position, selectedChar.position - new Vector2(64, 0), CombatProcessor.radiusTiles);
                            if (CombatProcessor.allPossibleNodes.Count != 0)
                            {
                                //  EncounterInfo.currentTurn().selectedCharTurn.stepsSet++;
                                EncounterInfo.currentTurn().bRegenerateRadius = true;
                            }
                            PathMoveHandler.Start(selectedChar, CombatProcessor.allPossibleNodes);
                        }
                    }

                    if (key.actionIndentifierString.Equals(Game1.moveRightString))
                    {
                        // PlayerController.selectedSprite.Move(new Vector2(Speed, 0));

                        //PathMoveHandler.SkipPathMovement();
                        if (!PathMoveHandler.bIsBusy)
                        {
                            selectedChar.rotationIndex = (int)BaseCharacter.Rotation.Right;
                            //int radius = selectedChar.trueSTATChart().currentPassiveStats[(int)STATChart.PASSIVESTATS.MOB] * selectedChar.trueSTATChart().currentPassiveStats[(int)STATChart.PASSIVESTATS.AP] - EncounterInfo.currentTurn().selectedCharTurn.stepsSet;
                            //CombatProcessor.radiusTiles = MapListUtility.returnMapRadius(radius,GameProcessor.loadedMap.possibleTilesGameZone(CombatProcessor.zoneTiles),selectedChar);
                            CombatProcessor.allPossibleNodes = PathFinder.NewPathSearch(selectedChar.position, selectedChar.position + new Vector2(64, 0), CombatProcessor.radiusTiles);
                            if (CombatProcessor.allPossibleNodes.Count != 0)
                            {
                                //  EncounterInfo.currentTurn().selectedCharTurn.stepsSet++;
                                EncounterInfo.currentTurn().bRegenerateRadius = true;
                            }
                            PathMoveHandler.Start(selectedChar, CombatProcessor.allPossibleNodes);
                        }
                    }

                    if (EncounterInfo.currentTurn().bIsPlayerTurnSet&& !BattleGUI.bIsRunning)
                    {
                        if (!KeyboardMouseUtility.bMouseButtonPressed && (key.actionIndentifierString.Equals(Game1.confirmString) || key.actionIndentifierString.Equals(Game1.openMenuString)) && !KeyboardMouseUtility.AnyButtonsPressed() && !PathMoveHandler.bIsBusy && EncounterInfo.currentTurn().selectedCharTurn != null && CombatProcessor.bMainCombat && !EncounterInfo.currentTurn().bPlayerMustSelectAction)
                        {
                            KeyboardMouseUtility.bPressed = true;
                            EncounterInfo.currentTurn().StartPopUpChoice(PlayerController.selectedSprite.position);
                        }
                        else if (KeyboardMouseUtility.bMouseButtonPressed && (key.actionIndentifierString.Equals(Game1.cancelString)) && !KeyboardMouseUtility.AnyButtonsPressed() && !PathMoveHandler.bIsBusy && EncounterInfo.currentTurn().selectedCharTurn != null && CombatProcessor.bMainCombat && !EncounterInfo.currentTurn().bPlayerMustSelectAction)
                        {
                            EncounterInfo.currentTurn().SelectCharacter();
                        }
                        else if (KeyboardMouseUtility.bMouseButtonPressed && !KeyboardMouseUtility.AnyButtonsPressed() && key.actionIndentifierString.Equals(Game1.confirmString) && !PathMoveHandler.bIsBusy && CombatProcessor.bMainCombat)
                        {
                            if (PlayerSaveData.heroParty.Find(c => c.spriteGameSize.Contains(KeyboardMouseUtility.gameMousePos)) == default(BaseCharacter))
                            {
                                EncounterInfo.currentTurn().RightButtonPlayerAction();
                            }
                            else
                            {
                                EncounterInfo.currentTurn().SelectCharacter();
                            }

                            KeyboardMouseUtility.bPressed = true;
                        }
                        else if (key.actionIndentifierString.Equals(Game1.tabKeyString) && !KeyboardMouseUtility.AnyButtonsPressed() && !PathMoveHandler.bIsBusy && EncounterInfo.currentTurn().selectedCharTurn != null && CombatProcessor.bMainCombat && !EncounterInfo.currentTurn().bPlayerMustSelectAction)
                        {
                            EncounterInfo.currentTurn().TabSelect();
                        }
                    }

                    //



                    //if (key.actionIndentifierString.Equals(Game1.cameraMoveUpString))
                    //{
                    //    GameProcessor.sceneCamera.Y += (int)(normalCameraSpeed * GameProcessor.zoom);
                    //}

                    //if (key.actionIndentifierString.Equals(Game1.cameraMoveDownString))
                    //{
                    //    GameProcessor.sceneCamera.Y -= (int)(normalCameraSpeed * GameProcessor.zoom);
                    //}

                    //if (key.actionIndentifierString.Equals(Game1.cameraMoveLeftString))
                    //{
                    //    GameProcessor.sceneCamera.X += (int)(normalCameraSpeed * GameProcessor.zoom);
                    //}

                    //if (key.actionIndentifierString.Equals(Game1.cameraMoveRightString))
                    //{
                    //    GameProcessor.sceneCamera.X -= (int)(normalCameraSpeed * GameProcessor.zoom);
                    //}
                    #endregion
                }
                else if (EncounterInfo.encounterGroups.Count > 0 && EncounterInfo.currentTurn().bPlayerMustSelectAction)
                {
                    if (key.actionIndentifierString.Equals(Game1.cancelString) && !KeyboardMouseUtility.AnyButtonsPressed())
                    {
                        EncounterInfo.currentTurn().bPlayerMustSelectAction = false;
                        KeyboardMouseUtility.bPressed = true;
                    }

                    if (key.actionIndentifierString.Equals(Game1.moveUpString) && !KeyboardMouseUtility.AnyButtonsPressed())
                    {
                        BattleGUI.PopUpPreviousChoice();
                    }

                    if (key.actionIndentifierString.Equals(Game1.moveDownString) && !KeyboardMouseUtility.AnyButtonsPressed())
                    {
                        BattleGUI.PopUpNextChoice();
                    }

                    if (key.actionIndentifierString.Equals(Game1.moveLeftString) && !KeyboardMouseUtility.AnyButtonsPressed())
                    {
                        BattleGUI.SelectPreviousCharacter();
                    }

                    if (key.actionIndentifierString.Equals(Game1.moveRightString) && !KeyboardMouseUtility.AnyButtonsPressed())
                    {
                        BattleGUI.SelectNextCharacter();
                    }

                    if ((key.actionIndentifierString.Equals(Game1.confirmString) || key.actionIndentifierString.Equals(Game1.openMenuString)) && !KeyboardMouseUtility.AnyButtonsPressed())
                    {
                        // var temp = EncounterInfo.currentTurn().selectedCharTurn.character;
                        switch (BattleGUI.returnCurrentPopUpMenuSelection())
                        {
                        case (int)BattleGUI.PopUpChoices.Attack:
                            if (BattleGUI.selectedTarget != null && EncounterInfo.currentTurn().selectedCharTurn.character.UsableAbilityList(BattleGUI.selectedTarget).Count != 0)
                            {
                                GameProcessor.StartBattleSoon(EncounterInfo.currentTurn().selectedCharTurn.character, BattleGUI.selectedTarget);
                            }
                            break;

                        case (int)BattleGUI.PopUpChoices.Defend:
                            EncounterInfo.currentTurn().selectedCharTurn.character.bSaveAP = true;
                            BattleGUI.DefendOption(EncounterInfo.currentTurn().selectedCharTurn.character, BattleGUI.selectedTarget);
                            EncounterInfo.currentTurn().FinalizeCharacterRound();
                            break;

                        case (int)BattleGUI.PopUpChoices.Item:
                            BattleGUI.ItemsOption();
                            break;
                        }
                    }
                }
            }

            if (!KeyboardMouseUtility.bMouseButtonPressed && (key.actionIndentifierString.Equals(Game1.confirmString) || key.actionIndentifierString.Equals(Game1.openMenuString)) && !KeyboardMouseUtility.AnyButtonsPressed())
            {
                if (CombatProcessor.bStartPhase1)
                {
                    CombatProcessor.StartMainCombat();
                    EncounterInfo.ChangeGroup(0);
                }
            }
        }