Пример #1
0
    public void SetFieldTargets(int teamPos, Battle battleModel)
    {
        activeTargetBtns = new List <BTLUI_ButtonFieldTarget>();
        HideAllButtons();
        CleanAllButtons();

        List <BattlePosition> allPositions = battleModel.GetAllBattlePositions();

        for (int i = 0; i < allPositions.Count; i++)
        {
            BattlePosition curPos = allPositions[i];
            BattleTeam     team   = battleModel.GetTeamFromBattlePosition(curPos);
            bool           isAlly = (teamPos == curPos.teamPos);

            BTLUI_ButtonFieldTarget curBtn = GetFieldTargetButton(
                position: curPos,
                teamPerspective: teamPos,
                battleModel: battleModel);

            if (curBtn != null)
            {
                CreateFieldTargetBtn(curPos, battleModel, curBtn);
                activeTargetBtns.Add(curBtn);
                curBtn.gameObject.SetActive(true);
            }
        }
    }
Пример #2
0
    public BTLUI_ButtonFieldTarget GetFieldTargetButton(BattlePosition position, int teamPerspective, Battle battleModel)
    {
        BattleTeam team   = battleModel.GetTeamFromBattlePosition(position);
        bool       isAlly = (teamPerspective == position.teamPos);

        BTLUI_ButtonFieldTarget curBtn =

            // singles battle
            (team.teamMode == BattleTeam.TeamMode.Single) ? (isAlly ? targetBtnNearSingle : targetBtnFarSingle)

            // doubles battle
            : (team.teamMode == BattleTeam.TeamMode.Double) ?
            (isAlly ?
             ((position.battlePos == 0) ? targetBtnNearDouble0 : targetBtnNearDouble1)
                    : ((position.battlePos == 0) ? targetBtnFarDouble0 : targetBtnFarDouble1))

            // triples battle
            : (team.teamMode == BattleTeam.TeamMode.Triple) ?
            (isAlly ?
             ((position.battlePos == 0) ? targetBtnNearTriple0
                        : (position.battlePos == 1) ? targetBtnNearTriple1 : targetBtnNearTriple2)
                    : ((position.battlePos == 0) ? targetBtnFarTriple0
                        : (position.battlePos == 1) ? targetBtnFarTriple1 : targetBtnFarTriple2))
            : null;

        return(curBtn);
    }
Пример #3
0
        public void SetFieldTargets(
            int teamPos,
            PBS.Battle.View.Model battleModel)
        {
            activeTargetBtns = new List <Panels.FieldTargetButton>();
            HideAllButtons();
            CleanAllButtons();

            List <BattlePosition> allPositions = battleModel.GetAllBattlePositions();

            for (int i = 0; i < allPositions.Count; i++)
            {
                BattlePosition curPos = allPositions[i];
                PBS.Battle.View.WifiFriendly.Team team = battleModel.GetMatchingTeam(curPos.teamPos);
                bool isAlly = (teamPos == curPos.teamPos);

                Panels.FieldTargetButton curBtn = GetFieldTargetButton(
                    position: curPos,
                    teamPerspective: teamPos,
                    battleModel: battleModel);

                if (curBtn != null)
                {
                    CreateFieldTargetBtn(curPos, battleModel, curBtn);
                    activeTargetBtns.Add(curBtn);
                    curBtn.gameObject.SetActive(true);
                }
            }
        }
