Example #1
0
    public BaseCharacterEntity SetCharacter(int position, BattleItem item)
    {
        var character = MakeCharacter(position, item) as CharacterEntity;

        if (character == null)
        {
            return(null);
        }

        RpguiCharacterStats rpguiStats;

        if (UIStats.TryGetValue(position, out rpguiStats))
        {
            Destroy(rpguiStats.gameObject);
            UIStats.Remove(position);
        }

        if (Manager != null)
        {
            //rpguiStats = Instantiate(Manager.RpguiCharacterStatsPrefab, Manager.uiCharacterStatsContainer);
            rpguiStats = Instantiate(Manager.RpguiCharacterStatsPrefab, character.transform);
            rpguiStats.transform.localScale    = Vector3.one;
            rpguiStats.transform.localPosition = new Vector3(0, 0, 0);
            rpguiStats.character          = character;
            character.RpguiCharacterStats = rpguiStats;
        }

        return(character);
    }
Example #2
0
    public void NextWave()
    {
        BattleItem[] characters;
        StageFoe[]   foes;
        var          wave = GetWave(CurrentWave);

        if (!wave.useRandomFoes && wave.foes.Length > 0)
        {
            foes = wave.foes;
        }
        else
        {
            foes = GetRandomFoes();
        }

        characters = new BattleItem[foes.Length];
        for (var i = 0; i < characters.Length; ++i)
        {
            var foe = foes[i];
            if (foe != null && !string.IsNullOrEmpty(foe.characterId))
            {
                var character = new BattleItem(ICharacter.DataMap[foe.characterId], foe.level, GetRandomFoesType());
                characters[i] = character;
            }
        }

        if (characters.Length == 0)
        {
            Debug.LogError("Missing Foes Data");
        }

        foeFormation.SetCharacters(characters);
        foeFormation.Revive();
        ++CurrentWave;
    }
Example #3
0
        private void StealItem(BattleEnemy enemy, Int32 itemIndex)
        {
            Byte itemId = enemy.StealableItems[itemIndex];

            if (itemId == Byte.MaxValue)
            {
                UiState.SetBattleFollowFormatMessage(BattleMesages.CouldNotStealAnything);
                return;
            }

            enemy.StealableItems[itemIndex] = Byte.MaxValue;
            GameState.Thefts++;

            BattleItem.AddToInventory(itemId);
            UiState.SetBattleFollowFormatMessage(BattleMesages.Stole, FF9TextTool.ItemName(itemId));
            if (_v.Caster.HasSupportAbility(SupportAbility2.Mug))
            {
                _v.Target.Flags   |= CalcFlag.HpAlteration;
                _v.Target.HpDamage = (Int16)(GameRandom.Next16() % (_v.Caster.Level * _v.Target.Level >> 1));
            }

            if (_v.Caster.HasSupportAbility(SupportAbility1.StealGil))
            {
                GameState.Gil += (UInt32)(GameRandom.Next16() % (1 + _v.Caster.Level * _v.Target.Level / 4));
            }
        }
Example #4
0
 public void SetupItemButton(BattleItem receivedItem, GeneralUiManager ui)
 {
     item           = receivedItem;
     uiManager      = ui;
     itemName.text  = item.itemName;
     itemPrice.text = item.price.ToString();
     itemRef        = new ItemReference(item.itemId, item.quantityHeld, item.itemType);
 }
Example #5
0
        public static BattleItem GenerateBattleItem()
        {
            BattleItem battleItem = new BattleItem();

            battleItem.AttackBonus  = RandomGenerator.GenerateRandomNumber();
            battleItem.DefenseBonus = RandomGenerator.GenerateRandomNumber();
            return(battleItem);
        }
Example #6
0
 // if a battle item is already set, its sprite must be changed to inactive, and then the new battle item can be set
 public void setItem(BattleItem newItem)
 {
     if (this.battleItem != null)
     {
         this.battleItem.itemSprite = this.battleItem.inactive;
     }
     this.battleItem = newItem;
 }
Example #7
0
 // since the item sprite may be changed after initiation, it is determined in Update.
 void Update()
 {
     // if the item is a battle item, ensure that its Inactive sprite is shown (active has a red mark and is used in the bag to identify the active item)
     if (item.GetType() == typeof(BattleItem))
     {
         battleItem      = (BattleItem)item;
         item.itemSprite = battleItem.inactive;
     }
     GetComponent <SpriteRenderer>().sprite = item.itemSprite;
 }
Example #8
0
        public void Perform()
        {
            const Int32 oreItemId = (Int32)GemItem.Ore;

            _v.MagicAccuracy();
            _v.Target.PenaltyShellHitRate();
            if (_v.TargetCommand.TryMagicHit())
            {
                BattleItem.AddToInventory(oreItemId);
            }
        }
Example #9
0
    //復活の御魂を使用
    void useSoulOfRessurection()
    {
        BattleItem item = items.Find(x => x.item.itemName == "復活の御魂");

        //開放効果はターン1回まで
        if (!item.isUsed)
        {
            Debug.Log("御魂により復活!");
            showActionName("御魂の開放", player);
            player.hp = player.maxHp;
            item.useItemPassive();
        }
    }
