internal LUA.LuaTurnSetInfo toLuaTurnSetInfo()
        {
            LUA.LuaTurnSetInfo ltsi = new LUA.LuaTurnSetInfo();
            ltsi.bIsAssist         = this.bIsAssistTurnSet;
            ltsi.bIsEnemy          = this.bIsEnemyTurnSet;
            ltsi.bIsPlayer         = this.bIsPlayerTurnSet;
            ltsi.parent            = this;
            ltsi.charactersInGroup = this.charactersInGroup;
            this.groupTurnSet.ForEach(ct => ltsi.charTurnInfos.Add(ct.toLuaCharacterTurnInfo()));

            if (EncounterInfo.currentTurn().bIsPlayerTurnSet&& !bPlayerTurnEnemyOverriden)
            {
                ltsi.CTCallFrom = selectedCharTurn == null ? null : selectedCharTurn.toLuaCharacterTurnInfo();
            }
            else
            {
                ltsi.CTCallFrom = currentEnemy == null ? null : currentEnemy.toLuaCharacterTurnInfo();
            }

            var tempL = EncounterInfo.encounterGroups.FindAll(g => g != this);

            foreach (var item in tempL)
            {
                ltsi.otherGroups.Add(item.toLuaTurnSetInfoSimple());
            }

            return(ltsi);
        }
        public void FinalizeEnemyRound()
        {
            currentEnemy.character.attackedAsAI = false;
            BattleGUI.End();
            bTest    = false;
            AITarget = null;
            AIbtba   = default(KeyValuePair <BasicTile, BasicAbility>);
            currentEnemy.character.attackedAsAI = false;
            currentEnemy.bIsCompleted           = true;
            //var MaxAP = currentEnemy.character.trueSTATChart().currentPassiveStats[(int)STATChart.PASSIVESTATS.AP];
            //BasicTile finalTile = currentEnemy.returnCompleteArea().Find(t => t.mapPosition.Location == PathMoveHandler.finalPos.ToPoint());
            //var expendedAP = currentEnemy.characterArea.IndexOf(currentEnemy.characterArea.Find(area => area.Contains(finalTile))) + 1;
            //currentEnemy.character.statChart.currentActiveStats[(int)STATChart.ACTIVESTATS.STORED_AP] += MaxAP - expendedAP;

            if (currentEnemy.character.bSaveAP || true)
            {
                var       MaxAP      = currentEnemy.character.trueSTATChart().currentPassiveStats[(int)STATChart.PASSIVESTATS.AP];
                BasicTile finalTile  = currentEnemy.returnCompleteArea().Find(t => t.mapPosition.Location == PathMoveHandler.finalPos.ToPoint());
                var       expendedAP = currentEnemy.characterArea.IndexOf(currentEnemy.characterArea.Find(area => area.Contains(finalTile))) + 1;
                currentEnemy.character.statChart.currentActiveStats[(int)STATChart.ACTIVESTATS.STORED_AP] += MaxAP - expendedAP;
            }

            if (currentEnemy.character.bAIExecuteDefend)
            {
                BattleGUI.DefendOption(currentEnemy.character, currentEnemy.character);
            }

            //   Console.WriteLine(currentEnemy.character.statChart.currentActiveStats[(int)STATChart.ACTIVESTATS.STORED_AP]);
            BattleScriptHandler.Execute(LUA.LuaBScriptEvent.EventType.postCT, this.toLuaTurnSetInfo());
            TBAGW.EncounterInfo.currentTurn().bPlayerTurnEnemyOverriden = false; //This line must always be after the Execute line

            EncounterInfo.ClearDeathChars();
            EncounterInfo.UpdateAllStats();
        }
 private void Reset()
 {
     frameIndex = 0;
     timePassed = 0;
     bMustShow  = false;
     EncounterInfo.TurnEffectCompletedAfterChangeTurn();
 }
        public void SelectCharacter(BaseCharacter c)
        {
            #region Left button logic
            if (!bPlayerMustSelectAction && !PathMoveHandler.bIsBusy)
            {
                if (EncounterInfo.currentTurn().selectedCharTurn != null)
                {
                    PlayerController.previousSelected = EncounterInfo.currentTurn().selectedCharTurn.character;
                }
                else
                {
                    PlayerController.previousSelected = null;
                }

                selectedCharTurn = groupTurnSet.Find(sct => sct.character == c && !sct.bIsCompleted);
                var v = PlayerController.originalPositionCharacter;
                if (selectedCharTurn != null && !selectedCharTurn.bIsCompleted && selectedCharTurn.character != PlayerController.selectedSprite || (bFirstTurn && selectedCharTurn != null))
                {
                    var selectedChar = EncounterInfo.currentTurn().selectedCharTurn.character;
                    if (PlayerController.previousSelected != null && !EncounterInfo.currentTurn().groupTurnSet.Find(gts2 => gts2.character == PlayerController.previousSelected).bIsCompleted&& !bFirstTurn)
                    {
                        //PlayerController.previousSelected.position = PlayerController.originalPositionCharacter;
                        PlayerController.previousSelected.changePosition(PlayerController.originalPositionCharacter);
                        groupTurnSet.Find(sct => sct.character == PlayerController.previousSelected).stepsSet = 0;
                    }
                    PlayerController.selectedSprite  = selectedChar;
                    GameProcessor.cameraFollowTarget = selectedChar;
                    bFirstTurn = false;
                    PlayerController.originalPositionCharacter = selectedChar.position;
                    GameProcessor.sceneCamera = ((new Vector2(-(selectedChar.position.X + 32 - 1366 / GameProcessor.zoom / 2), -(selectedChar.position.Y + 32 - 768 / GameProcessor.zoom / 2))));
                    ReGenerateTurn();
                }
                if (selectedCharTurn != null && selectedCharTurn.bIsCompleted)
                {
                    var selectedChar = EncounterInfo.currentTurn().selectedCharTurn.character;
                    GameProcessor.sceneCamera = ((new Vector2(-(selectedChar.position.X + 32 - 1366 / GameProcessor.zoom / 2), -(selectedChar.position.Y + 32 - 768 / GameProcessor.zoom / 2))));
                }
                if (selectedCharTurn == null)
                {
                    if (PlayerController.previousSelected != null && !EncounterInfo.currentTurn().groupTurnSet.Find(gts2 => gts2.character == PlayerController.previousSelected).bIsCompleted&& !bFirstTurn)
                    {
                        PlayerController.previousSelected.changePosition(PlayerController.originalPositionCharacter);
                        groupTurnSet.Find(sct => sct.character == PlayerController.previousSelected).stepsSet = 0;
                    }
                    // PlayerController.selectedSprite.position = PlayerController.originalPositionCharacter;

                    bFirstTurn = true;
                    GameProcessor.cameraFollowTarget = null;
                }
            }
            #endregion
        }
        internal LUA.LuaTurnSetInfo toLuaTurnSetInfoSimple()
        {
            LUA.LuaTurnSetInfo ltsi = new LUA.LuaTurnSetInfo();
            ltsi.bIsAssist         = this.bIsAssistTurnSet;
            ltsi.bIsEnemy          = this.bIsEnemyTurnSet;
            ltsi.bIsPlayer         = this.bIsPlayerTurnSet;
            ltsi.parent            = this;
            ltsi.charactersInGroup = this.charactersInGroup;
            this.groupTurnSet.ForEach(ct => ltsi.charTurnInfos.Add(ct.toLuaCharacterTurnInfo()));

            if (EncounterInfo.currentTurn().bIsPlayerTurnSet)
            {
                ltsi.CTCallFrom = selectedCharTurn == null ? null : selectedCharTurn.toLuaCharacterTurnInfo();
            }
            else
            {
                ltsi.CTCallFrom = currentEnemy == null ? null : currentEnemy.toLuaCharacterTurnInfo();
            }

            return(ltsi);
        }
        public void FinalizeCharacterRound()
        {
            BattleGUI.End();
            bPlayerMustSelectAction       = false;
            selectedCharTurn.bIsCompleted = true;

            if (selectedCharTurn.character.bSaveAP)
            {
                var       MaxAP      = selectedCharTurn.character.trueSTATChart().currentPassiveStats[(int)STATChart.PASSIVESTATS.AP];
                BasicTile finalTile  = selectedCharTurn.returnCompleteArea().Find(t => t.mapPosition.Location == PathMoveHandler.finalPos.ToPoint());
                var       expendedAP = selectedCharTurn.characterArea.IndexOf(selectedCharTurn.characterArea.Find(area => area.Contains(finalTile))) + 1;
                selectedCharTurn.character.statChart.currentActiveStats[(int)STATChart.ACTIVESTATS.STORED_AP] += MaxAP - expendedAP;
            }

            //Console.WriteLine(selectedCharTurn.character.statChart.currentActiveStats[(int)STATChart.ACTIVESTATS.STORED_AP]);
            BattleScriptHandler.Execute(LUA.LuaBScriptEvent.EventType.postCT, this.toLuaTurnSetInfo());
            EncounterInfo.ClearDeathChars();

            selectedCharTurn = null;
            EncounterInfo.UpdateAllStats();
        }
        private void ResetAndChangeGroup()
        {
            bIsCompleted = false;
            foreach (var item in groupTurnSet)
            {
                item.bIsCompleted = false;
            }

            if (bIsPlayerTurnSet)
            {
                BattleScriptHandler.Execute(LUA.LuaBScriptEvent.EventType.postPT, this.toLuaTurnSetInfo());
            }
            else
            {
                BattleScriptHandler.Execute(LUA.LuaBScriptEvent.EventType.postET, this.toLuaTurnSetInfo());
            }


            EncounterInfo.ChangeGroup();

            randomEnemy = GamePlayUtility.Randomize(0, CombatProcessor.heroCharacters.Count - 1);
        }
        public void Start()
        {
            bIsCompleted     = true;
            selectedCharTurn = null;
            GenerateTurns();
            BattleGUI.UpdateGUIElements();

            if (bIsPlayerTurnSet)
            {
                BattleScriptHandler.Execute(LUA.LuaBScriptEvent.EventType.startPT, this.toLuaTurnSetInfo());
            }
            else
            {
                BattleScriptHandler.Execute(LUA.LuaBScriptEvent.EventType.startET, this.toLuaTurnSetInfo());
            }

            PlayerController.previousSelected        = null;
            groupTurnSet.ForEach(gts => gts.stepsSet = 0);
            EncounterInfo.UpdateAllStats();
            selectedCharTurn = null;
            bFirstTurn       = false;
            PlayerController.selectedSprite = null;
        }
        public void Update()
        {
            var gts = groupTurnSet.Find(g => !g.bIsCompleted);

            //CombatProcessor.encounterEnemies

            if (bIsPlayerTurnSet && !EncounterInfo.currentTurn().bPlayerTurnEnemyOverriden&& !BattleGUI.bIsRunning && !bSelectingArea)
            {
                if (!KeyboardMouseUtility.AnyButtonsPressed() && Keyboard.GetState().IsKeyDown(Keys.X))
                {
                    var temp = EncounterInfo.encounterGroups.FindAll(eg => eg.bIsPlayerTurnSet);
                    foreach (var item in temp)
                    {
                        item.bIsCompleted = true;
                    }
                }

                if (EncounterInfo.currentTurn().selectedCharTurn != null && bRegenerateRadius)
                {
                    RegenerateRadius();
                }

                currentEnemy = null;


                if (selectedCharTurn != null && !selectedCharTurn.bIsCompleted)
                {
                    var tempTile = selectedCharTurn.returnCompleteArea().Find(t => t.mapPosition.Contains(GameProcessor.EditorCursorPos));
                    if (tempTile != null)
                    {
                        if (CombatArrowLayout.bShouldRecheck(tempTile))
                        {
                            CombatArrowLayout.Start(tempTile, selectedCharTurn);
                        }
                    }
                    else
                    {
                        CombatArrowLayout.bMustDraw = false;
                        CombatArrowLayout.Clear();
                    }
                }
                else
                {
                    if (CombatArrowLayout.CanClear())
                    {
                        CombatArrowLayout.Clear();
                    }
                }
            }
            else if (bIsPlayerTurnSet && BattleGUI.bIsRunning)
            {
            }
            else if (bIsEnemyTurnSet || EncounterInfo.currentTurn().bPlayerTurnEnemyOverriden)
            {
                UpdateEnemyLogic(gts);
            }

            if (bSelectingArea)
            {
            }

            if (gts == null)
            {
                bIsCompleted = true;
            }

            if (bIsCompleted && !bPlayerTurnEnemyOverriden && !LUA.LuaExecutionList.DemandOverride() && !PathMoveHandler.bIsBusy && BattleGUI.TurnEffectsList.Find(te => te.bMustShow) == default(ChangeTurnEffect))
            {
                ResetAndChangeGroup();
            }
        }