Пример #4
0
        public Panels.FieldTargetButton GetFieldTargetButton(
            BattlePosition position,
            int teamPerspective,
            PBS.Battle.View.Model battleModel)
        {
            PBS.Battle.View.WifiFriendly.Team team = battleModel.GetMatchingTeam(position.teamPos);
            bool isAlly = (teamPerspective == position.teamPos);

            Panels.FieldTargetButton curBtn =

                // singles battle
                (team.teamMode == TeamMode.Single) ? (isAlly ? targetBtnNearSingle : targetBtnFarSingle)

                // doubles battle
                : (team.teamMode == TeamMode.Double) ?
                (isAlly ?
                 ((position.battlePos == 0) ? targetBtnNearDouble0 : targetBtnNearDouble1)
                        : ((position.battlePos == 0) ? targetBtnFarDouble0 : targetBtnFarDouble1))

                // triples battle
                : (team.teamMode == TeamMode.Triple) ?
                (isAlly ?
                 ((position.battlePos == 0) ? targetBtnNearTriple0
                            : (position.battlePos == 1) ? targetBtnNearTriple1 : targetBtnNearTriple2)
                        : ((position.battlePos == 0) ? targetBtnFarTriple0
                            : (position.battlePos == 1) ? targetBtnFarTriple1 : targetBtnFarTriple2))
                : null;
            return(curBtn);
        }
Пример #5
0
        public void HighlightFieldTargets(BattlePosition userPos, List <BattlePosition> targetPositions)
        {
            backBtn.UnselectSelf();
            promptText.text = "Choose a target by scrolling left or right.";
            List <Panels.FieldTargetButton> fieldTargetBtns = activeTargetBtns;

            for (int i = 0; i < fieldTargetBtns.Count; i++)
            {
                bool posWasTargeted             = false;
                Panels.FieldTargetButton curBtn = fieldTargetBtns[i];
                BattlePosition           curPos = fieldTargetBtns[i].position;

                for (int k = 0; k < targetPositions.Count; k++)
                {
                    if (targetPositions[k].IsTheSameAs(curPos))
                    {
                        posWasTargeted = true;
                        break;
                    }
                }

                if (posWasTargeted)
                {
                    curBtn.SelectSelf();
                }
                else
                {
                    curBtn.UnselectSelf();
                    if (userPos.IsTheSameAs(curPos))
                    {
                        curBtn.image.color = curBtn.colorUser;
                    }
                }
            }
        }
Пример #6
0
 public BattleChoice()
 {
     choiceType = ChoiceType.NONE;
     pMove      = null;
     pSwitchTo  = null;
     target     = null;
     pItem      = null;
 }
Пример #7
0
        /// <summary>
        /// Returns a new battlechoice containing instructions to use the specified move on the specified target
        /// </summary>
        /// <param name="move">move to use</param>
        /// <param name="inTarget">target battleposition</param>
        /// <returns></returns>
        public static BattleChoice UseMove(ActiveMove move, BattlePosition inTarget)
        {
            BattleChoice choice = new BattleChoice();

            choice.choiceType = ChoiceType.MOVE;
            choice.target     = inTarget;
            choice.pMove      = move;

            return(choice);
        }
Пример #8
0
 public void addCharacterToTeam(Character character, bool isInFront, BattlePosition position)
 {
     if (_team.Count < MAX_TEAM_SIZE)
     {
         _team.Add(new TeamSlot()
         {
             character = character, frontPosition = isInFront, battlePosition = position
         });
     }
 }
Пример #9
0
        public static BattleChoice UseItem(Item item, BattlePosition inTarget)
        {
            BattleChoice choice = new BattleChoice();

            choice.choiceType = ChoiceType.ITEM;
            choice.pItem      = item;
            choice.target     = inTarget;

            return(choice);
        }
Пример #10
0
 public bool IsTargetingPosition(BattlePosition position)
 {
     for (int i = 0; i < wishPositions.Count; i++)
     {
         if (wishPositions[i].IsTheSameAs(position))
         {
             return(true);
         }
     }
     return(false);
 }
Пример #11
0
 public static BattlePosition popPosition()
 {
     positions.Reverse();
     if (positions.Count > 0)
     {
         lastPosition = positions.ElementAt(0);
         positions.RemoveAt(0);
         return(lastPosition);
     }
     return(null);
 }