Example #10
0
 //リストに従ってアイテムを置く
 public void setItems(List <string> itemList)
 {
     //TODO 戦闘をまたぐ場合アイテム個数は消耗していることがある
     items = new List <BattleItem>();
     foreach (string s in itemList)
     {
         Item       item    = ItemStore.getItemByName(s);
         BattleItem created = Instantiate <BattleItem>(itemPrefab, itemsContainer.transform);
         created.setItem(item);
         created.messageArea = messageArea;
         created.battle      = this;
         items.Add(created);
     }
 }
        private void RemoveItem()
        {
            Byte itemId = (Byte)_v.Command.HitRate;

            if (ff9item.FF9Item_GetCount(itemId) == 0)
            {
                UiState.SetBattleFollowFormatMessage(BattleMesages.CouldNotStealAnything);
            }
            else
            {
                BattleItem.RemoveFromInventory(itemId);
                UiState.SetBattleFollowFormatMessage(BattleMesages.WasStolen, FF9TextTool.ItemName(itemId));
            }
        }
Example #12
0
        public void Perform()
        {
            _v.Target.Flags   |= CalcFlag.HpAlteration | CalcFlag.HpRecovery | CalcFlag.MpAlteration | CalcFlag.MpRecovery;
            _v.Target.HpDamage = (Int16)(_v.Target.MaximumHp >> 1);
            _v.Target.MpDamage = (Int16)(_v.Target.MaximumMp >> 1);

            BattleItem item = _v.Command.Item;

            if (item.HitRate < GameRandom.Next16() % 100)
            {
                UiState.SetBattleFollowFormatMessage(BattleMesages.Bitten);
                _v.Target.TryAlterStatuses(item.Status, false);
            }
        }
Example #13
0
 public void StoreItemInInventory(BattleItem item)
 {
     for (int cont = 0; cont < battleItems.Count; cont++)
     {
         if (item.itemId == battleItems[cont].itemId)
         {
             battleItems[cont].quantityHeld += item.quantityHeld;
         }
         else if (cont == battleItems.Count - 1 && item.itemId != battleItems[cont].itemId)
         {
             battleItems.Add(item);
         }
     }
     allItems.Add(item);
 }
Example #14
0
    //リストに従ってアイテムを置く
    public void setItems()
    {
        foreach (Transform n in this.itemsContainer.transform)
        {
            Destroy(n.gameObject);
        }

        foreach (string s in status.items)
        {
            Item       item    = ItemStore.getItemByName(s);
            BattleItem created = Instantiate <BattleItem>(itemPrefab, itemsContainer.transform);
            created.setItem(item);
            created.messageArea = messageArea;
        }
    }
Example #15
0
    public BaseCharacterEntity MakeCharacter(int position, BattleItem item)
    {
        //if (position < 0 || position >= containers.Length || item == null || item.CharacterData == null)
        //return null;


        var container = containers[position];

        container.RemoveAllChildren();

        var character = Instantiate(GameInstance.Singleton.model);

        character.SetFormation(this, position);
        character.Item                    = item;
        Characters[position]              = character;
        character.transform.rotation      = Quaternion.Euler(0, 0, 0);
        character.transform.localRotation = Quaternion.Euler(0, 0, 0);
        (character as CharacterEntity).customSkillActionLogic.InitBattleCustomSkill();
        return(character);
    }
        public override void StartChoosingAction(BattleData battleData)
        {
            base.StartChoosingAction(battleData);

            if (actionHasBeenChosen)
            {
                return;
            }

            int  actionItemTargetIndex = activePokemonIndex;
            Item actionItem;

            List <BattleItem> validItems = new List <BattleItem>();

            foreach (BattleItem item in BattleItem.registry)
            {
                if (item.CheckCompatibility(GetPokemon()[actionItemTargetIndex]))
                {
                    validItems.Add(item);
                }
            }

            if (validItems.Count > 0)
            {
                actionItem = validItems[battleData.RandomRange(0, validItems.Count)];
            }
            else
            {
                Debug.LogWarning("No valid item found. Choosing item with id 0");
                actionItem = BattleItem.GetBattleItemById(0);
            }

            chosenAction = new Action(this)
            {
                type                    = Action.Type.UseItem,
                useItemItemToUse        = actionItem,
                useItemTargetPartyIndex = actionItemTargetIndex
            };

            actionHasBeenChosen = true;
        }
        public void Perform()
        {
            if (!_v.CheckHasCommandItem())
            {
                return;
            }

            Byte       itemId     = _v.Command.Power;
            BattleItem item       = BattleItem.Find(itemId);
            Byte       itemScript = item.ScriptId;

            MutableBattleCommand itemCommand = new MutableBattleCommand();

            itemCommand.Id        = BattleCommandId.Item;
            itemCommand.AbilityId = BattleAbilityId.Void;
            itemCommand.LoadAbility();
            itemCommand.AbilityId = (BattleAbilityId)itemId;

            SBattleCalculator.Calc(_v.Caster, _v.Target, itemCommand, itemScript);
            BattleItem.RemoveFromInventory(itemId);
        }
