예제 #1
0
    protected float GetRatioDistanceToAttackAndMoveRange(BattleSimulationUnit unit, BattleSimulationTarget potentialTarget)
    {
        float result           = 0f;
        float distanceByGround = unit.GetDistanceByGround(potentialTarget.StaticPosition);

        if (distanceByGround > 0f)
        {
            float propertyValue  = unit.GetPropertyValue(SimulationProperties.BattleMaximumMovement);
            float propertyValue2 = unit.GetPropertyValue(SimulationProperties.BattleRange);
            result = distanceByGround / (propertyValue + propertyValue2);
        }
        return(result);
    }
예제 #2
0
    protected float GetIsTargetLower(BattleSimulationUnit unit, BattleSimulationTarget potentialTarget)
    {
        float propertyValue = unit.GetPropertyValue(SimulationProperties.Altitude);
        float num           = (float)unit.ElevationMap.GetValue(potentialTarget.StaticPosition);

        if (propertyValue > num)
        {
            return(1f);
        }
        return(0f);
    }
예제 #3
0
    protected float GetNumberOfTurnToReachTargetWithCapacities(BattleSimulationUnit unit, BattleSimulationTarget potentialTarget)
    {
        float result        = 0f;
        float propertyValue = unit.GetPropertyValue(SimulationProperties.BattleMaximumMovement);

        if (propertyValue != 0f)
        {
            result = unit.GetDistanceByGround(potentialTarget.StaticPosition) / propertyValue;
        }
        return(result);
    }
예제 #4
0
    protected float GetNumberOfTurnToReachTargetByAir(BattleSimulationUnit unit, BattleSimulationTarget potentialTarget)
    {
        float result        = 0f;
        float propertyValue = unit.GetPropertyValue(SimulationProperties.BattleMaximumMovement);

        if (propertyValue != 0f)
        {
            result = (float)this.worldPositionningService.GetDistance(unit.Position, potentialTarget.StaticPosition) / propertyValue;
        }
        return(result);
    }
예제 #5
0
    protected float GetRatioOfTargetAltitudeToMyAltitude(BattleSimulationUnit unit, BattleSimulationTarget potentialTarget)
    {
        float result        = 0f;
        float propertyValue = unit.GetPropertyValue(SimulationProperties.Altitude);

        if (propertyValue != 0f)
        {
            float num = (float)unit.ElevationMap.GetValue(potentialTarget.StaticPosition);
            result = num / propertyValue;
        }
        return(result);
    }
예제 #6
0
    protected float GetRatioMyDefenseToTargetAttack(BattleSimulationUnit unit, BattleSimulationTarget potentialTarget)
    {
        float result = 2f;
        BattleSimulationUnit unit2 = potentialTarget.Unit;

        if (unit2 != null)
        {
            float propertyValue = unit2.GetPropertyValue(SimulationProperties.Attack);
            if (propertyValue != 0f)
            {
                result = Mathf.Clamp(unit.GetPropertyValue(SimulationProperties.Defense) / propertyValue, 0.5f, 2f);
            }
        }
        return(result);
    }
    private bool ExecuteBattleAction(float battleActionContextRandomNumber, BattleAction battleAction, BattleEffects battleEffects, BattleSimulationUnit initiator, BattleSimulationUnit activator, BattleSimulationTarget[] currentTargets, bool immediate)
    {
        if (battleAction == null)
        {
            throw new ArgumentNullException("battleAction");
        }
        if (battleEffects == null)
        {
            throw new ArgumentNullException("battleEffects");
        }
        if (!battleAction.CanBeAppliedByDeadUnit && activator.GetPropertyValue(SimulationProperties.Health) <= 0f)
        {
            return(false);
        }
        Diagnostics.Assert(this.Simulation != null && this.Simulation.BattleSimulationRandom != null);
        double num  = this.Simulation.BattleSimulationRandom.NextDouble();
        double num2 = (double)battleEffects.GetProbability(initiator);

        if (num >= num2)
        {
            return(false);
        }
        BattleSimulationTarget[] array             = this.Simulation.FilterTargets(battleEffects.TargetsFilter, initiator, currentTargets);
        BattleEffectsArea        battleEffectsArea = battleEffects as BattleEffectsArea;

        if (battleEffectsArea == null)
        {
            BattleActionContext battleActionContext = new BattleActionContext(this, battleAction, battleEffects, initiator, activator, array, battleActionContextRandomNumber);
            this.ExecuteBattleAction(battleActionContext, immediate);
        }
        else
        {
            this.ExecuteAOEBattleAction(battleActionContextRandomNumber, battleAction, battleEffectsArea, initiator, activator, array, immediate);
        }
        return(true);
    }
