Beispiel #1
0
        public override TimeBaseValue Calculate(int forIndex)
        {
            if (forIndex < Length)
            {
                return new SRValue()
                       {
                           Time = GetTime(forIndex), Value = double.NaN, Source = GetValueBySource(forIndex), Index = Result.Count
                       }
            }
            ;

            double[] close = GetClose(forIndex, Range);
            double[] low   = close, high = close;

            int      center = forIndex - 1 - Range;
            DateTime tm     = GetTime(center);
            SRValue  value  = new SRValue()
            {
                Time = tm, Index = Result.Count, Power = 1
            };

            if (IsMin(low[Range], low))  // support
            {
                value.Type = SupResType.Support;

                value.Value = low[Range];
                if (UpdateSupport(value))
                {
                    Support.Add(value);
                }
            }
            else if (IsMax(high[Range], high))  // resistance
            {
                value.Type  = SupResType.Resistance;
                value.Value = high[Range];
                if (UpdateResistance(value))
                {
                    Resistance.Add(value);
                }
            }

            SRValue lastRes = GetLastResistance();

            if (lastRes != null && lastRes != value)
            {
                lastRes.Length++;
            }

            SRValue lastSup = GetLastSupport();

            if (lastSup != null && lastSup != value)
            {
                lastSup.Length++;
            }

            return(value);
        }
Beispiel #2
0
 public void AddResistance(Element element)
 {
     Resistance.Add(element);
 }
Beispiel #3
0
    internal Resistance GetResistance(EDamageType type)
    {
        _currentResistance.armor = 0;
        _currentResistance.flat  = 0;

        switch (type)
        {
        //PHYSICAL
        case EDamageType.Slashing:
            _currentResistance.Add(general);
            _currentResistance.Add(physical);
            _currentResistance.Add(slashing);
            break;

        case EDamageType.Crushing:
            _currentResistance.Add(general);
            _currentResistance.Add(physical);
            _currentResistance.Add(crushing);
            break;

        case EDamageType.Piercing:
            _currentResistance.Add(general);
            _currentResistance.Add(physical);
            _currentResistance.Add(piercing);
            break;

        //MAGIC
        case EDamageType.Fire:
            _currentResistance.Add(general);
            _currentResistance.Add(magic);
            _currentResistance.Add(fire);
            break;

        case EDamageType.Frost:
            _currentResistance.Add(general);
            _currentResistance.Add(magic);
            _currentResistance.Add(frost);
            break;

        case EDamageType.Ligthing:
            _currentResistance.Add(general);
            _currentResistance.Add(magic);
            _currentResistance.Add(lightning);
            break;

        //STANDALONE
        case EDamageType.Bleed:
            _currentResistance.Add(general);
            //_currentResistance.Add(physical);
            _currentResistance.Add(bleed);
            break;

        case EDamageType.Poison:
            _currentResistance.Add(general);
            //_currentResistance.Add(magic);
            _currentResistance.Add(poison);
            break;

        case EDamageType.Spirit:
            _currentResistance.Add(general);
            //_currentResistance.Add(magic);
            _currentResistance.Add(spirit);
            break;
        }

        return(_currentResistance);
    }