Example #18
0
    void AddButtons()
    {
        for (int i = 0; i < battles.Count; i++)
        {
            Button bt = Instantiate(btn);
            bt.transform.SetParent(transform, true);
            //bt.GetComponent<RectTransform> ().SetPositionAndRotation (new Vector3(0, -i*150, 0), Quaternion.identity);
            bt.GetComponent <RectTransform> ().localPosition = new Vector3(0, -i * 150, 0);
            RectTransform rt = bt.GetComponent <RectTransform> ();
            //			rt.SetInsetAndSizeFromParentEdge (RectTransform.Edge.Left, 0, 750);
            rt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, i * 150, 150);

            BattleItem  item  = bt.GetComponent <BattleItem> ();
            BattleModel model = battles[i];
            model.order = i + 1;
            item.Bind(model, this);
        }

        RectTransform rootRt = GetComponent <RectTransform> ();

        rootRt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, screenW);
        rootRt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, battles.Count * 150);
    }
Example #19
0
 private void DrawSprite(GraphicsBuffer buffer, int topRow, int leftColumn, BattleItem item, bool animating, int frame)
 {
     var body = animating ? animation[frame] : image;
     var walkingOffset = animating ? walkingOffsets[frame] : 0;
     foreach (var part in direction.Metadata().DrawOrder)
     {
         switch (part)
         {
         case SpritePart.Head:
             buffer.DrawItem(topRow, leftColumn, body);
             break;
         case SpritePart.OneHandedWeapon:
             if (item != null && !item.IsTwoHanded)
                 buffer.DrawItem(topRow + walkingOffset, leftColumn, item.Sprites[direction]);
             break;
         case SpritePart.TwoHandedWeapon:
             if (item != null && item.IsTwoHanded)
                 buffer.DrawItem(topRow + walkingOffset, leftColumn, item.Sprites[direction]);
             break;
         }
     }
 }
Example #20
0
 //アイテム
 public void useItem(BattleItem item)
 {
     consumeActionByItem(item.item.action, ActorType.PLAYER);
 }
Example #21
0
 public void Animate(GraphicsBuffer buffer, int topRow, int leftColumn, BattleItem item, int frame)
 {
     DrawSprite(buffer, topRow, leftColumn, item, true, frame);
 }
Example #22
0
 public void Render(GraphicsBuffer buffer, int topRow, int leftColumn, BattleItem item)
 {
     DrawSprite(buffer, topRow, leftColumn, item, false, 0);
 }
Example #23
0
        public IActionResult BattleItem(int id)
        {
            BattleItem model = this.dataService.GetObjectByPropertyValue <BattleItem>("Id", id);

            return(this.View(model));
        }
Example #24
0
    //ダメージ計算
    int calcDamage(BattleCharacter actor, BattleCharacter target, Effect effect, bool ignoreShield = false, bool isCheck = false)
    {
        //無敵状態だったらダメージは受けない 防御も消費しない
        if (target.hasBuff(Buff.BuffID.INVINCIBLE))
        {
            return(0);
        }

        //消魔印を持っている場合魔法ダメージは1(isCheckがついてる場合予測ダメージ計算でしかないのでスルーする)
        if (target == player && items.Exists(x => x.item.itemName == "消魔印") && effect.hasAttribute(Effect.Attribute.MAGIC) && !isCheck)
        {
            BattleItem item = items.Find(x => x.item.itemName == "消魔印");
            //開放効果はターン1回まで
            if (!item.isUsed)
            {
                showActionName("消魔印", player);
                item.useItemPassive();
                return(1);
            }
        }


        //ダメージ倍率
        float multiply = 1.0f;

        //攻撃倍率を乗算
        //魔法攻撃は魔力依存
        if (effect.hasAttribute(Effect.Attribute.MAGIC))
        {
            multiply *= actor.getMagicRate();
        }
        //魔法攻撃と明示されているもの以外はすべて物理攻撃である
        else
        {
            multiply *= actor.getAttackRate();

            //物理攻撃は相手側の防御Lvに応じてダメージカット
            multiply *= (1f - target.getNormalCutRate());
        }


        //物理攻撃で相手が防御してたら防御回数を減らしつつダメージ減衰
        if (!effect.hasAttribute(Effect.Attribute.MAGIC) && target.hasShield() && !ignoreShield)
        {
            multiply           *= (1f - target.getDefenceCutRate());
            target.shieldCount -= 1;
            //Debug.LogFormat("防御!{0}%ダメージカット", target.getDefenceCutRate()*100);
        }

        //特効枠
        //王撃 5ターン目以降のみつよい
        if (effect.hasAttribute(Effect.Attribute.KING) && turnCount >= 5)
        {
            //Debug.Log("王撃!7倍ダメージ");
            multiply *= 7;
        }
        //ぷち王撃 3ターン目以降のみつよい
        if (effect.hasAttribute(Effect.Attribute.PETIT_KING) && turnCount >= 3)
        {
            //Debug.Log("ぷち王撃!3倍ダメージ");
            multiply *= 3;
        }
        //即撃 1ターン目のみつよい
        if (effect.hasAttribute(Effect.Attribute.SKIP) && turnCount == 1)
        {
            //Debug.Log("即撃!2.5倍ダメージ");
            multiply *= 2.5f;
        }
        //ぷち即撃 2ターン目までつよい
        if (effect.hasAttribute(Effect.Attribute.PETIT_SKIP) && turnCount <= 2)
        {
            //Debug.Log("ぷち即撃!1.5倍ダメージ");
            multiply *= 1.5f;
        }
        //高揚 ダメージ2倍
        if (actor.hasBuff(Buff.BuffID.EXALTED))
        {
            multiply *= 2;
        }

        //雷→水チェック
        if (target.hasAttribute(CharacterAttribute.AttributeID.WATER) && effect.hasAttribute(Effect.Attribute.THUNDER))
        {
            multiply *= 2;
            //Debug.Log("雷特効!");
        }


        //効果量に倍率かけて端数落としたものを最終ダメージとする
        int finalDamage = (int)(effect.effectAmount * multiply);


        //Debug.LogFormat("{0}が{1}に{2}ダメージ!",actor.name,target.name,finalDamage);
        return(finalDamage);
    }
