예제 #1
0
    public float GetAbilityValue(int casterLevel, BattleProperty casterProperty, BattleProperty targetProperty)
    {
        float abilityValue = baseValue + baseValueGrow * casterLevel;

        // additionSourceValue 附加值
        if (m_AdditionSourceValues.Count > 0)
        {
            for (int i = 0; i < m_AdditionSourceValues.Count; i++)
            {
                AdditionSourceValue    data = m_AdditionSourceValues[i];
                AbilityValueSourceType abilityValueSourceType = data.abilityValueSourceType;
                int sourceValueCoefficient             = data.sourceValueCoefficient;
                int sourceValueCoefficientGrow         = data.sourceValueCoefficientGrow;
                int limitBasicValue                    = data.limitBasicValue;
                int limitBasicVlimitBasicValueGrowalue = data.limitBasicValueGrow;

                float coefficient         = sourceValueCoefficient * 0.0001f + casterLevel * sourceValueCoefficientGrow * 0.0001f;
                int   additionSourceValue = GetAdditionSourceValueFuncMap[abilityValueSourceType](casterProperty, targetProperty);
                float addition            = additionSourceValue * coefficient;

                abilityValue += addition;
            }
        }
        return(abilityValue);
    }
예제 #2
0
 public Resistance(DamageType ResistanceType, float ResistanceRate, float ResistanceStatic)
 {
     this.ResistanceType   = ResistanceType;
     this.ResistanceRate   = new BattleProperty(10 + (int)ResistanceType, StaticManager.DamageTypesName[ResistanceType] + "抗性比率", ResistanceRate);
     this.ResistanceStatic = new BattleProperty(20 + (int)ResistanceType, StaticManager.DamageTypesName[ResistanceType] + "抗性减免", ResistanceStatic);
     this.Self             = Self;
 }
예제 #3
0
 // 构造函数初始化
 public Player()
 {
     M_BasicProperty  = new BasicProperty();
     M_BattleProperty = new BattleProperty();
     M_Equipments     = new string[11];
     M_Skills         = new string[4];
 }
예제 #4
0
    /// <summary>
    /// 有行为树,会攻击,会寻路的AI
    /// </summary>
    public BattleUnit AddOneEnemyUnit()
    {
        BattleProperty property = new BattleProperty(npcPropertyTable.Instance.GetTableItem(102));
        HeroUnit       unit     = new HeroUnit(GetUniqueID(), BattleCamp.ENEMY, property);

        unit.enemyCamp = BattleCamp.FRIENDLY;
        m_UnitMgr.AddUnit(unit);
        return(unit);
    }
예제 #5
0
    private void AddPlayer()
    {
        BattleProperty property = new BattleProperty(npcPropertyTable.Instance.GetTableItem(101));
        BattleUnit     entity   = new BattleUnit(GetUniqueID(), BattleCamp.FRIENDLY, property);

        entity.enemyCamp = BattleCamp.ENEMY;

        m_UnitMgr.AddPlayer(entity);
    }
예제 #6
0
    // 造成伤害
    public static void ApplyDamage(BattleUnit caster, BattleUnit victim, AbilityDamageType damageType,
                                   AbilityDamageFlag damageFlag, AbilityValueSource damageValueSource, string configName)
    {
        int            casterLevel    = caster.GetLevel();
        BattleProperty casterProperty = caster.GetProperty();
        BattleProperty victimProperty = victim.GetProperty();
        float          abilityValue   = damageValueSource.GetAbilityValue(casterLevel, casterProperty, victimProperty);
        float          finalDamage    = CalcDamageByDamageType(abilityValue, damageType, casterProperty, victimProperty);

        // 护盾
        // 吸血

        victim.UpdateHP(-finalDamage);
        BattleLog.LogRpgBattleAttacker(BattleLogic.instance.logicFrame, caster, victim, configName, finalDamage);
    }