Пример #12
0
    public void CreateFieldTargetBtn(BattlePosition position, Battle battleModel, BTLUI_ButtonFieldTarget btn)
    {
        btn.position = position;
        Pokemon pokemon = battleModel.GetPokemonAtPosition(position);

        btn.RefreshSelf(active: pokemon != null);
        if (pokemon != null)
        {
            btn.nameTxt.text = pokemon.nickname;
            PokemonGender gender = pokemon.gender;
            if (gender != PokemonGender.Genderless)
            {
                btn.nameTxt.text += (gender == PokemonGender.Male) ? " <color=#8080FF>♂</color>"
                    : " <color=#FF8080>♀</color>";
            }

            btn.lvlTxt.text = "<color=yellow>Lv</color>" + pokemon.level;

            StatusCondition condition = pokemon.nonVolatileStatus;
            if (condition.statusID == "healthy")
            {
                btn.statusTxt.text = "";
            }
            else
            {
                btn.statusTxt.text = condition.data.shortName;
            }

            float hpPercent = pokemon.HPPercent;
            btn.hpBar.fillAmount = hpPercent;

            btn.hpBar.color = (hpPercent > 0.5f) ? btn.hpHigh
                : (hpPercent > 0.25f) ? btn.hpMed
                : btn.hpLow;

            // draw icon
            string drawPath = "pokemonSprites/icon/" + pokemon.data.displayID;
            btn.icon.sprite = BattleAssetLoader.instance.nullPokemonIconSprite;
            if (BattleAssetLoader.instance.loadedPokemonSprites.ContainsKey(drawPath))
            {
                btn.icon.sprite = BattleAssetLoader.instance.loadedPokemonSprites[drawPath];
            }
            else
            {
                StartCoroutine(BattleAssetLoader.instance.LegacyLoadPokemon(
                                   pokemon: pokemon,
                                   useicon: true,
                                   imagePokemon: btn.icon
                                   ));
            }
        }
    }
Пример #13
0
    // Clone
    public static BattlePosition Clone(BattlePosition original)
    {
        if (original == null)
        {
            return(null);
        }
        BattlePosition clonePosition = new BattlePosition(
            teamPos: original.teamPos,
            battlePos: original.battlePos
            );

        return(clonePosition);
    }
Пример #14
0
        public void CreateFieldTargetBtn(
            BattlePosition position,
            PBS.Battle.View.Model battleModel,
            Panels.FieldTargetButton btn)
        {
            btn.position = position;
            PBS.Battle.View.WifiFriendly.Pokemon pokemon = battleModel.GetPokemonAtPosition(position);

            btn.RefreshSelf(active: pokemon != null);
            if (pokemon != null)
            {
                btn.nameTxt.text = pokemon.nickname;
                PokemonGender gender = pokemon.gender;
                if (gender != PokemonGender.Genderless)
                {
                    btn.nameTxt.text += (gender == PokemonGender.Male) ? " <color=#8080FF>♂</color>"
                        : " <color=#FF8080>♀</color>";
                }
                btn.lvlTxt.text = "<color=yellow>Lv</color>" + pokemon.level;

                btn.statusTxt.text = "";
                if (!string.IsNullOrEmpty(pokemon.nonVolatileStatus))
                {
                    StatusPKData statusData = StatusPKDatabase.instance.GetStatusData(pokemon.nonVolatileStatus);
                    btn.statusTxt.text = statusData.shortName;
                }

                float hpPercent = ((float)pokemon.currentHP) / pokemon.maxHP;
                btn.hpBar.fillAmount = hpPercent;

                btn.hpBar.color = (hpPercent > 0.5f) ? btn.hpHigh
                    : (hpPercent > 0.25f) ? btn.hpMed
                    : btn.hpLow;

                // draw icon
                string drawPath = "pokemonSprites/icon/" + PokemonDatabase.instance.GetPokemonData(pokemon.pokemonID).displayID;
                btn.icon.sprite = BattleAssetLoader.instance.nullPokemonIconSprite;
                if (BattleAssetLoader.instance.loadedPokemonSprites.ContainsKey(drawPath))
                {
                    btn.icon.sprite = BattleAssetLoader.instance.loadedPokemonSprites[drawPath];
                }
                else
                {
                    StartCoroutine(BattleAssetLoader.instance.LoadPokemon(
                                       pokemon: pokemon,
                                       useicon: true,
                                       imagePokemon: btn.icon
                                       ));
                }
            }
        }