Example #25
0
 public void Render(GraphicsBuffer buffer, int topRow, int leftColumn, BattleItem item)
 {
     //TODO: kneeling
     DrawSprite(buffer, topRow, leftColumn, item, LegPosition.Standing, 0);
 }
 public void ConsumeBattleItem(BattleItem itemToConsume)
 {
     //To-Do apply battle item effects
     itemToConsume.quantityHeld -= 1;
 }
Example #27
0
        void MenuMonster_OnButtonUp(object sender, object arg)
        {
            int pc_index     = int.Parse(game.ScriptManager.GetVariable("pc_index"));
            int target_index = ((ButtonBox)sender).Index;
            int damage       = 0;

            PC      pc  = game.PCs[pc_index];
            Monster mon = game.Monsters[target_index];

            game.ScriptManager.InsertCommand("var target_index = " + target_index);

            string op_type = game.ScriptManager.GetVariable("op_type");

            if (op_type == "weapon")
            {
                string haveweapon = "null";


                if (pc.Weapon != null)
                {
                    if (pc.Weapon.Name != null)
                    {
                        if (pc.Weapon.Name != string.Empty)
                        {
                            haveweapon = pc.Weapon.Name;
                        }
                    }
                }
                game.ScriptManager.InsertCommand("var haveweapon = " + haveweapon);
                game.ScriptManager.InsertCommand("?var op_type # weapon var haveweapon = not_null");
                game.ScriptManager.InsertCommand("?var haveweapon = null var op_type = fight");

                //计算伤害
                int roll = Util.Roll(100000);

                double acc = pc.Accurate - mon.Missrate;
                double str = pc.Strength - mon.Physique;
                if (acc < 0)
                {
                    acc = 0;
                }
                if (str < 0)
                {
                    str = 0;
                }

                if (roll < acc * 1000.0)
                {
                    if (roll < str * acc)
                    {
                        //暴击
                        damage = (int)(pc.Damage + pc.Damage * (100000.0 - roll) / 100000.0);
                    }
                    else
                    {
                        //非暴击
                        double x = (double)pc.Weapon.Quality;
                        x /= 100.0;
                        double y = Math.Abs(1.0 - x);
                        damage = (int)(pc.Damage * x + pc.Damage * y * (100000.0 - roll) / 100000.0);
                    }
                }
            }
            else if (op_type == "item")
            {
                int  item_index = int.Parse(game.ScriptManager.GetVariable("item_index"));
                Item item       = pc.BagSee(item_index);
                //pc.BagRemove(item_index);
                if (item is BattleItem)
                {
                    BattleItem bitem = (BattleItem)item;

                    int roll = Util.Roll(100000);

                    double acc = bitem.Accurate - mon.Missrate;
                    double str = pc.Strength - mon.Physique;
                    if (acc < 0)
                    {
                        acc = 0;
                    }
                    if (str < 0)
                    {
                        str = 0;
                    }

                    if (roll < acc * 1000.0)
                    {
                        if (roll < str * acc)
                        {
                            //暴击
                            damage = (int)(bitem.Damage + bitem.Damage * (100000.0 - roll) / 100000.0);
                        }
                        else
                        {
                            //非暴击
                            double x = (double)pc.Weapon.Quality;
                            x /= 100.0;
                            double y = Math.Abs(1.0 - x);
                            damage = (int)(bitem.Damage * x + bitem.Damage * y * (100000.0 - roll) / 100000.0);
                        }
                    }
                }
                game.ScriptManager.AppendCommand("pc [pc_index] bagremove [item_index]");
            }
            game.ScriptManager.AppendCommand("monster [target_index] -hp " + damage);

            game.ScriptManager.AppendCommand("msg monster [target_index] HP-= " + damage);
            game.ScriptManager.AppendCommand("untilpress y n");
            game.ScriptManager.AppendCommand("msg");

            game.ScriptManager.AppendCommand("monster [target_index] gethp mhp");
            game.ScriptManager.AppendCommand("?var mhp < 1 msg monster [target_index] 死了");
            game.ScriptManager.AppendCommand("?var mhp < 1 untilpress y n");
            game.ScriptManager.AppendCommand("?var mhp < 1 msg");
            game.ScriptManager.AppendCommand("?var mhp < 1 monster [target_index] dead");
        }
