Esempio n. 1
0
 void Start()
 {
     battleGui      = gameObject.GetComponent <BattleGUI>();
     announcements  = gameObject.GetComponentInChildren <Announcements>();
     attributes     = gameObject.GetComponentInChildren <AttributeBoard>();
     timeLineLength = battleGui.GetLength();
 }
Esempio n. 2
0
        // Temp - start a test wild battle
        public void TempCreateWildBattle(Map map, Map.Layout.Block block, EncounterTable.Encounter encounter)
        {
            Save sav      = Save;
            var  me       = new PBETrainerInfo(sav.PlayerParty, sav.PlayerName);
            var  wildPkmn = PartyPokemon.GetTestWildPokemon(encounter);
            var  wild     = new PBETrainerInfo(new Party {
                wildPkmn
            }, "Wild " + PBELocalizedString.GetSpeciesName(wildPkmn.Species).English);

            void OnBattleEnded()
            {
                void FadeFromTransitionEnded()
                {
                    _fadeFromTransition = null;
                }

                _fadeFromTransition = new FadeFromColorTransition(20, 0, FadeFromTransitionEnded);
                _battleGUI          = null;
            }

            _battleGUI = new BattleGUI(new PBEBattle(PBEBattleFormat.Single, PBESettings.DefaultSettings, me, wild,
                                                     battleTerrain: Overworld.GetPBEBattleTerrainFromBlock(block.BlocksetBlock),
                                                     weather: Overworld.GetPBEWeatherFromMap(map)),
                                       OnBattleEnded);
            void OnBattleTransitionEnded()
            {
                _battleTransition = null;
            }

            _battleTransition = new SpiralTransition(OnBattleTransitionEnded);
        }
Esempio n. 3
0
    //TODO fleeing? timer for fleeing?
    private void Attack(StateController controller)
    {
        RaycastHit hit;

        Debug.Log("attack being called");
        Debug.DrawRay(controller.eyes.position, controller.eyes.forward.normalized * attackRange, Color.red);
        ChallengerText chaltext = controller.manager.GetComponent <ChallengerText>();

        try {
            if (Physics.SphereCast(controller.eyes.position, attackRange, controller.eyes.forward, out hit, attackRange) &&
                !hit.collider.GetComponent <Challenger>().faction.Equals(controller.faction))       //TODO vfirst few frames this second part is null ?? not sure why ?

            {
                Challenger target = hit.collider.GetComponent <Challenger>();
                BattleGUI  gui    = controller.manager.GetComponent <BattleGUI>();
                gui.enemy = controller.self;                         //sets battle gui enemy to this enemy
                                                                     //setting an showing challenger interaction GUI
                controller.retreatButton.interactable = false;       // turn off retreat options btton
                                                                     // needed if more than 1v1:
                target.interactingWith            = controller.self; //sets player to be interacting with this attacking unit
                controller.self.interactingWith   = target;          //sets self to interacting with player
                controller.navMeshAgent.isStopped = true;            //stops?
                chaltext.SetText(controller.self);                   //sets text
                chaltext.ShowChalGUI();
            }
        } catch (NullReferenceException e) {
            Debug.Log("First x frames seem to throw null ref??");
        }
    }
Esempio n. 4
0
    // Use this for initialization

    private void Awake()
    {
        armyGUI = GetComponent <ArmyGUIController>();
        playerGUI.SetActive(false);
        chalText        = GetComponent <ChallengerText>();
        battleGUIObject = GetComponent <BattleGUI>();
    }
Esempio n. 5
0
    /*
     * public BattleGUI(PokemonObj pokemonObj){
     *
     *      this.pokemonObj = pokemonObj;
     *      pokemonObj.pokemon.pp = 1;
     * }
     */

    public static BattleGUI CreateBattleGUI(GameObject where, PokemonObj pokeobjtmp)
    {
        BattleGUI myC = where.AddComponent <BattleGUI>();

        myC.pokemonObj = pokeobjtmp;
        return(myC);
    }
Esempio n. 6
0
        public StartScreen()
        {
            BattleGUI.InitializeResources();
            bIsRunning    = true;
            r2d           = new RenderTarget2D(Game1.graphics.GraphicsDevice, 1366, 768);
            bg.texFileLoc = @"Graphics\StartScreen\StartBG";
            bg.animationFrames.Add(new Rectangle(0, 0, 1366, 768));
            bg.ReloadTexture();

            sf = Game1.contentManager.Load <SpriteFont>(@"Fonts\Design\BGUI\test48");
            //testSF = Game1.contentManager.Load<SpriteFont>(@"Fonts\Design\BGUI\test");
            //testSF20 = Game1.contentManager.Load<SpriteFont>(@"Fonts\Design\BGUI\test20");
            //testSF25 = Game1.contentManager.Load<SpriteFont>(@"Fonts\Design\BGUI\test25");
            //testSF32 = Game1.contentManager.Load<SpriteFont>(@"Fonts\Design\BGUI\test32");
            //testSF48 = Game1.contentManager.Load<SpriteFont>(@"Fonts\Design\BGUI\test48");
            int width  = 800;
            int deltaH = 28;
            int height = (400 - deltaH * 5) / 4;

            Rectangle b = new Rectangle((1366 - width) / 2, 400, 800, height);

            mButtons.Add(new SCButton(b, sf, "New Game"));
            b.Y += height + deltaH;
            mButtons.Add(new SCButton(b, sf, "Load Game"));
            b.Y += height + deltaH;
            mButtons.Add(new SCButton(b, sf, "Settings"));
            b.Y += height + deltaH;
            mButtons.Add(new SCButton(b, sf, "Exit Game"));
            sc = this;

            Utilities.Control.Player.PlayerController.InitializeStartScreenControls(this);
        }
 public void StartPopUpChoice(Vector2 pos)
 {
     //CombatProcessor.allPossibleNodes = PathFinder.NewPathSearch(pos, GameProcessor.EditorCursorPos, selectedCharTurn.returnCompleteArea());
     // PathMoveHandler.Start(PlayerController.selectedSprite, CombatProcessor.allPossibleNodes);
     bPlayerMustSelectAction = true;
     BattleGUI.InitializePopUpMenu();
 }
        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 static void ProcessEnd(ActionKey actionKey)
 {
     if (actionKey.actionIndentifierString.Equals(Game1.confirmString, StringComparison.OrdinalIgnoreCase) && !KeyboardMouseUtility.AnyButtonsPressed())
     {
         BattleGUI.CharacterSoloStop();
     }
 }