Пример #15
0
        public PBS.Battle.View.WifiFriendly.Pokemon GetPokemonAtPosition(BattlePosition position)
        {
            List <PBS.Battle.View.WifiFriendly.Pokemon> allPokemon = GetPokemonFromAllTrainers();

            for (int i = 0; i < allPokemon.Count; i++)
            {
                if (allPokemon[i].teamPos == position.teamPos &&
                    allPokemon[i].battlePos == position.battlePos)
                {
                    return(allPokemon[i]);
                }
            }
            return(null);
        }
Пример #16
0
 public void Action(BattleActor[] member, BattlePosition aim, COM_ReportTarget[] props, TogetherCallBack finishCallBack, COM_ReportAction[] acitons)
 {
     GlobalInstanceFunction.Instance.OnDeadFinish += OnDealDeadFinish;
     resetBackCount_ = 0;
     dealStateCount_ = 0;
     simpleHitCount  = 0;
     includeChange   = 0;
     AttaclPanel.Instance.togetherHitCrl_.Open();
     togetherFinCallBack_ = finishCallBack;
     members_             = member;
     props_     = props;
     aim_       = Battle.Instance.GetActorByIdx((int)aim);
     CurrentHp_ = aim_.battlePlayer.hpCrt_;
     ResetBack();
 }
Пример #17
0
    private float GetBasePositionValue(BattlePosition position)
    {
        switch (position)
        {
        case BattlePosition.Rear:
            return(3);

        case BattlePosition.Mid:
            return(2);

        case BattlePosition.Front:
        default:
            return(1);
        }
    }
Пример #18
0
    public void SwitchSelectedMoveTargetsTo(BattlePosition userPos, int chooseIndex, List <List <BattlePosition> > choices)
    {
        List <BattlePosition> targetPositions = choices[chooseIndex];

        string descText = "";

        if (targetPositions == null)
        {
            descText = "<<-  Back  ->>";
        }
        else
        {
            int optionNo = choices.Contains(null) ? chooseIndex : chooseIndex + 1;
            descText = "<<-  Option " + optionNo + "  ->>";
        }
        StartCoroutine(DrawTextInstant(text: descText, textBox: fieldTargetTxt));

        for (int i = 0; i < fieldTargetBtns.Count; i++)
        {
            bool           posWasTargeted = false;
            BattlePosition curPos         = fieldTargetBtns[i].position;

            if (targetPositions != null)
            {
                for (int k = 0; k < targetPositions.Count; k++)
                {
                    if (targetPositions[k].IsTheSameAs(curPos))
                    {
                        posWasTargeted = true;
                        break;
                    }
                }
            }

            if (posWasTargeted)
            {
                SelectFieldTarget(fieldTargetBtns[i], true);
            }
            else
            {
                SelectFieldTarget(fieldTargetBtns[i], false);
                if (userPos.IsTheSameAs(curPos))
                {
                    fieldTargetBtns[i].image.color = fieldTargetBtns[i].colorUser;
                }
            }
        }
    }
Пример #19
0
 // Constructor
 public BattleFutureSightCommand(
     string pokemonID,
     string moveID,
     BattlePosition[] targetPositions,
     int turnsLeft = 0
     )
 {
     this.pokemonID       = pokemonID;
     this.moveID          = moveID;
     this.targetPositions = new List <BattlePosition>();
     for (int i = 0; i < targetPositions.Length; i++)
     {
         this.targetPositions.Add(BattlePosition.Clone(targetPositions[i]));
     }
     this.turnsLeft = turnsLeft;
 }
Пример #20
0
    public override void SwitchSelectedMoveTargetsTo(
        BattlePosition userPos,
        int chooseIndex,
        List <List <BattlePosition> > choices)
    {
        List <BattlePosition> choice = choices[chooseIndex];

        if (choice == null)
        {
            fieldTargetPanel.HighlightBackButton();
        }
        else
        {
            fieldTargetPanel.HighlightFieldTargets(userPos, choice);
        }
    }