Exemplo n.º 10
0
        public void TabSelect()
        {
            if (!bPlayerMustSelectAction && !PathMoveHandler.bIsBusy)
            {
                if (EncounterInfo.currentTurn().selectedCharTurn != null)
                {
                    PlayerController.previousSelected = EncounterInfo.currentTurn().selectedCharTurn.character;
                }
                else
                {
                    PlayerController.previousSelected = null;
                }

                //   selectedCharTurn = groupTurnSet.Find(sct => sct.character == CombatProcessor.heroCharacters.Find(c => c.spriteGameSize.Contains(GameProcessor.EditorCursorPos)) && !sct.bIsCompleted);
                int index          = 0;
                var availableChars = groupTurnSet.FindAll(ct => !ct.bIsCompleted);
                if (availableChars.Count == 0)
                {
                    selectedCharTurn = availableChars[index];
                }
                else
                {
                    index = availableChars.IndexOf(EncounterInfo.currentTurn().selectedCharTurn);
                    if (index == -1)
                    {
                        index = 0;
                    }
                    else if (index + 1 != availableChars.Count)
                    {
                        index++;
                    }
                    else
                    {
                        index = 0;
                    }

                    selectedCharTurn = availableChars[index];
                }


                var v = PlayerController.originalPositionCharacter;
                if (selectedCharTurn != null && !selectedCharTurn.bIsCompleted && selectedCharTurn.character != PlayerController.selectedSprite || (bFirstTurn && selectedCharTurn != null))
                {
                    var selectedChar = EncounterInfo.currentTurn().selectedCharTurn.character;
                    if (PlayerController.previousSelected != null && !EncounterInfo.currentTurn().groupTurnSet.Find(gts2 => gts2.character == PlayerController.previousSelected).bIsCompleted&& !bFirstTurn)
                    {
                        //PlayerController.previousSelected.position = PlayerController.originalPositionCharacter;
                        PlayerController.previousSelected.changePosition(PlayerController.originalPositionCharacter);
                        groupTurnSet.Find(sct => sct.character == PlayerController.previousSelected).stepsSet = 0;
                    }
                    PlayerController.selectedSprite  = selectedChar;
                    GameProcessor.cameraFollowTarget = selectedChar;
                    bFirstTurn = false;
                    PlayerController.originalPositionCharacter = selectedChar.position;
                    //   GameProcessor.sceneCamera = ((new Vector2(-(selectedChar.position.X + 32 - 1366 / GameProcessor.zoom / 2), -(selectedChar.position.Y + 32 - 768 / GameProcessor.zoom / 2))));
                    ReGenerateTurn();
                }
                if (selectedCharTurn != null && selectedCharTurn.bIsCompleted)
                {
                    var selectedChar = EncounterInfo.currentTurn().selectedCharTurn.character;
                    // GameProcessor.sceneCamera = ((new Vector2(-(selectedChar.position.X + 32 - 1366 / GameProcessor.zoom / 2), -(selectedChar.position.Y + 32 - 768 / GameProcessor.zoom / 2))));
                }
                if (selectedCharTurn == null)
                {
                    if (PlayerController.previousSelected != null && !EncounterInfo.currentTurn().groupTurnSet.Find(gts2 => gts2.character == PlayerController.previousSelected).bIsCompleted&& !bFirstTurn)
                    {
                        PlayerController.previousSelected.changePosition(PlayerController.originalPositionCharacter);
                        groupTurnSet.Find(sct => sct.character == PlayerController.previousSelected).stepsSet = 0;
                    }
                    // PlayerController.selectedSprite.position = PlayerController.originalPositionCharacter;

                    bFirstTurn = true;
                    GameProcessor.cameraFollowTarget = null;
                }
            }
        }