Esempio n. 10
0
        public static void InitiateCombat(BaseCharacter g, BaseCharacter r, BasicAbility gca, BasicAbility rca)
        {
            bMods.Clear();
            foreach (var item in Enum.GetNames(typeof(BattleMods)))
            {
                bMods.Add(0);
            }
            castAbility = gca;
            giver       = g;
            receiver    = r;
            // giverAS.DefaultStatChart();
            // receiverAS.DefaultStatChart();

            giverAS    = g.trueSTATChart();
            receiverAS = r.trueSTATChart();
            Console.WriteLine(g.trueSTATChart().currentActiveStats[(int)STATChart.ACTIVESTATS.SHIELD]);

            if (gca.abilityType == (int)BasicAbility.ABILITY_TYPE.ATTACK)
            {
                bMods[(int)BattleMods.MIN_DAMAGE]        = CalculateMinDamage();
                bMods[(int)BattleMods.MAX_DAMAGE]        = CalculateMaxDamage();
                bMods[(int)BattleMods.MIN_STATUS_CHANCE] = 0;
                bMods[(int)BattleMods.MAX_STATUS_CHANCE] = 0;
                bMods[(int)BattleMods.CRIT]  = 5;
                bMods[(int)BattleMods.DODGE] = 5;
                bMods[(int)BattleMods.FAIL]  = 5;
            }

            BattleGUI.Start(giverAS, receiverAS, g, r, gca, rca);
        }
Esempio n. 11
0
	void Start(){
		trainer = GameObject.Find("Player").GetComponent<Trainer>();
		gameObject.AddComponent<PlayerSave> ();
		battleGUI = gameObject.AddComponent<BattleGUI> ();
		gameObject.AddComponent<CameraControl> ();
		trainer.gameObject.AddComponent<PlayerMovement> ();
		gamegui = gameObject.AddComponent<GameGUI> ();
		gameObject.AddComponent<BattleTarget> ();
	}
Esempio n. 12
0
        static public void Initialize()
        {
            if (!bInitialized)
            {
                BattleGUI.InitializeResources();
                bInitialized = true;

                sf32 = BattleGUI.testSF32;
                sf48 = BattleGUI.testSF48;
            }
        }
        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);
                    }
                }
            }
        }
 private static void GlobalControls(List <Actions.ActionKey> keys)
 {
     if (!BattleGUI.bIsRunning && !TurnSet.bSelectingArea && EncounterInfo.encounterGroups.Count != 0)
     {
         if (!KeyboardMouseUtility.AnyButtonsPressed() && EncounterInfo.currentTurn().bIsPlayerTurnSet&& KeyboardMouseUtility.bMouseButtonPressed && keys.Last().actionIndentifierString.Equals(Game1.confirmString))
         {
             BattleGUI.HandleLowerTabSelect();
         }
     }
     //if (keys[keys.Count - 1].actionIndentifierString.Equals(Game1.openMenuString) && !KeyboardMouseUtility.AnyButtonsPressed() && !BattleGUI.bIsRunning && EncounterInfo.currentTurn().bIsPlayerTurnSet)
     //{
     //    GameProcessor.bInGameMenu = true;
     //    GameMenuHandler.Start();
     //    KeyboardMouseUtility.bPressed = true;
     //    GameProcessor.EnableMenuStage();
     //}
 }
Esempio n. 15
0
    BattleGUI battleGUI;                                       //a battle GUI for players to see stats and make actions


    ////////////////////////////////////////////////////////////////////////////////////////////////////
    //                                                                                                //
    //                                          Methods                                               //
    //                                                                                                //
    ////////////////////////////////////////////////////////////////////////////////////////////////////

    ////////////////////////////////////////////////////////////////////////////////////////////////////
    //                                                                                                //
    //                                       Init  Methods                                            //
    //                                                                                                //
    ////////////////////////////////////////////////////////////////////////////////////////////////////


    //initalize the battle manager
    public void Init()
    {
        _manager         = this;
        playerCharacters = GameManager._game.playerCharacters;
        enemyCharacters  = new List <BaseEnemyChampion>();
        championOrder    = gameObject.transform.GetChild(0).GetComponent <ChampionOrder>();
        battleGUI        = gameObject.transform.GetChild(1).GetComponent <BattleGUI>();

        GenerateRandomEnemy();
        GenerateRandomEnemy();
        GenerateRandomEnemy();

        InitEnemyChampions();
        InitGUI();
        InitBattle();
        StartCoroutine(BattleLoop());
    }
        public static void Draw(SpriteBatch sb)
        {
            BattleGUI.DrawBlueTiles(sb, availableTiles);

            /*
             * foreach (var item in availableTiles)
             * {
             *  sb.Draw(Game1.hitboxHelp, item.mapPosition, Color.LightBlue);
             * }*/

            if (availableTiles.Find(t => t.mapPosition.Contains(GameProcessor.EditorCursorPos)) != null)
            {
                Vector2 temp = (GameProcessor.EditorCursorPos / 64).ToPoint().ToVector2() * 64;
                if (selectedChar != null)
                {
                    selectedChar.Draw(sb, temp, (int)BaseSprite.Rotation.Down, Color.White * .4f);
                }
            }
        }
        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();
        }