Example #28
0
        public void Perform()
        {
            Byte itemId = _v.Command.Power;

            BattleItem.AddToInventory(itemId);
        }
Example #29
0
    public static void LoadLevelConfig(string level, string levelLang, string levelMeta, string levelBox)
    {
        SDCSV levelCSV     = new SDCSV();
        SDCSV levelLangCSV = new SDCSV();
        SDCSV levelMetaCSV = new SDCSV();
        SDCSV levelBoxCSV  = new SDCSV();

        levelCSV.CreateCSVFromStr(level, 0);
        levelLangCSV.CreateCSVFromStr(levelLang, 0);
        levelMetaCSV.CreateCSVFromStr(levelMeta, 1);
        levelBoxCSV.CreateCSVFromStr(levelBox, 0);

        //首先遍历level表的每一行,每一行又是一个HashTable...
        levelInfos = new LevelItem[levelCSV.csvTable.Count];
        int count = 0;

        foreach (DictionaryEntry de in levelCSV.csvTable)
        {
            levelInfos[count] = new LevelItem();
            string    key      = (string)de.Key;
            Hashtable valTable = (Hashtable)de.Value;

            levelInfos[count].levelID = int.Parse(key);
            //然后遍历行中的每一列,每一列是一个string
            foreach (DictionaryEntry de2 in valTable)
            {
                //获得名字..
                string name = (string)de2.Key;
                string val  = (string)de2.Value;
                //通过名字查找metaTable,获得数据类型..
                Hashtable meta = (Hashtable)levelMetaCSV.csvTable[name];
                string    type = (string)meta["Type"];

                if (type == "int")
                {
                    levelInfos[count].levelProp.Add(name, int.Parse(val));
                }
                else
                {
                    levelInfos[count].levelProp.Add(name, val);
                }
            }

            //读取国际化表对应的行..
            Hashtable langHash = (Hashtable)levelLangCSV.csvTable[key];
            if (langHash != null)
            {
                foreach (DictionaryEntry de3 in langHash)
                {
                    //获得名字..
                    string name = (string)de3.Key;
                    string val  = (string)de3.Value;
                    //通过名字查找metaTable,获得数据类型..
                    Hashtable meta = (Hashtable)levelMetaCSV.csvTable[name];
                    string    type = (string)meta["Type"];

                    if (type == "int")
                    {
                        levelInfos[count].levelProp[name] = int.Parse(val);
                    }
                    else
                    {
                        levelInfos[count].levelProp[name] = val;
                    }
                }
            }
            count++;
        }

        for (count = 1; count <= 16; count++)
        {
            battleInfos[count] = new BattleItem();
        }

        // 处理关卡领奖数据结构.
        foreach (DictionaryEntry de in levelBoxCSV.csvTable)
        {
            string    key      = (string)de.Key;
            Hashtable valTable = (Hashtable)de.Value;

            uint          bid = 0;
            BattleBoxItem box = new BattleBoxItem();
            box.BoxID = uint.Parse(key);

            foreach (DictionaryEntry de2 in valTable)
            {
                string name = (string)de2.Key;
                string val  = (string)de2.Value;
                if (name == "BattleID")
                {
                    bid = uint.Parse(val);
                }
                else if (name == "Job")
                {
                    box.Job = uint.Parse(val);
                }
                else if (name == "NeedStar")
                {
                    box.NeedStar = uint.Parse(val);
                }
                else if (name == "NonMoney")
                {
                    box.NonMoney = uint.Parse(val);
                }
                else if (name == "NonCash")
                {
                    box.NonCash = uint.Parse(val);
                }
                else if (name == "i1.TID")
                {
                    box.Item1ID = uint.Parse(val);
                }
                else if (name == "i1.Count")
                {
                    box.Item1Count = uint.Parse(val);
                }
                else if (name == "i2.TID")
                {
                    box.Item2ID = uint.Parse(val);
                }
                else if (name == "i2.Count")
                {
                    box.Item2Count = uint.Parse(val);
                }
                else if (name == "i3.TID")
                {
                    box.Item3ID = uint.Parse(val);
                }
                else if (name == "i3.Count")
                {
                    box.Item3Count = uint.Parse(val);
                }
            }

            // 总计16个战役,从1开始.
            if (bid >= 1 && bid <= 16)
            {
                if (box.NeedStar <= 18)
                {
                    count = 0;
                }
                else if (box.NeedStar <= 36)
                {
                    count = 1;
                }
                else
                {
                    count = 2;
                }

                int job = 0;
                if (box.Job == 1)
                {
                    job = 1;                                                    // 战士.
                }
                else if (box.Job == 4)
                {
                    job = 2;                                            // 法师.
                }
                else if (box.Job == 7)
                {
                    job = 3;                                            // 游侠.
                }
                else if (box.Job == 10)
                {
                    job = 4;                                            // 牧师.
                }
                //battleInfos[bid].rewardBox[count,job] = new BattleBoxItem();
                battleInfos[bid].rewardBox[count, job] = box;
            }
        }
    }