Пример #21
0
 // Constructor
 public BattleWishCommand(
     string pokemonID,
     string moveID,
     BattlePosition[] wishPositions,
     int turnsLeft   = 0,
     int hpRecovered = 0
     )
 {
     this.pokemonID     = pokemonID;
     this.moveID        = moveID;
     this.wishPositions = new List <BattlePosition>();
     for (int i = 0; i < wishPositions.Length; i++)
     {
         this.wishPositions.Add(BattlePosition.Clone(wishPositions[i]));
     }
     this.turnsLeft   = turnsLeft;
     this.hpRecovered = hpRecovered;
 }
Пример #22
0
        private void DrawPlayerHealthBar(BattlePosition position, SpriteBatch spriteBatch)
        {
            if (position.pokemon == null)
            {
                return;
            }

            int currentHealth = position.pokemon.currentHealth;
            int maxHealth     = position.pokemon.maxHealth;
            int currentEXP    = position.pokemon.pokemon.currentExp;
            int goalEXP       = position.pokemon.pokemon.expAtLevel(position.pokemon.pokemon.level);


            Texture2D colour;

            if (currentHealth > (maxHealth / 2))
            {
                colour = green;
            }
            else if (currentHealth > (maxHealth / 10))
            {
                colour = orange;
            }
            else
            {
                colour = red;
            }

            //draw HPBar
            spriteBatch.Draw(playerHPBarTexture, playerHPBarRect, Color.White);
            //draw HP
            spriteBatch.Draw(colour, new Rectangle(playerHPBarRect.X + 73, playerHPBarRect.Y + 5, (int)(144.0 * ((double)currentHealth / (double)maxHealth)), 4), Color.White);
            //draw EXP
            spriteBatch.Draw(orange, new Rectangle(playerHPBarRect.X + 42, playerHPBarRect.Y + 19, (int)(217.0 * ((double)currentEXP / (double)goalEXP)), 2), Color.White);
            //draw Pokemon name
            spriteBatch.DrawString(font, position.pokemon.pokemon.Nickname, new Vector2(playerHPBarRect.X + 40, playerHPBarRect.Y - 15), Color.White);
            spriteBatch.DrawString(font, position.pokemon.pokemon.Nickname, new Vector2(playerHPBarRect.X + 41, playerHPBarRect.Y - 16), Color.Black);
            //draw Level
            spriteBatch.DrawString(font, "Lv. " + position.pokemon.pokemon.level, new Vector2(playerHPBarRect.X + 226, playerHPBarRect.Y - 15), Color.White);
            spriteBatch.DrawString(font, "Lv. " + position.pokemon.pokemon.level, new Vector2(playerHPBarRect.X + 227, playerHPBarRect.Y - 16), Color.Black);
            //draw HP Text
            spriteBatch.DrawString(font, currentHealth + "/" + maxHealth, new Vector2(playerHPBarRect.X + 226, playerHPBarRect.Y + 2), Color.White);
            spriteBatch.DrawString(font, currentHealth + "/" + maxHealth, new Vector2(playerHPBarRect.X + 227, playerHPBarRect.Y + 1), Color.Black);
        }
Пример #23
0
    // FIELD TARGETING
    public void SetFieldTargets(int teamPos)
    {
        List <BattlePosition> allPositions = battleModel.GetAllBattlePositions();

        for (int i = 0; i < allPositions.Count; i++)
        {
            BattlePosition curPos = allPositions[i];
            BattleTeam     team   = battleModel.GetTeamFromBattlePosition(curPos);
            bool           isAlly = (teamPos == curPos.teamPos);
            GameObject     spawn  = isAlly ? fieldTargetOptionObjNear : fieldTargetOptionObjFar;

            BTLUI_ButtonFieldTarget newBtn = Instantiate(fieldTargetBtnPrefab, spawn.transform);
            newBtn.InitializeSelf();

            switch (team.teamMode)
            {
            case BattleTeam.TeamMode.Single:
                newBtn.rectTransform.localPosition = new Vector3(0, 0);
                break;

            case BattleTeam.TeamMode.Double:
                float xPosDouble = isAlly ? -48f : 48f;
                if (curPos.battlePos == 1)
                {
                    xPosDouble = -xPosDouble;
                }
                newBtn.rectTransform.localPosition = new Vector3(xPosDouble, 0);
                break;

            case BattleTeam.TeamMode.Triple:
                float xPosTriple = isAlly ? -96f : 96f;
                xPosTriple += curPos.battlePos * (isAlly ? 96f : -96f);
                newBtn.rectTransform.localPosition = new Vector3(xPosTriple, 0);
                break;
            }
            CreateFieldTargetBtn(curPos, newBtn);
            fieldTargetBtns.Add(newBtn);
        }
    }