Esempio n. 18
0
    //initalizer for this class
    public void Init(List <PlayerChampion> playersArg)
    {
        _battleGUI    = this;
        players       = playersArg;
        championInfo  = new List <PlayerInfoPanel>();
        actionButtons = new List <ActionButton>();

        battleMessage      = gameObject.transform.GetChild(0).transform.GetChild(0).GetComponent <TextMeshPro>();
        battleMessagePanel = gameObject.transform.GetChild(0).transform.GetChild(1).GetComponent <Image>();

        for (int idx = 0; idx <= 4 - 1; idx++)
        {
            championInfo.Add(gameObject.transform.GetChild(idx + 1).GetComponent <PlayerInfoPanel>());
            if (players.Count - 1 >= idx)
            {
                championInfo[idx].Init(players[idx]);
            }
            else
            {
                championInfo[idx].Init(null);
            }
        }
    }
        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;
        }
Esempio n. 20
0
 // Use this for initialization
 public void Awake()
 {
     _battleGUI = this.GetComponent<BattleGUI> ();
     _battleSystem = this;
 }
Esempio n. 21
0
	void Start() {
		allPokemon = new List<Transform>();
		targetedPokemon = null;
		battleGUI = gameObject.AddComponent<BattleGUI> ();
	}
Esempio n. 22
0
 void Start()
 {
     battleGUI = gameObject.AddComponent <BattleGUI> ();
     //gamegui = gameObject.GetComponent<GameGUI>();
 }