Example #30
0
        public IActionResult BattleItem(BattleItem battleItem)
        {
            this.dataService.DeleteBattleItem(battleItem.Id);

            return(this.RedirectToAction("BattleItems", "Admin"));
        }
Example #31
0
 public void Animate(GraphicsBuffer buffer, int topRow, int leftColumn, BattleItem item, int frame)
 {
     DrawSprite(buffer, topRow, leftColumn, item, LegPosition.Walking, frame);
 }
 public void removeItem()
 {
     this.battleItem = null;
 }
Example #33
0
        private void DrawSprite(GraphicsBuffer buffer, int topRow, int leftColumn, BattleItem item, LegPosition legPosition, int frame)
        {
            var isWalking = legPosition == LegPosition.Walking;
            var isKneeling = legPosition == LegPosition.Kneeling;
            var isOneHanded = item != null && !item.IsTwoHanded;
            var isTwoHanded = item != null && item.IsTwoHanded;

            var walkingOffset =
                isWalking ? walkingOffsets[frame] :
                isKneeling ? 2 : //TODO: correct offset for kneeling
                0;
            var armOffset =
                isWalking ? armOffsets[frame] :
                isKneeling ? 2 : //TODO: correct offset
                0;
            var leftArm =
                isTwoHanded ? twoHandedLeftArm :
                isWalking ? leftArmAnimation[frame] :
                emptyLeftArm;
            //TODO: Firing position
            var rightArm =
                isTwoHanded ? twoHandedRightArm :
                isOneHanded ? oneHandedRightArm :
                isWalking ? rightArmAnimation[frame] :
                emptyRightArm;
            var legs =
                isWalking ? legsAnimation[frame] :
                isKneeling ? legsKneeling :
                legsStanding;

            foreach (var part in direction.Metadata().DrawOrder)
            {
                switch (part)
                {
                case SpritePart.OneHandedWeapon:
                    if (isOneHanded)
                        buffer.DrawItem(topRow + armOffset + weaponOffset, leftColumn, item.Sprites[direction]);
                    break;
                case SpritePart.TwoHandedWeapon:
                    if (isTwoHanded)
                        buffer.DrawItem(topRow + armOffset + weaponOffset, leftColumn, item.Sprites[direction]);
                    break;
                case SpritePart.LeftArm:
                    buffer.DrawItem(topRow + armOffset, leftColumn, leftArm);
                    break;
                case SpritePart.RightArm:
                    buffer.DrawItem(topRow + armOffset, leftColumn, rightArm);
                    break;
                case SpritePart.Head:
                    buffer.DrawItem(topRow + walkingOffset, leftColumn, head);
                    break;
                case SpritePart.Legs:
                    buffer.DrawItem(topRow, leftColumn, legs);
                    break;
                }
            }
        }
 public void setItem(BattleItem battleItem)
 {
     this.battleItem = battleItem;
 }
        /// <summary>
        /// Creates a pokemon for the imported team.
        /// </summary>
        /// <param name="importedPokemon">The pokemon string from the Pokemon Showdown export string.</param>
        /// <returns>The created PokemonTeamDetail object.</returns>
        private PokemonTeamDetailViewModel CreatePokemonDetailFromImport(string importedPokemon)
        {
            PokemonTeamDetailViewModel pokemonTeamDetail = new PokemonTeamDetailViewModel();
            string pokemonName           = importedPokemon.Split("\r\n")[0];
            string remainingImportedText = importedPokemon.Replace(string.Concat(pokemonName, "\r\n"), string.Empty);

            pokemonName = pokemonName.Trim();

            // Held item converter.
            if (pokemonName.IndexOf(" @ ") != -1)
            {
                string     itemName   = pokemonName.Split(" @ ")[1];
                BattleItem battleItem = this.dataService.GetObjectByPropertyValue <BattleItem>("Name", itemName);
                if (battleItem != null)
                {
                    pokemonTeamDetail.BattleItemId = battleItem.Id;
                }

                pokemonName = pokemonName.Split(string.Concat(" @ ", itemName))[0];
            }

            // Gender converter.
            int genderCheckStart = pokemonName.LastIndexOf('(');

            if (genderCheckStart != -1 && pokemonName.Substring(genderCheckStart + 2, 1) == ")")
            {
                string genderInitial = pokemonName.Substring(genderCheckStart + 1, 1);
                if (genderInitial == "M")
                {
                    pokemonTeamDetail.Gender = "Male";
                }
                else if (genderInitial == "F")
                {
                    pokemonTeamDetail.Gender = "Female";
                }

                pokemonName = pokemonName.Split(string.Concat(" (", genderInitial, ")"))[0];
            }

            // Nickname converter.
            if (pokemonName.IndexOf("(") != -1)
            {
                pokemonTeamDetail.Nickname = pokemonName.Substring(0, pokemonName.IndexOf("(") - 1);
                pokemonName = pokemonName.Replace(string.Concat(pokemonTeamDetail.Nickname, " ("), string.Empty);
                pokemonName = pokemonName.Replace(")", string.Empty);
            }

            // Pokemon converter.
            Pokemon pokemon;

            // Converts Pokemon Showdown's apostrophe to the database's apostrophe.
            pokemonName = pokemonName.Replace('’', '\'');

            // Used to check for alternate form
            if (pokemonName.LastIndexOf('-') != -1)
            {
                if (pokemonName.Contains("Gmax"))
                {
                    pokemonName = pokemonName.Replace("-Gmax", "-Gigantamax");
                }

                if (pokemonName == "Meowstic-F" || pokemonName == "Indeedee-F")
                {
                    pokemonName = pokemonName.Replace("-F", "-Female");
                }

                List <Form> forms = this.dataService.GetObjects <Form>("Name");
                foreach (var f in forms)
                {
                    f.Name = f.Name.Replace(' ', '-');
                }

                string formName = pokemonName.Remove(0, pokemonName.IndexOf('-') + 1);

                Form form = forms.Find(x => x.Name == formName);

                if (form != null)
                {
                    pokemon = this.dataService.GetPokemonFromNameAndFormName(pokemonName.Replace(string.Concat("-", form.Name), string.Empty), form.Name.Replace('-', ' '));
                }
                else
                {
                    pokemon = this.dataService.GetPokemon(pokemonName);
                }
            }
            else
            {
                pokemon = this.dataService.GetPokemon(pokemonName);
            }

            pokemonTeamDetail.PokemonId = pokemon.Id;

            // Ability converter.
            Ability ability;
            string  abilityName = remainingImportedText.Split("\r\n")[0];

            if (abilityName.Contains("Ability: "))
            {
                remainingImportedText = remainingImportedText.Replace(string.Concat(abilityName, "\r\n"), string.Empty);
                abilityName           = abilityName.Split("Ability: ")[1].Trim();
                ability = this.dataService.GetObjectByPropertyValue <Ability>("Name", abilityName);
            }
            else
            {
                ability = this.dataService.GetAbilitiesForPokemon(pokemon.Id)[0];
            }

            pokemonTeamDetail.AbilityId = ability.Id;

            // Level converter.
            if (remainingImportedText.Contains("Level:"))
            {
                string pokemonLevel = remainingImportedText.Split("\r\n")[0];
                remainingImportedText   = remainingImportedText.Replace(string.Concat(pokemonLevel, "\r\n"), string.Empty);
                pokemonLevel            = pokemonLevel.Trim();
                pokemonTeamDetail.Level = Convert.ToByte(pokemonLevel.Substring(pokemonLevel.IndexOf(':') + 2, pokemonLevel.Length - (pokemonLevel.IndexOf(':') + 2)));
                if (pokemonTeamDetail.Level == 0)
                {
                    pokemonTeamDetail.Level = 1;
                }
                else if (pokemonTeamDetail.Level > 100 || string.Compare(pokemonTeamDetail.Level.ToString(), pokemonLevel.Substring(pokemonLevel.IndexOf(':') + 2)) != 0)
                {
                    pokemonTeamDetail.Level = 100;
                }
            }
            else
            {
                pokemonTeamDetail.Level = 100;
            }

            // Shiny converter.
            if (remainingImportedText.Contains("Shiny: Yes"))
            {
                remainingImportedText     = remainingImportedText.Replace(string.Concat(remainingImportedText.Split("\r\n")[0], "\r\n"), string.Empty);
                pokemonTeamDetail.IsShiny = true;
            }

            // Happiness converter.
            if (remainingImportedText.Contains("Happiness:"))
            {
                string happiness = remainingImportedText.Split("\r\n")[0];
                remainingImportedText       = remainingImportedText.Replace(string.Concat(happiness, "\r\n"), string.Empty);
                happiness                   = happiness.Trim();
                pokemonTeamDetail.Happiness = Convert.ToByte(happiness.Substring(happiness.IndexOf(':') + 2, happiness.Length - (happiness.IndexOf(':') + 2)));
                if (string.Compare(pokemonTeamDetail.Happiness.ToString(), happiness.Substring(happiness.IndexOf(':') + 2)) != 0)
                {
                    pokemonTeamDetail.Happiness = 255;
                }
            }
            else
            {
                pokemonTeamDetail.Happiness = 255;
            }

            // EV converter.
            if (remainingImportedText.Contains("EVs:"))
            {
                string evs = remainingImportedText.Split("\r\n")[0];
                remainingImportedText = remainingImportedText.Replace(string.Concat(evs, "\r\n"), string.Empty);
                PokemonTeamEV pokemonEVs = new PokemonTeamEV();
                if (evs.Contains("HP"))
                {
                    string health = evs.Substring(evs.IndexOf("HP") - 4, 3);
                    health            = health.Replace(":", string.Empty).Replace("/", string.Empty).Trim();
                    pokemonEVs.Health = Convert.ToByte(health);
                }

                if (evs.Contains("Atk"))
                {
                    string attack = evs.Substring(evs.IndexOf("Atk") - 4, 3);
                    attack            = attack.Replace(":", string.Empty).Replace("/", string.Empty).Trim();
                    pokemonEVs.Attack = Convert.ToByte(attack);
                }

                if (evs.Contains("Def"))
                {
                    string defense = evs.Substring(evs.IndexOf("Def") - 4, 3);
                    defense            = defense.Replace(":", string.Empty).Replace("/", string.Empty).Trim();
                    pokemonEVs.Defense = Convert.ToByte(defense);
                }

                if (evs.Contains("SpA"))
                {
                    string specialAttack = evs.Substring(evs.IndexOf("SpA") - 4, 3);
                    specialAttack            = specialAttack.Replace(":", string.Empty).Replace("/", string.Empty).Trim();
                    pokemonEVs.SpecialAttack = Convert.ToByte(specialAttack);
                }

                if (evs.Contains("SpD"))
                {
                    string specialDefense = evs.Substring(evs.IndexOf("SpD") - 4, 3);
                    specialDefense            = specialDefense.Replace(":", string.Empty).Replace("/", string.Empty).Trim();
                    pokemonEVs.SpecialDefense = Convert.ToByte(specialDefense);
                }

                if (evs.Contains("Spe"))
                {
                    string speed = evs.Substring(evs.IndexOf("Spe") - 4, 3);
                    speed            = speed.Replace(":", string.Empty).Replace("/", string.Empty).Trim();
                    pokemonEVs.Speed = Convert.ToByte(speed);
                }

                pokemonTeamDetail.EVs = pokemonEVs;
            }

            // Nature converter.
            if (remainingImportedText.Contains("Nature"))
            {
                string natureName = remainingImportedText.Split("\r\n")[0];
                remainingImportedText = remainingImportedText.Replace(string.Concat(natureName, "\r\n"), string.Empty);
                natureName            = natureName.Replace("Nature", string.Empty).Trim();
                Nature nature = this.dataService.GetObjectByPropertyValue <Nature>("Name", natureName);
                pokemonTeamDetail.NatureId = nature.Id;
            }
            else
            {
                pokemonTeamDetail.NatureId = this.dataService.GetObjectByPropertyValue <Nature>("Name", "Serious").Id;
            }

            // IV converter.
            if (remainingImportedText.Contains("IVs:"))
            {
                string ivs = remainingImportedText.Split("\r\n")[0];
                remainingImportedText = remainingImportedText.Replace(string.Concat(ivs, "\r\n"), string.Empty);
                PokemonTeamIV pokemonIVs = new PokemonTeamIV();
                if (ivs.Contains("HP"))
                {
                    string health = ivs.Substring(ivs.IndexOf("HP") - 3, 2).Trim();
                    pokemonIVs.Health = Convert.ToByte(health);
                }

                if (ivs.Contains("Atk"))
                {
                    string health = ivs.Substring(ivs.IndexOf("Atk") - 3, 2).Trim();
                    pokemonIVs.Attack = Convert.ToByte(health);
                }

                if (ivs.Contains("Def"))
                {
                    string health = ivs.Substring(ivs.IndexOf("Def") - 3, 2).Trim();
                    pokemonIVs.Defense = Convert.ToByte(health);
                }

                if (ivs.Contains("SpA"))
                {
                    string health = ivs.Substring(ivs.IndexOf("SpA") - 3, 2).Trim();
                    pokemonIVs.SpecialAttack = Convert.ToByte(health);
                }

                if (ivs.Contains("SpD"))
                {
                    string health = ivs.Substring(ivs.IndexOf("SpD") - 3, 2).Trim();
                    pokemonIVs.SpecialDefense = Convert.ToByte(health);
                }

                if (ivs.Contains("Spe"))
                {
                    string health = ivs.Substring(ivs.IndexOf("Spe") - 3, 2).Trim();
                    pokemonIVs.Speed = Convert.ToByte(health);
                }

                pokemonTeamDetail.IVs = pokemonIVs;
            }

            // Moveset converter.
            if (remainingImportedText.Contains("- "))
            {
                List <string>      moves      = remainingImportedText.Split("\r\n").ToList();
                List <string>      validMoves = new List <string>();
                string             move;
                PokemonTeamMoveset moveset = new PokemonTeamMoveset();

                foreach (var m in moves)
                {
                    if (!string.IsNullOrEmpty(m) && validMoves.Count < 4)
                    {
                        validMoves.Add(m);
                    }
                }

                foreach (var m in validMoves)
                {
                    move = m.Substring(2, m.Length - 2).Trim();
                    moveset.FourthMove = move;
                    moveset            = this.dataService.SortMoveset(moveset);
                }

                pokemonTeamDetail.Moveset = moveset;
            }

            return(pokemonTeamDetail);
        }
 public CareerContestant()
 {
     BattleItem  = BattleItem.GenerateBattleItem();
     AttackLevel = 100;
 }