예제 #7
0
        //记录攻击者和防御者的属性
        public static void AttachBattleComputerProperty(CharacterInfoData attacker, CharacterInfoData defender)
        {
            Heluo.Logger.LogError("AttachBattleComputerProperty start");
            BattleComputer        battleComputer         = Singleton <BattleComputer> .Instance;
            BattleFormulaProperty BattleComputerProperty = Traverse.Create(battleComputer).Field("BattleComputerProperty").GetValue <BattleFormulaProperty>();
            BattleComputerFormula BattleComputerFormula  = Traverse.Create(battleComputer).Field("BattleComputerFormula").GetValue <BattleComputerFormula>();

            BattleComputerProperty.Clear();
            foreach (object obj in Enum.GetValues(typeof(NurturanceProperty)))
            {
                NurturanceProperty prop = (NurturanceProperty)obj;
                string             key  = string.Format("attacker_{0}", prop.ToString().ToLower());
                int    value            = attacker.GetUpgradeableProperty((CharacterUpgradableProperty)obj);
                string key2             = string.Format("defender_{0}", prop.ToString().ToLower());
                int    value2           = defender.GetUpgradeableProperty((CharacterUpgradableProperty)obj);
                BattleComputerProperty[key]  = value;
                BattleComputerProperty[key2] = value2;
                BattleComputerProperty[prop.ToString().ToLower()] = value;
            }
            foreach (object obj2 in Enum.GetValues(typeof(BattleProperty)))
            {
                BattleProperty battleProperty  = (BattleProperty)obj2;
                string         format          = "attacker_{0}";
                BattleProperty battleProperty2 = battleProperty;
                string         key3            = string.Format(format, battleProperty2.ToString().ToLower());
                int            value3          = attacker.Property[(CharacterProperty)obj2].Value;
                string         format2         = "defender_{0}";
                battleProperty2 = battleProperty;
                string key4   = string.Format(format2, battleProperty2.ToString().ToLower());
                int    value4 = defender.Property[(CharacterProperty)obj2].Value;
                BattleComputerProperty[key3] = value3;
                BattleComputerProperty[key4] = value4;
                if (battleProperty == BattleProperty.Move)
                {
                    break;
                }
            }

            BattleComputerProperty["attacker_element"] = (int)attacker.Element;
            BattleComputerProperty["defender_element"] = (int)defender.Element;

            BattleComputerProperty["defender_max_hp"] = defender.Property[CharacterProperty.Max_HP].Value;
            float num = BattleComputerFormula["basic_attack_of_counter"].Evaluate(BattleComputerProperty.GetDictionary());

            BattleComputerProperty.Add("basic_attack_of_counter", (int)num);

            Heluo.Logger.LogError("AttachBattleComputerProperty end");
        }
예제 #8
0
 public static void UnitElementPatch2(WgBar __instance, BattleProperty prop)
 {
     if (__instance != null)
     {
         Slider hp = Traverse.Create(__instance).Field("hp").GetValue <Slider>();
         if (hp != null && hp.transform != null)
         {
             var trans = hp.transform.Find("ElementImage");
             if (prop == BattleProperty.Element && trans != null && __instance.Unit != null)
             {
                 var element = trans.gameObject.GetComponent <Image>();
                 element.sprite = Game.Resource.Load <Sprite>(string.Format(GameConfig.ElementPath, __instance.Unit.Element));
             }
         }
     }
 }
예제 #9
0
    /**
     * 更新角色属性显示
     * */
    public void UpdatePropertyText()
    {
        BattleProperty battelProperty = player.M_BattleProperty;

        text_name.text  = player.M_BasicProperty.M_Name;
        text_level.text = player.M_BasicProperty.M_Level.ToString();
        text_race.text  = EnumHelper.GetEnumDescription(player.M_BasicProperty.M_Race);
        text_hp.text    = battelProperty.M_CurrentHp + "/" + battelProperty.M_MaxHp;
        text_mp.text    = battelProperty.M_CurrentMp + "/" + battelProperty.M_MaxMp;
        text_atk.text   = battelProperty.M_Atk.ToString();
        text_def.text   = battelProperty.M_Def.ToString();
        text_mgk.text   = battelProperty.M_Mgk.ToString();
        text_rgs.text   = battelProperty.M_Rgs.ToString();
        text_spd.text   = battelProperty.M_Spd.ToString();
        text_state.text = EnumHelper.GetEnumDescription(battelProperty.M_State);
    }
예제 #10
0
    public BattleUnit(int id, BattleCamp battleCamp, BattleProperty property) : base(id)
    {
        property.id    = id;
        camp           = battleCamp;
        m_Property     = property;
        abilities      = new List <Ability>();
        m_abilityMap   = new Dictionary <AbilityCastType, Ability>(4);
        m_HeroState    = HeroState.IDLE;
        m_BehaviorTree = GetBehaviorTree();
        m_DecisionTree = GetDecisionTree();

        m_DecisionWorkData = new BattleDecisionWorkingData(this);
        m_BehaviorWorkData = new BattleBehaviorWorkingData(this);

        InitAbilities();
    }
예제 #11
0
    private static float CalcDamageByDamageType(float abilityValue, AbilityDamageType damageType,
                                                BattleProperty casterProperty, BattleProperty targetProperty)
    {
        // todo 计算减伤
        switch (damageType)
        {
        case AbilityDamageType.DAMAGE_TYPE_PHYSICAL:

            break;

        case AbilityDamageType.DAMAGE_TYPE_MAGICAL:
            break;

        case AbilityDamageType.DAMAGE_TYPE_PURE:
            break;

        default:
            break;
        }
        return(abilityValue);
    }
예제 #12
0
 public Penetrate(DamageType PenetrateType, float PenetrateRate, float PenetrateStatic, Unit Self)
 {
     this.PenetrateType   = PenetrateType;
     this.PenetrateRate   = new BattleProperty(30 + (int)PenetrateType, StaticManager.DamageTypesName[PenetrateType] + "穿透比率", PenetrateRate);
     this.PenetrateStatic = new BattleProperty(40 + (int)PenetrateType, StaticManager.DamageTypesName[PenetrateType] + "固定穿透", PenetrateStatic);
 }
예제 #13
0
 public HeroUnit(int id, BattleCamp camp, BattleProperty property) : base(id, camp, property)
 {
 }