Esempio n. 23
0
	void Start() {
		allPokemon = new List<Transform>();
		targetedPokemon = null;
		battleGUI = Player.battleGUI;
	}
        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);
                }
            }
        }
        private static void AreaSelectContext(ActionKey actionKey)
        {
            if (!KeyboardMouseUtility.AnyButtonsPressed() && actionKey.actionIndentifierString.Equals(Game1.cameraMoveUpString, StringComparison.OrdinalIgnoreCase))
            {
                BattleGUI.gbc.rotationIndex   = (int)BaseCharacter.Rotation.Up;
                KeyboardMouseUtility.bPressed = true;
            }

            if (!KeyboardMouseUtility.AnyButtonsPressed() && actionKey.actionIndentifierString.Equals(Game1.cameraMoveDownString, StringComparison.OrdinalIgnoreCase))
            {
                BattleGUI.gbc.rotationIndex   = (int)BaseCharacter.Rotation.Down;
                KeyboardMouseUtility.bPressed = true;
            }

            if (!KeyboardMouseUtility.AnyButtonsPressed() && actionKey.actionIndentifierString.Equals(Game1.cameraMoveLeftString, StringComparison.OrdinalIgnoreCase))
            {
                BattleGUI.gbc.rotationIndex   = (int)BaseCharacter.Rotation.Left;
                KeyboardMouseUtility.bPressed = true;
            }

            if (!KeyboardMouseUtility.AnyButtonsPressed() && actionKey.actionIndentifierString.Equals(Game1.cameraMoveRightString, StringComparison.OrdinalIgnoreCase))
            {
                BattleGUI.gbc.rotationIndex   = (int)BaseCharacter.Rotation.Right;
                KeyboardMouseUtility.bPressed = true;
            }

            if (!KeyboardMouseUtility.AnyButtonsPressed() && actionKey.actionIndentifierString.Equals(Game1.cancelString, StringComparison.OrdinalIgnoreCase))
            {
                BattleGUI.HandleAreaCancel();
            }

            if (!KeyboardMouseUtility.AnyButtonsPressed() && actionKey.actionIndentifierString.Equals(Game1.confirmString, StringComparison.OrdinalIgnoreCase))
            {
                BattleGUI.HandleAreaConfirm();
            }

            #region
            if (actionKey.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 (actionKey.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 (actionKey.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 (actionKey.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);
                }
            }
            #endregion
        }
        internal static LUA.LuaAbilityInfo abiToLuaAbilityInfo(TBAGW.BasicAbility ba, LuaCharacterInfo caster, LuaCharacterInfo target, CallType ct = CallType.Attack)
        {
            LuaAbilityInfo lai = new LuaAbilityInfo();

            lai.abiType     = ba.abilityType.ToString();
            lai.abiCastType = ba.abilityFightStyle.ToString();
            lai.bIsAttack   = ba.abilityType == (int)BasicAbility.ABILITY_TYPE.ATTACK;

            lai.minDmg = ba.baseDamage;
            lai.minDmg = (int)(lai.minDmg * target.parent.combatInfo.baseVSModifier(ba));
            lai.maxDmg = (int)(lai.minDmg * 1.5f);

            lai.abiName = ba.abilityName;
            lai.target  = target;

            lai.caster = caster;
            lai.target = target;

            lai.parent = ba;

            lai.hitChance  = ba.ReturnAbilityHitChanceNum(caster.parent);
            lai.critChance = ba.ReturnAbilityCritChanceNum(caster.parent);

            if (caster != null)
            {
                caster.parent.combatInfo.CheckAffinity(target.parent);
            }
            if (target != null)
            {
                target.parent.combatInfo.CheckAffinity(target.parent);
            }


            if (target.parent.combatInfo.Absorbs(ba.affinity))
            {
                lai.bAbsorbs = true;
            }

            if (BattleGUI.bIsRunning)
            {
                var surroundInfo = BattleGUI.GetSurroundInfo();
                lai.surrAliesCaster   = surroundInfo.gbcAllies;
                lai.surrEnemiesCaster = surroundInfo.gbcEnemies;
                lai.surrAliesTarget   = surroundInfo.rbcAllies;
                lai.surrEnemiesTarget = surroundInfo.rbcEnemies;
                lai.critChance       += surroundInfo.critChance;
                lai.hitChance        += surroundInfo.hitChance;
            }

            switch (ct)
            {
            case CallType.Attack:
                break;

            case CallType.Area:
                lai.bCalledForArea = true;
                break;

            default:
                break;
            }

            return(lai);
        }
Esempio n. 27
0
        public void Update(GameTime gameTime, BattleGUI gui, Unit selectedTarget)
        {
            _selectedUnit = _units[gui.SelectedUnitIndex];

            FinisedMoving = false;

            switch (State)
            {
            case States.Selected:

                _previousMapPoint = _currentMapPoint;
                _currentMapPoint  = Map.Vector2ToPoint(Game1.GameMouse.Position_WithCamera);
                _currentMapPoint  = Helpers.Clamp(_currentMapPoint, new Point(0, 0), new Point(_mapManager.Map.GetWidth(), _mapManager.Map.GetHeight()));

                if (Game1.GameMouse.HasRightClicked && _selectedUnit != null && Game1.GameMouse.ClickableObjects.Where(c => !(c is Unit)).Count() == 0)
                {
                    State = States.Moving;
                }

                _mapManager.SetUnit(_selectedUnit);

                _previousPosition = _currentPosition;
                _currentPosition  = _selectedUnit.Position;

                if (_previousPosition != _currentPosition)
                {
                    _selectedUnit.PotentialPoints = new List <Tuple <int, Point> >();

                    var unitPoint = Map.Vector2ToPoint(_selectedUnit.TilePosition);

                    var distance = (_selectedUnit.UnitModel.Speed * _selectedUnit.UnitModel.Stamina);

                    var top  = (int)MathHelper.Max(unitPoint.Y - (distance + 1), 0);
                    var left = (int)MathHelper.Max(unitPoint.X - (distance + 1), 0);

                    var right  = (int)MathHelper.Min(unitPoint.X + (distance + 1), _mapManager.Map.GetWidth());
                    var bottom = (int)MathHelper.Min(unitPoint.Y + (distance + 1), _mapManager.Map.GetHeight());

                    for (var y = top; y < bottom; y++)
                    {
                        for (var x = left; x < right; x++)
                        {
                            var endPoint = new Point(x, y);

                            if (unitPoint == endPoint)
                            {
                                continue;
                            }

                            var pfResult = PathFinder.Find(_mapManager.Map.Get(), unitPoint, endPoint);

                            if (pfResult.Status == PathStatus.Valid && pfResult.Path.Count() <= distance)
                            {
                                _selectedUnit.PotentialPoints.Add(new Tuple <int, Point>(pfResult.Path.Count, pfResult.Path.Last()));
                            }
                        }
                    }
                }


                //// if there isn't a target
                //if (selectedTarget == null)
                //{
                //  SetUnitPath();
                //}
                //// if the target has changed
                //else if (_previousTarget != selectedTarget)
                //{
                //  SetUnitPath(selectedTarget);
                //}
                //// If the mouse has changed tile
                //else if (_previousMapPoint != _currentMapPoint)
                //{
                //  SetUnitPath(selectedTarget);
                //}

                //_previousTarget = selectedTarget;

                if ((_previousTarget != selectedTarget) ||
                    (selectedTarget == null) ||
                    (_previousMapPoint != _currentMapPoint) ||
                    (_previousAbility != _selectedUnit.UnitModel.Abilities.Get(gui.SelectedAbilityIndex)))
                {
                    _previousAbility = _selectedUnit.UnitModel.Abilities.Get(gui.SelectedAbilityIndex);

                    var ability = _selectedUnit.UnitModel.Abilities.Get(gui.SelectedAbilityIndex);

                    if (_previousTarget != selectedTarget)
                    {
                        _previousTarget = selectedTarget;
                        _selectedUnit.PotentialPaths = new List <List <Point> >();
                    }

                    if (ability != null)
                    {
                        if (ability.AbilityType == Lib.Models.AbilityModel.AbilityTypes.Close)
                        {
                            SetUnitPath(selectedTarget);
                        }
                    }
                    else
                    {
                        SetUnitPath(selectedTarget);
                    }
                }

                break;

            case States.Moving:

                _selectedUnit.Move();

                if (_selectedUnit.MovementPath.Count == 0)
                {
                    FinisedMoving = true;

                    _selectedUnit.UpdateStamina();
                    _mapManager.Refresh();

                    if (_selectedUnit.UnitModel.Stamina <= 0)
                    {
                        UpdateUnitIndex = true;
                    }


                    //_selectedUnit = null;
                    State = States.Selected;
                }

                break;

            default:
                break;
            }

            _unitPointerTile.Layer    = _selectedUnit.Layer -= 0.001f;
            _unitPointerTile.Position = _selectedUnit.TilePosition - new Vector2(4, 4);

            if (selectedTarget != null)
            {
                _targetPointerTile.Layer    = selectedTarget.Layer -= 0.001f;
                _targetPointerTile.Position = selectedTarget.TilePosition - new Vector2(4, 4);
            }
            else
            {
                _targetPointerTile.Layer = -1;
            }


            _unitPointer.Update(gameTime, _selectedUnit.Position);
        }
Esempio n. 28
0
	void Start() {
		battleGUI = gameObject.AddComponent<BattleGUI> ();
		//gamegui = gameObject.GetComponent<GameGUI>();
	}
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            //ResolutionUtility.toggleFullscreen();
            GraphicsDevice.Clear(Color.Red);
            GraphicsDevice.SetRenderTarget(gameRender);
            //   spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, SceneUtility.transform);
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, null);
            if (!bRunEditMode && !StartScreen.bIsRunning || (StartScreen.bIsRunning && startScreen.bFinishedLoading))
            {
                scenes[SceneUtility.currentScene].Draw(gameTime, spriteBatch);

                TextUtility.Draw(spriteBatch, "Pre-alpha combat demo v0.1.6", defaultFont, new Rectangle(1000, 650, 300, 100), TextUtility.OutLining.Left, Color.Gold, 1f, false, default(Matrix), Color.Silver, false);
                //if ((int)Screens.Editor != SceneUtility.currentScene)
                //{
                //    CursorUtility.Draw(spriteBatch);
                //}
            }
            if (StartScreen.bIsRunning)
            {
                startScreen.Draw(spriteBatch, gameRender);
                spriteBatch.End();
                spriteBatch.GraphicsDevice.SetRenderTarget(gameRender);
                spriteBatch.GraphicsDevice.Clear(Color.TransparentBlack);
                spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null, null);

                if (!OptionsMenu.bIsRunning)
                {
                    spriteBatch.Draw(startScreen.getRender(), gameRender.Bounds, Color.White);
                }
                else
                {
                    spriteBatch.Draw(OptionsMenu.getRender(), gameRender.Bounds, Color.White);
                }
                BattleGUI.DrawCursor(spriteBatch, KeyboardMouseUtility.uiMousePos.ToVector2(), 1f);

                TextUtility.Draw(spriteBatch, "Pre-alpha combat demo v0.1.6", defaultFont, new Rectangle(1000, 650, 300, 100), TextUtility.OutLining.Left, Color.Gold, 1f, false, default(Matrix), Color.Silver, false);

                spriteBatch.End();
            }

            spriteBatch.End();

            //if (bRunEditMode)
            //{
            //    ScripTestingScene.Draw(spriteBatch);
            //}
            //ResolutionUtility.toggleFullscreen();
            GraphicsDevice.SetRenderTarget(null);
            Matrix m = Matrix.CreateTranslation(0, 0, 1) * Matrix.CreateScale(ResolutionUtility.stdScale.X, ResolutionUtility.stdScale.Y, 1);

            m.M11 = 1.0f;
            m.M22 = 1.0f;
            if (graphics.IsFullScreen)
            {
                Rectangle targetDrawInFullScreen = new Rectangle(((int)monitorSize.X - (int)ResolutionUtility.WindowSizeBeforeFullScreen.X) / 2, ((int)monitorSize.Y - (int)ResolutionUtility.WindowSizeBeforeFullScreen.Y) / 2, (int)ResolutionUtility.WindowSizeBeforeFullScreen.X, (int)ResolutionUtility.WindowSizeBeforeFullScreen.Y);
                spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null);
                // spriteBatch.Draw(gameRender, targetDrawInFullScreen, gameRender.Bounds, Color.White);
                spriteBatch.Draw(gameRender, new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight), Color.White);
                spriteBatch.End();

                //spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null, null, SceneUtility.transform);
                //spriteBatch.Draw(gameRender, new Rectangle(0,0,1366,768), Color.White);
                //spriteBatch.End();

                //spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null, null, null);
                //spriteBatch.Draw(gameRender, gameRender.Bounds, Color.White);
                //spriteBatch.End();
            }
            else
            {
                spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null);
                // spriteBatch.Draw(gameRender, gameRender.Bounds, Color.White);
                // Rectangle targetDrawInFullScreen = new Rectangle(((int)monitorSize.X - (int)ResolutionUtility.WindowSizeBeforeFullScreen.X) / 2, ((int)monitorSize.Y - (int)ResolutionUtility.WindowSizeBeforeFullScreen.Y) / 2, (int)ResolutionUtility.WindowSizeBeforeFullScreen.X, (int)ResolutionUtility.WindowSizeBeforeFullScreen.Y);
                spriteBatch.Draw(gameRender, new Rectangle(0, 0, (int)ResolutionUtility.WindowSizeBeforeFullScreen.X, (int)ResolutionUtility.WindowSizeBeforeFullScreen.Y), Color.White);
                spriteBatch.End();
            }
            spriteBatch.End();
            base.Draw(gameTime);
        }