Exemplo n.º 11
0
        private void RegenerateRadius()
        {
            int radius = selectedCharTurn.character.trueSTATChart().currentPassiveStats[(int)STATChart.PASSIVESTATS.MOB] * selectedCharTurn.character.trueSTATChart().currentPassiveStats[(int)STATChart.PASSIVESTATS.AP] - (EncounterInfo.currentTurn().selectedCharTurn.stepsSet - 2);

            switch (selectedCharTurn.character.rotationIndex)
            {
            case (int)BaseCharacter.Rotation.Up:
                CombatProcessor.radiusTiles = MapListUtility.returnValidMapRadius(radius, EncounterInfo.currentTurn().selectedCharTurn.returnCompleteArea(), selectedCharTurn.character.position - new Vector2(0, 64));
                CombatProcessor.radiusTiles.RemoveAll(t => t.distanceCoordsFrom(selectedCharTurn.character.position) > radius - 2);
                break;

            case (int)BaseCharacter.Rotation.Down:
                CombatProcessor.radiusTiles = MapListUtility.returnValidMapRadius(radius, EncounterInfo.currentTurn().selectedCharTurn.returnCompleteArea(), selectedCharTurn.character.position + new Vector2(0, 64));
                CombatProcessor.radiusTiles.RemoveAll(t => t.distanceCoordsFrom(selectedCharTurn.character.position + new Vector2(0, 64)) > radius - 2);
                break;

            case (int)BaseCharacter.Rotation.Right:
                CombatProcessor.radiusTiles = MapListUtility.returnValidMapRadius(radius, EncounterInfo.currentTurn().selectedCharTurn.returnCompleteArea(), selectedCharTurn.character.position + new Vector2(64, 0));

                CombatProcessor.radiusTiles.RemoveAll(t => t.distanceCoordsFrom(selectedCharTurn.character.position + new Vector2(64, 0)) > radius - 2);
                break;

            case (int)BaseCharacter.Rotation.Left:
                CombatProcessor.radiusTiles = MapListUtility.returnValidMapRadius(radius, EncounterInfo.currentTurn().selectedCharTurn.returnCompleteArea(), selectedCharTurn.character.position - new Vector2(64, 0));
                CombatProcessor.radiusTiles.RemoveAll(t => t.distanceCoordsFrom(selectedCharTurn.character.position) > radius - 2);
                break;
            }

            //CombatProcessor.radiusTiles.RemoveAll(t => t.distanceCoordsFrom(selectedCharTurn.character.position) > radius - 1);
            bRegenerateRadius = false;
        }