Пример #24
0
        private void DrawOpponentHealthBar(BattlePosition position, SpriteBatch spriteBatch)
        {
            if (position.pokemon == null)
            {
                return;
            }

            int currentHealth = position.pokemon.currentHealth;
            int maxHealth     = position.pokemon.maxHealth;
            int currentEXP    = position.pokemon.pokemon.currentExp;
            int goalEXP       = position.pokemon.pokemon.expAtLevel(position.pokemon.pokemon.level);

            Texture2D colour;

            if (currentHealth > (maxHealth / 2))
            {
                colour = green;
            }
            else if (currentHealth > (maxHealth / 10))
            {
                colour = orange;
            }
            else
            {
                colour = red;
            }

            //draw HPBar
            spriteBatch.Draw(opponentHPBarTexture, opponentHPBarRect, Color.White);
            //draw HP
            spriteBatch.Draw(colour, new Rectangle(opponentHPBarRect.X + 66, opponentHPBarRect.Y + 5, (int)(195.0 * ((double)currentHealth / (double)maxHealth)), 4), Color.White);
            //draw Pokemon name
            spriteBatch.DrawString(font, position.pokemon.pokemon.Nickname, new Vector2(opponentHPBarRect.X + 40, opponentHPBarRect.Y - 15), Color.White);
            spriteBatch.DrawString(font, position.pokemon.pokemon.Nickname, new Vector2(opponentHPBarRect.X + 41, opponentHPBarRect.Y - 16), Color.Black);
            //draw Level
            spriteBatch.DrawString(font, "Lv. " + position.pokemon.pokemon.level, new Vector2(opponentHPBarRect.X + 237, opponentHPBarRect.Y - 15), Color.White);
            spriteBatch.DrawString(font, "Lv. " + position.pokemon.pokemon.level, new Vector2(opponentHPBarRect.X + 238, opponentHPBarRect.Y - 16), Color.Black);
        }
Пример #25
0
 public BattleState(BattlePosition state) : this(state, null) { }
Пример #26
0
 private void DrawOpponentPokemon(BattlePosition battlePosition, SpriteBatch spriteBatch)
 {
     spriteBatch.Draw(battlePosition.frontTexture, opponentPokeRect, Color.White);
 }
Пример #27
0
 private void DrawPlayerPokemon(BattlePosition battlePosition, SpriteBatch spriteBatch)
 {
     spriteBatch.Draw(battlePosition.backTexture, playerPokeRect, Color.White);
 }
Пример #28
0
 public static void WriteBattleUtilityPosition(this NetworkWriter writer, BattlePosition obj)
 {
     writer.WriteInt32(obj.battlePos);
     writer.WriteInt32(obj.teamPos);
 }
Пример #29
0
 private static void insertTriggerable(BattlePosition b)
 {
     //Searches the Pokémon for any items or abilities that require immediate insertion in the triggerable stack.
 }
 public BattleState(BattlePosition state) : this(state, null)
 {
 }
 public BattleState(BattlePosition state, CarDetails driver)
 {
     this.State  = state;
     this.Driver = driver;
 }
Пример #32
0
 public BattleState(BattlePosition state, CarDetails driver)
 {
     this.State = state;
     this.Driver = driver;
 }