Esempio n. 30
0
    public void deselectItem(Image overlayObject)
    {
        if (selectedItem == null)
        {
            setLootInteractable(true);
            return;
        }
        CharacterSheet cs         = selectedCharacter.characterSheet;
        Item           i          = selectedItem.GetComponent <InventoryItem>().item;
        InventorySlot  insertSlot = (originalSlot == InventorySlot.Trap || originalSlot == InventorySlot.Turret ? InventorySlot.None : originalSlot);

        if (overlayObjects.Count > 0)
        {
            InventorySlot sl = overlayObjects[0].GetComponent <InventoryItem>().slot;
            if (sl == InventorySlot.None)
            {
                insertSlot = sl;
            }
            else if (BaseManager.trapTurretInventorySlots.Contains(sl))
            {
                if (baseManager.canInsertItem(i, sl))
                {
                    insertSlot = sl;
                }
            }
            else if (UnitGUI.armorSlots.Contains(sl))
            {
                if (cs.characterLoadout.canInsertItemInSlot(sl, i, originalSlot))
                {
                    insertSlot = sl;
                }
            }
            else if (UnitGUI.inventorySlots.Contains(sl))
            {
                Vector2 vSlot = UnitGUI.getIndexOfSlot(sl);
                int     oSlot = UnitGUI.getLinearIndexFromIndex(vSlot);
                vSlot -= selectedCell;
                int iSlot = UnitGUI.getLinearIndexFromIndex(vSlot);
                if (iSlot >= 0 && iSlot < 16 && cs.inventory.canInsertItemInSlot(i, vSlot))
                {
                    insertSlot = UnitGUI.getInventorySlotFromIndex(vSlot);
                }
                else if (oSlot >= 0 && oSlot < 16)
                {
                    Item inSlot = cs.inventory.inventory[oSlot].getItem();
                    if (inSlot != null && cs.inventory.itemCanStackWith(inSlot, i))
                    {
                        insertSlot = sl;
                    }
                }
            }
        }
        ActionType at = Inventory.getActionTypeForMovement(originalSlot, insertSlot);

        if (!canUseActionType(at))
        {
            insertSlot = originalSlot;
        }
//		if (selectedUnit != null) {
//			if ((at == ActionType.Minor && selectedUnit.minorsLeft <= 0) || (at == ActionType.Standard && selectedUnit.usedStandard) || (at == ActionType.Movement && selectedUnit.usedMovement)) return;
//		}
        if (UnitGUI.armorSlots.Contains(insertSlot))
        {
            Item       i2      = cs.characterLoadout.getItemInSlot(insertSlot);
            GameObject oldItem = null;
            if (i2 != null)
            {
                oldItem = getArmourParent(insertSlot).transform.FindChild("InventoryItem").gameObject;
            }
            cs.characterLoadout.setItemInSlot(insertSlot, i);
            Vector2    size         = i.getSize() * 32.0f;
            GameObject armourParent = getArmourParent(insertSlot);
            selectedItem.transform.SetParent(armourParent.transform, false);
            Vector2 v = new Vector2();
            v.x = 32.0f - size.x / 2.0f;
            if (size.y >= 64.0f)
            {
                v.y = -64.0f + size.y;
            }
            else
            {
                v.y = -32.0f + size.y / 2.0f;
            }
            selectedItem.GetComponent <RectTransform>().anchoredPosition = v;
            selectedItem.GetComponent <InventoryItem>().slot             = originalSlot;
            GameObject    canv = armourParent.transform.FindChild("Canvas").gameObject;         //.FindChild("Overlay");
            RectTransform rt   = canv.GetComponent <RectTransform>();
            rt.anchoredPosition = v;
            rt.sizeDelta        = size;
            i = i2;
            if (i != null)
            {
                selectedItem = oldItem;
                InventorySlot sl    = originalSlot;
                Vector2       vSlot = UnitGUI.getIndexOfSlot(sl);
                //	vSlot -= selectedCell;
                sl = UnitGUI.getInventorySlotFromIndex(vSlot);
                int iSlot = UnitGUI.getLinearIndexFromIndex(vSlot);
                Debug.Log("Drop has item: " + sl + "  " + vSlot + "   " + iSlot + "  " + selectedCell);
                Item inSlot = (iSlot < 0 || iSlot >= 16 ? null : cs.inventory.inventory[iSlot].getItem());
                if (cs.inventory.canInsertItemInSlot(i, vSlot) || (inSlot != null && cs.inventory.itemCanStackWith(inSlot, i)))
                {
                    insertSlot = sl;
                }
                else
                {
                    foreach (InventorySlot sl2 in UnitGUI.inventorySlots)
                    {
                        sl     = sl2;
                        vSlot  = UnitGUI.getIndexOfSlot(sl);
                        iSlot  = UnitGUI.getLinearIndexFromIndex(vSlot);
                        inSlot = cs.inventory.inventory[iSlot].getItem();
                        if (cs.inventory.canInsertItemInSlot(i, vSlot) || (inSlot != null && cs.inventory.itemCanStackWith(inSlot, i)))
                        {
                            insertSlot = sl;
                            break;
                        }
                    }
                }
                Debug.Log("Drop has item2: " + insertSlot + "  " + vSlot + "   " + iSlot + "  " + selectedCell);
                selectedCell = new Vector2(0, 0);
            }
            if (selectedUnit != null)
            {
                selectedUnit.idleAnimation(false);
                selectedUnit.Invoke("beginIdle", 0.05f);
            }
        }
        else if (BaseManager.trapTurretInventorySlots.Contains(insertSlot) && !(i is Turret) && !(i is Trap))
        {
            Debug.Log("Trap Turret");
            Item       i2      = baseManager.getTrapTurretInSlot(insertSlot);
            GameObject oldItem = null;
            if (i2 != null)
            {
                oldItem = getArmourParent(insertSlot).transform.FindChild("InventoryItem").gameObject;
            }
            baseManager.setItemInSlot(insertSlot, i);
//			cs.characterLoadout.setItemInSlot(insertSlot,i);
            Vector2    size         = i.getSize() * 32.0f;
            GameObject armourParent = getArmourParent(insertSlot);
            selectedItem.transform.SetParent(armourParent.transform, false);
            Vector2 v = new Vector2();
            v.x = 32.0f - size.x / 2.0f;
            if (size.y >= 64.0f)
            {
                v.y = -64.0f + size.y;
            }
            else
            {
                v.y = -32.0f + size.y / 2.0f;
            }
            selectedItem.GetComponent <RectTransform>().anchoredPosition = v;
            selectedItem.GetComponent <InventoryItem>().slot             = originalSlot;
            GameObject    canv = armourParent.transform.FindChild("Canvas").gameObject;         //.FindChild("Overlay");
            RectTransform rt   = canv.GetComponent <RectTransform>();
            rt.anchoredPosition = v;
            rt.sizeDelta        = size;
            i = i2;
            if (i != null)
            {
                selectedItem = oldItem;
                InventorySlot sl    = originalSlot;
                Vector2       vSlot = UnitGUI.getIndexOfSlot(sl);
                //	vSlot -= selectedCell;
                sl = UnitGUI.getInventorySlotFromIndex(vSlot);
                int iSlot = UnitGUI.getLinearIndexFromIndex(vSlot);
                Debug.Log("Drop has item: " + sl + "  " + vSlot + "   " + iSlot + "  " + selectedCell);
                Item inSlot = (iSlot < 0 || iSlot >= 16 ? null : cs.inventory.inventory[iSlot].getItem());
                if (cs.inventory.canInsertItemInSlot(i, vSlot) || (inSlot != null && cs.inventory.itemCanStackWith(inSlot, i)))
                {
                    insertSlot = sl;
                }
                else
                {
                    foreach (InventorySlot sl2 in UnitGUI.inventorySlots)
                    {
                        sl     = sl2;
                        vSlot  = UnitGUI.getIndexOfSlot(sl);
                        iSlot  = UnitGUI.getLinearIndexFromIndex(vSlot);
                        inSlot = cs.inventory.inventory[iSlot].getItem();
                        if (cs.inventory.canInsertItemInSlot(i, vSlot) || (inSlot != null && cs.inventory.itemCanStackWith(inSlot, i)))
                        {
                            insertSlot = sl;
                            break;
                        }
                    }
                }
                Debug.Log("Drop has item2: " + insertSlot + "  " + vSlot + "   " + iSlot + "  " + selectedCell);
                selectedCell = new Vector2(0, 0);
            }
            if (!(baseManager.turretFrame == null || baseManager.turretApplicator == null || baseManager.turretGear == null || baseManager.energySource == null))
            {
                createTurret();
            }
            if (!(baseManager.trapFrame == null || baseManager.trapApplicator == null || baseManager.trapGear == null || baseManager.trigger == null))
            {
                createTrap();
            }

            if (selectedUnit != null)
            {
                selectedUnit.idleAnimation(false);
                selectedUnit.Invoke("beginIdle", 0.05f);
            }
        }
        else
        {
            Debug.Log("Insert Slot: " + insertSlot + "  Original: " + originalSlot);
        }
        if (UnitGUI.inventorySlots.Contains(insertSlot))
        {
            if (cs.inventory.canInsertItemInSlot(i, UnitGUI.getIndexOfSlot(insertSlot)))
            {
                cs.inventory.insertItemInSlot(i, UnitGUI.getIndexOfSlot(insertSlot));
                selectedItem.transform.SetParent(inventorySlots.transform, false);
                Vector2 v = 32.0f * UnitGUI.getIndexOfSlot(insertSlot);
                v.y *= -1;
                selectedItem.GetComponent <RectTransform>().anchoredPosition = v;
                selectedItem.GetComponent <InventoryItem>().slot             = insertSlot;
            }
            else
            {
                Vector2 vSlot  = UnitGUI.getIndexOfSlot(insertSlot);
                int     iSlot  = UnitGUI.getLinearIndexFromIndex(vSlot);
                Item    inSlot = cs.inventory.inventory[iSlot].getItem();
                if (inSlot != null && cs.inventory.itemCanStackWith(inSlot, i))
                {
                    cs.inventory.stackItemWith(inSlot, i);
                    GameObject[] obj = GameObject.FindGameObjectsWithTag("inventoryitem");
                    foreach (GameObject go in obj)
                    {
                        InventoryItem invP = go.GetComponent <InventoryItem>();
                        if (invP.item == inSlot)
                        {
                            invP.transform.FindChild("Text").GetComponent <Text>().text = (inSlot.stackSize() > 1 ? inSlot.stackSize() + "" : "");
                        }
                    }
                }
                GameObject.Destroy(selectedItem);
            }
        }
        if (insertSlot == InventorySlot.None)
        {
            if (currentLootTile != null)
            {
                currentLootTile.addItem(i);
                selectedItem.transform.SetParent(lootContent, false);
                selectedItem.GetComponent <InventoryItem>().slot         = insertSlot;
                selectedItem.GetComponent <LayoutElement>().ignoreLayout = false;
                selectedItem.GetComponent <CanvasGroup>().blocksRaycasts = true;
                selectedItem.transform.FindChild("Overlay").gameObject.SetActive(true);
            }
            else if (currentStash != null)
            {
                addLootItem(i, 1);
                foreach (Item s in i.stack)
                {
                    addLootItem(s);
                }
                currentStash.addItem(i);
                GameObject.Destroy(selectedItem);
            }
        }
        selectedItem = null;
        List <Image> hoveredCopy = new List <Image>(overlayObjects);

        foreach (Image im in hoveredCopy)
        {
            mouseHoverLeave(im);
            mouseHoverEnter(im);
        }
        if (inventoryHead != null)
        {
            setACText();
        }
        setLootInteractable(true);
        if (selectedUnit != null)
        {
            if (at == ActionType.Minor)
            {
                selectedUnit.useMinor(MinorType.Loot, false, false);
            }
            else if (at == ActionType.Standard)
            {
                selectedUnit.useStandard();
            }
            if (!selectedUnit.usedStandard)
            {
                StandardType[] standards = selectedUnit.getStandardTypes();
                if (!sameAsOldStandards(standards))
                {
                    BattleGUI.resetStandardButtons();
                }
            }
        }
        else
        {
            selectedCharacter.saveCharacter();
        }
    }
        static public void Update(List <ActionKey> keys)
        {
            if (TurnSet.bSelectingArea && EncounterInfo.currentTurn() != null && EncounterInfo.currentTurn().bIsPlayerTurnSet)
            {
                if (keys.Count != 0)
                {
                    AreaSelectContext(keys[keys.Count - 1]);
                }
            }
            else
            {
                if (!ScriptProcessor.bIsRunning && !LootScreen.IsRunning())
                {
                    if (BattleGUI.bIsRunning && EncounterInfo.encounterGroups.Count > 0 && !EncounterInfo.currentTurn().bIsEnemyTurnSet&& !BattleGUI.bIsAttacking && (Mouse.GetState().RightButton == ButtonState.Pressed || keys.Last().actionIndentifierString.Equals(Game1.cancelString) || keys.Last().actionIndentifierString.Equals(Game1.SettingsMenu)) && !KeyboardMouseUtility.AnyButtonsPressed())
                    {
                        KeyboardMouseUtility.bPressed = true;
                        BattleGUI.bChooseAbility      = false;
                        BattleGUI.EndWithoutAttacking();
                    }

                    if ((PlayerController.selectedSprite == null && EncounterInfo.encounterGroups.Count != 0 && EncounterInfo.currentTurn().bIsPlayerTurnSet&& !EncounterInfo.currentTurn().bPlayerTurnEnemyOverriden) || (EncounterInfo.encounterGroups.Count != 0 && EncounterInfo.currentTurn().selectedCharTurn == null && CombatProcessor.bMainCombat && EncounterInfo.currentTurn().bIsPlayerTurnSet&& !EncounterInfo.currentTurn().bPlayerTurnEnemyOverriden))
                    {
                        if (keys.Count != 0)
                        {
                            GlobalControls(keys);
                            NoSpriteSelectedControls(keys[keys.Count - 1]);
                            KeyboardMouseUtility.bPressed = true;
                        }
                    }
                    else if (selectedChar != null)
                    {
                        if (keys.Count != 0)
                        {
                            GlobalControls(keys);
                            SpriteSelectedControls(keys[keys.Count - 1]);
                            KeyboardMouseUtility.bPressed = true;
                        }
                        selectedChar = (BaseCharacter)PlayerController.selectedSprite;
                    }
                    else if (selectedChar == null && PlayerController.selectedSprite != null || (EncounterInfo.encounterGroups.Count != 0 && !EncounterInfo.currentTurn().bIsPlayerTurnSet))
                    {
                        selectedChar = (BaseCharacter)PlayerController.selectedSprite;
                        if (keys.Count != 0)
                        {
                            GlobalControls(keys);
                            SpriteSelectedControls(keys[keys.Count - 1]);
                            KeyboardMouseUtility.bPressed = true;
                        }
                    }
                    else if (BattleGUI.bIsRunning)
                    {
                        if (keys.Count != 0)
                        {
                            //GlobalControls(keys);
                            SpriteSelectedControls(keys[keys.Count - 1]);
                            KeyboardMouseUtility.bPressed = true;
                        }
                    }
                }
                else if (LootScreen.IsRunning())
                {
                    if (LootScreen.WaitingForKeyPress())
                    {
                        if (keys.Count != 0)
                        {
                            LootScreenKeys(keys[keys.Count - 1]);
                            KeyboardMouseUtility.bPressed = true;
                        }
                    }
                }
            }
        }
