private static MultiBinding GetStatBinding(BattleEntity source, BattleEntityStatCalculationData calculationData)
 {
     var statBinding = new MultiBinding { Converter = new BattleEntityStatCalculationConverter() };
     statBinding.Bindings.Add(new Binding { Source = calculationData.CalculationFunction });
     foreach (var bindingPath in calculationData.BindingPaths)
     {
         statBinding.Bindings.Add(new Binding(bindingPath) { Source = source });
     }
     return statBinding;
 }
Пример #2
0
        public BattleEntityInBattle(BattleEntity battleEntity)
        {
            BattleEntity = battleEntity;

            var normalizedStartingAction = 100.0 * battleEntity.BaseStats.Speed / Constants.STATS_MAX_PRIMARY_STAT;
            ActionCounter = Math.Max(0, RandomUtility.RandomGaussian(normalizedStartingAction, 25));

            //wire up the is alive property
            var isAliveBinding = new Binding("BattleEntity.CurrentHealth") { Source = this, Converter = new BattleEntityInBattleIsAliveConverter() };
            BindingOperations.SetBinding(this, IsAliveProperty, isAliveBinding);

            //wire up the action status property
            var actionStatusBinding = new MultiBinding { Converter = new BattlePartyMemberActionStatusConverter() };
            actionStatusBinding.Bindings.Add(new Binding("ActionCounter") { Source = this });
            actionStatusBinding.Bindings.Add(new Binding("HasQueuedAbility") { Source = this });
            BindingOperations.SetBinding(this, ActionStatusProperty, actionStatusBinding);
        }
Пример #3
0
        public static Int32 GetArmorMitigatedDamageDefault(BattleEntity target, DamageType damageType, Int32 originalDamage)
        {
            if (damageType == DamageType.Direct)
            {
                //no armor calculation
                return originalDamage;
            }

            //we have an armor calculation
            if (damageType == DamageType.Physical)
            {
                //for physical damage, just scale
                var reduction = target.BaseStats.PhysicalArmor / (Double)Constants.STATS_MAX_PHYSICAL_ARMOR * Constants.STATS_MAX_ARMOR_REDUCTION_MULTIPLIER;
                return Convert.ToInt32(originalDamage * (1 - reduction));
            }

            //we must have elemental damage, scale at a factor determined by half the maximum elemental armor
            var halfMaxArmor = Constants.STATS_MAX_ELEMENTAL_ARMOR / 2;
            var multiplier = (halfMaxArmor - GetElementalArmor(target, damageType)) / (Double)halfMaxArmor;
            return Convert.ToInt32(originalDamage * multiplier);
        }
 protected ShowAbilityAnimationMessage(AbilityAnimation animation, BattleEntity source, BattleEntity[] targets)
 {
     Animation = animation;
     Source = source;
     Targets = targets;
 }
 public static ShowAbilityAnimationMessage New(AbilityAnimation animation, BattleEntity source, BattleEntity[] targets)
 {
     return new ShowAbilityAnimationMessage(animation, source, targets);
 }
Пример #6
0
 public static BattleEntityDiedMessage New(BattleEntity entity)
 {
     var battleEntityInBattle = BattleUtility.GetBattleEntityInBattleByBattleEntity(entity);
     return new BattleEntityDiedMessage(battleEntityInBattle);
 }
 public static BattleEntityDodgedMessage New(BattleEntity entity, LuckyEvent luckyEvent)
 {
     var battleEntityInBattle = BattleUtility.GetBattleEntityInBattleByBattleEntity(entity);
     return new BattleEntityDodgedMessage(battleEntityInBattle, luckyEvent);
 }
 public static BattleEntityTookHealingMessage New(BattleEntity entity, HealingModel healingModel)
 {
     var battleEntityInBattle = BattleUtility.GetBattleEntityInBattleByBattleEntity(entity);
     return new BattleEntityTookHealingMessage(battleEntityInBattle, healingModel);
 }
Пример #9
0
 public static LuckyEvent GetSkillAttackCritEvent(BattleEntity entity)
 {
     return RandomUtility.GetLuckyEvent(entity.BaseStats.SkillCrit, entity.BaseStats.Luck);
 }
Пример #10
0
 public static LuckyEvent GetDodgeEvent(BattleEntity entity)
 {
     return RandomUtility.GetLuckyEvent(entity.BaseStats.Evade, entity.BaseStats.Luck);
 }
Пример #11
0
 private static Int32 GetElementalArmor(BattleEntity entity, DamageType type)
 {
     switch (type)
     {
         case DamageType.Fire:      return entity.BaseStats.FireArmor;
         case DamageType.Ice:       return entity.BaseStats.IceArmor;
         case DamageType.Lightning: return entity.BaseStats.LightningArmor;
         case DamageType.Air:       return entity.BaseStats.AirArmor;
         case DamageType.Poison:    return entity.BaseStats.PoisonArmor;
         case DamageType.Earth:     return entity.BaseStats.EarthArmor;
     }
     return 0;
 }
 public static BattleEntityTookDamageMessage New(BattleEntity entity, Dictionary<DamageType, Int32> damageByType, LuckyEvent crit)
 {
     var battleEntityInBattle = BattleUtility.GetBattleEntityInBattleByBattleEntity(entity);
     return new BattleEntityTookDamageMessage(battleEntityInBattle, damageByType, crit);
 }
Пример #13
0
 public static BattleEntityInBattle GetBattleEntityInBattleByBattleEntity(BattleEntity battleEntity)
 {
     var battleData = BattleModel.Instance?.BattleData;
     if (battleData == null)
     {
         return null;
     }
     if (battleEntity == battleData.PartyMemberInBattle1.BattleEntity) return battleData.PartyMemberInBattle1;
     if (battleEntity == battleData.PartyMemberInBattle2.BattleEntity) return battleData.PartyMemberInBattle2;
     if (battleEntity == battleData.PartyMemberInBattle3.BattleEntity) return battleData.PartyMemberInBattle3;
     if (battleEntity == battleData.PartyMemberInBattle4.BattleEntity) return battleData.PartyMemberInBattle4;
     return battleData.AllEnemiesInBattle.Where(x => x.BattleEntity == battleEntity).FirstOrDefault();
 }