예제 #8
0
    protected bool IsTargetWithinMovementRange(BattleSimulationUnit unit, BattleSimulationTarget potentialTarget)
    {
        float distanceByGround = unit.GetDistanceByGround(potentialTarget.StaticPosition);

        return(distanceByGround <= unit.GetPropertyValue(SimulationProperties.BattleMovement));
    }
예제 #9
0
    protected float GetWithinAttackRange(BattleSimulationUnit unit, BattleSimulationTarget potentialTarget)
    {
        int distance = this.worldPositionningService.GetDistance(unit.Position, potentialTarget.StaticPosition);

        return(((float)distance <= unit.GetPropertyValue(SimulationProperties.BattleRange)) ? 1f : 0f);
    }
예제 #10
0
    protected BattleSimulationTarget ComputeTargetingWithWeight(BattleSimulationUnit unit, BattleSimulationTarget[] battleSimulationTargets)
    {
        if (unit == null)
        {
            throw new ArgumentNullException("unit");
        }
        List <BattleTargetingUnitBehaviorWeight> battleTargetingUnitBehaviorWeights = unit.BattleTargetingUnitBehaviorWeights;

        if (battleTargetingUnitBehaviorWeights == null)
        {
            return(null);
        }
        bool flag = unit.GetPropertyValue(SimulationProperties.BattleRange) > 1.1f;
        BattleSimulationTarget result = null;
        float num = float.NegativeInfinity;

        for (int i = 0; i < battleTargetingUnitBehaviorWeights.Count; i++)
        {
            BattleTargetingUnitBehaviorWeight battleTargetingUnitBehaviorWeight = battleTargetingUnitBehaviorWeights[i];
            foreach (BattleSimulationTarget battleSimulationTarget in battleSimulationTargets)
            {
                if ((battleSimulationTarget.Unit == null || !battleSimulationTarget.Unit.IsDead) && this.FiltersAreVerified(battleTargetingUnitBehaviorWeight, unit, battleSimulationTarget))
                {
                    float num2 = 0f;
                    if (battleTargetingUnitBehaviorWeight.Weights != null && battleTargetingUnitBehaviorWeight.Weights.Length != 0)
                    {
                        for (int k = 0; k < battleTargetingUnitBehaviorWeight.Weights.Length; k++)
                        {
                            BattleTargetingUnitBehaviorWeight.Weight weight = battleTargetingUnitBehaviorWeight.Weights[k];
                            if (weight.ValueAsFloat != 0f)
                            {
                                float paramValueByName = this.GetParamValueByName(weight.Name, unit, battleSimulationTarget);
                                Amplitude.Unity.Framework.AnimationCurve animationCurve;
                                this.targettingAnimationCurveDatabase.TryGetValue(weight.NormalizationCurveName, out animationCurve);
                                float num3;
                                if (animationCurve != null)
                                {
                                    num3 = animationCurve.Evaluate(paramValueByName) * weight.ValueAsFloat;
                                }
                                else
                                {
                                    num3 = paramValueByName * weight.ValueAsFloat;
                                }
                                num2 += num3;
                            }
                        }
                        num2 /= (float)battleTargetingUnitBehaviorWeight.Weights.Length;
                    }
                    if (flag && float.IsNegativeInfinity(num2) && battleSimulationTarget.Unit != null)
                    {
                        num2 = -1E+07f;
                    }
                    if (num2 > num)
                    {
                        result = battleSimulationTarget;
                        num    = num2;
                    }
                }
            }
        }
        return(result);
    }