Esempio n. 32
0
        public override void LoadContent()
        {
            _walls = new List <Sprites.Sprite>()
            {
                new Sprites.Sprite(Content.Load <Texture2D>("Walls/Wall_001"))
                {
                    TilePosition = Map.PointToVector2(5, 0),
                },
                new Sprites.Sprite(Content.Load <Texture2D>("Cover/Crate"))
                {
                    TilePosition = Map.PointToVector2(3, 6),
                },
                new Sprites.Sprite(Content.Load <Texture2D>("Cover/Crate"))
                {
                    TilePosition = Map.PointToVector2(5, 7),
                },
            };

            int id = _units.Select(c => c.UnitModel.Id).OrderBy(c => c).Last() + 1;

            _enemies = new List <Unit>()
            {
                new Enemy(Content.Load <Texture2D>("Units/Enemies/Egg"))
                {
                    TilePosition = Map.PointToVector2(7, 7),
                    UnitModel    = new Lib.Models.UnitModel()
                    {
                        Id       = id++,
                        Armour   = 0,
                        Health   = 5,
                        Speed    = 2,
                        Name     = "Stu",
                        UnitType = Lib.Models.UnitModel.UnitTypes.Enemy,
                    },
                },
                new Enemy(Content.Load <Texture2D>("Units/Enemies/Egg"))
                {
                    TilePosition = Map.PointToVector2(3, 7),
                    UnitModel    = new Lib.Models.UnitModel()
                    {
                        Id       = id++,
                        Armour   = 0,
                        Health   = 5,
                        Speed    = 2,
                        Name     = "Frank",
                        UnitType = Lib.Models.UnitModel.UnitTypes.Enemy,
                    },
                },
                new Enemy(Content.Load <Texture2D>("Units/Enemies/Egg"))
                {
                    TilePosition = Map.PointToVector2(9, 6),
                    UnitModel    = new Lib.Models.UnitModel()
                    {
                        Id       = id++,
                        Armour   = 0,
                        Health   = 5,
                        Speed    = 2,
                        Name     = "Jim",
                        UnitType = Lib.Models.UnitModel.UnitTypes.Enemy,
                    },
                },
            };

            _mapManager = new MapManager(Content);

            _mapManager.Refresh = () =>
            {
                _mapManager.Map.Clear();

                foreach (var sprite in _units)
                {
                    _mapManager.Map.AddItem(sprite.TileRectangle);
                }

                foreach (var sprite in _enemies)
                {
                    _mapManager.Map.AddItem(sprite.TileRectangle);
                }

                foreach (var sprite in _walls)
                {
                    _mapManager.Map.AddItem(sprite.TileRectangle);
                }

                _mapManager.Map.Write();
            };

            var images = new List <string>()
            {
                "Stone_01",
                "Stone_02",
                "Stone_03",
                "Stone_04",
            };

            _backgroundTiles = new List <Sprites.Sprite>();

            for (int y = 0; y < _mapManager.Map.GetHeight(); y++)
            {
                for (int x = 0; x < _mapManager.Map.GetWidth(); x++)
                {
                    //_backgroundTiles.Add(new Sprites.Sprite(Content.Load<Texture2D>($"Tiles/Stone/{images[BaseGame.Random.Next(0, images.Count)]}"))
                    _backgroundTiles.Add(new Sprites.Sprite(Content.Load <Texture2D>($"Tiles/Floor"))
                    {
                        HasFixedLayer = true,
                        Layer         = 0,
                        TilePosition  = Map.PointToVector2(x, y + 1) // TODO: Figure out why I've added +1
                    });
                }
            }

            _mapManager.Refresh();

            _unitManager = new UnitManager(_units, _mapManager);
            _unitManager.LoadContent(Content);

            _gui = new BattleGUI(_gameModel, _units.Select(c => c.UnitModel).ToList());
            _gui.UnitsGroup.OnButtonChange     = OnUnitSelect;
            _gui.AbilitiesGroup.OnButtonChange = OnAbilitySelect;
            _gui.TargetsGroup.OnButtonChange   = OnTargetSelect;

            _camera = new Camera()
            {
                Position = new Vector2(BaseGame.ScreenWidth / 2, BaseGame.ScreenHeight / 2),
            };

            _font = Content.Load <SpriteFont>("Fonts/Font");

            OnUnitSelect();
        }
Esempio n. 33
0
 void Start()
 {
     allPokemon      = new List <Transform>();
     targetedPokemon = null;
     battleGUI       = gameObject.AddComponent <BattleGUI> ();
 }
Esempio n. 34
0
	void Start(){
		pokemonObj = GetComponent<PokemonObj>();
		pokemonObj.pokemon.pp = 1;
		battleGUI = Player.battleGUI;
	}
Esempio n. 35
0
 void Start()
 {
     battleGui     = gameObject.GetComponent <BattleGUI> ();
     announcements = gameObject.GetComponentInChildren <Announcements> ();
 }
Esempio n. 36
0
 //GameGUI gamegui = new GameGUI();
 void Awake()
 {
     pokemonObj = GetComponent <PokemonObj> ();
     battleGUI  = new BattleGUI(pokemonObj);
 }