public static void CheckBuffAdd(BattleObject source)
    {
        int skillID = source.damage.skillID;
        bool isWeaponDamage = source.damage.isWeaponDamage;

        SkillData skillData = DataManager.Instance.GetSkillDataSet().GetSkillData(skillID);
        for(int i = 0; i < skillData.buffID.Count; i++)
        {
            if(skillData.buffID[i] == 0)continue;

            int random = UnityEngine.Random.Range(0, 101);
            if(random <= skillData.buffPercent[i])
            {
                if(skillData.buffAddTriggers[i] == (int)BuffAddTrigger.SelfAfterDamage)
                {
                    source.AddBuff(skillData.buffID[i], skillData.buffTurns[i]);
                }
                else if(skillData.buffAddTriggers[i] == (int)BuffAddTrigger.TargetAfterDamage)
                {
                    source.damage.target.AddBuff(skillData.buffID[i], skillData.buffTurns[i]);
                }
            }
        }

        if(isWeaponDamage)
        {
            WeaponData weaponData = DataManager.Instance.GetItemDataSet().GetWeaponData(source.GetWeapon());

            for(int i = 0; i < weaponData.buffID.Count; i++)
            {
                if(weaponData.buffID[i] == 0)continue;

                int random = UnityEngine.Random.Range(0, 101);
                if(random <= weaponData.buffPercent[i])
                {
                    if(weaponData.buffAddTriggers[i] == (int)BuffAddTrigger.SelfAfterDamage)
                    {
                        source.AddBuff(weaponData.buffID[i], weaponData.buffTurns[i]);
                    }
                    else if(weaponData.buffAddTriggers[i] == (int)BuffAddTrigger.TargetAfterDamage)
                    {
                        source.damage.target.AddBuff(weaponData.buffID[i], weaponData.buffTurns[i]);
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
    public TargetType targetType; //目标类型

    #endregion Fields

    #region Methods

    public static List<Command> GetAvailableCommands(BattleObject bo)
    {
        List<Command> availableCommands = new List<Command>();
        //检查攻击类技能
        if(!bo.disableAttackCommand)
        {
            if(bo.GetBattleType() != BattleType.Magical && bo.GetWeapon() > 1000)
            {
                WeaponData weaponData = DataManager.Instance.GetItemDataSet().GetWeaponData(bo.GetWeapon());
                if(weaponData.skill1ID > 0)
                    availableCommands.Add(new CommandUseWeaponSkill(weaponData, weaponData.skill1ID));
                if(weaponData.skill2ID > 0)
                    availableCommands.Add(new CommandUseWeaponSkill(weaponData, weaponData.skill2ID));
                if(weaponData.skill3ID > 0)
                    availableCommands.Add(new CommandUseWeaponSkill(weaponData, weaponData.skill3ID));
            }
            if(bo.GetBattleType() != BattleType.Physical)
            {
                foreach(int magicID in bo.GetMagicList())
                {
                    MagicData magicData = DataManager.Instance.GetItemDataSet().GetMagicData(magicID);
                    availableCommands.Add(new CommandUseMagicSkill(magicData, magicData.skillID));
                }
            }
        }
        //检查防御技能
        if(!bo.disableDefenceCommand)
        {
            availableCommands.Add(new CommandBlock());
            availableCommands.Add(new CommandEvade());
            availableCommands.Add(new CommandGuard());
        }
        //检查物品
        if(!bo.disableItemCommand)
        {
            if(bo.GetBattleType() != BattleType.Magical)
            {
                foreach(int weaponID in bo.GetWeaponList())
                {
                    if(weaponID != bo.GetWeapon())
                        availableCommands.Add(new CommandSwitchWeapon(weaponID));
                }
            }
            foreach(var item in bo.GetItemList())
            {
                availableCommands.Add(new CommandUseItem(item.Key, item.Value));
            }
        }
        //检查策略
        if(!bo.disableStrategyCommand)
        {
            availableCommands.Add(new CommandNone());
            availableCommands.Add(new CommandEscape());
        }

        foreach(Command command in availableCommands)
        {
            command.source = bo;
        }

        return availableCommands;
    }
    public static void CheckWeaponBuff(BattleObject source, int offID = 0)
    {
        if(offID > 0)
        {
            WeaponData oldWeaponData = DataManager.Instance.GetItemDataSet().GetWeaponData(offID);

            for(int i = 0; i < oldWeaponData.buffID.Count; i++)
            {
                if(oldWeaponData.buffID[i] == 0)continue;

                if(oldWeaponData.buffAddTriggers[i] == (int)BuffAddTrigger.Self)
                {
                    source.RemoveBuff(oldWeaponData.buffID[i]);
                }
            }
        }

        WeaponData weaponData = DataManager.Instance.GetItemDataSet().GetWeaponData(source.GetWeapon());

        for(int i = 0; i < weaponData.buffID.Count; i++)
        {
            if(weaponData.buffID[i] == 0)continue;

            int random = UnityEngine.Random.Range(0, 101);
            if(random <= weaponData.buffPercent[i])
            {
                if(weaponData.buffAddTriggers[i] == (int)BuffAddTrigger.Self)
                {
                    source.AddBuff(weaponData.buffID[i], weaponData.buffTurns[i]);
                }
            }
        }
    }
    public static void CheckWeaponEffect(EffectTrigger trigger, BattleObject source)
    {
        WeaponData weaponData = DataManager.Instance.GetItemDataSet().GetWeaponData(source.GetWeapon());

        for(int i = 0; i < weaponData.effectID.Count; i++)
        {
            if(weaponData.effectID[i] == 0)continue;

            int random = UnityEngine.Random.Range(0, 101);
            if(random <= weaponData.effectPercent[i])
            {
                SkillEffectData effectData = DataManager.Instance.GetSkillDataSet().GetEffectData(weaponData.effectID[i]);
                if(effectData.trigger == trigger)
                {
                    SkillEffect.ExecuteSkillEffect(source, effectData.effectString);
                }
            }
        }
    }