Пример #1
0
        private double BoonIntensityStacks(Boon b, List <BoonEvent> boonEvents)
        {
            if (boonEvents.Count == 0)
            {
                return(0.0);
            }
            int        prev = 0;
            int        curr = 0;
            List <int> s    = new List <int> {
                0
            };

            BoonStackIntensity bs = new BoonStackIntensity(b.Capacity);

            foreach (BoonEvent be in boonEvents)
            {
                curr = be.Time;
                bs.SimulateTimePassed(curr - prev, s);
                bs.Update(curr - prev);
                bs.Add(be.Duration);
                if (prev != curr)
                {
                    s.Add(bs.CalculateValue());
                }
                else
                {
                    s[s.Count - 1] = bs.CalculateValue();
                }
                prev = curr;
            }
            bs.SimulateTimePassed(_time - prev, s);
            bs.Update(1);
            s.Add(bs.CalculateValue());
            //Console.WriteLine();
            //Console.WriteLine(s.Sum() + "|" +_time);
            //using (StreamWriter f = new StreamWriter("stacks.txt"))
            //{
            //    foreach (int k in s)
            //    {
            //        f.WriteLine(k.ToString());
            //    }
            //}
            //Console.Read();

            return(s.Average());
        }
Пример #2
0
        private double BoonDurationRates(Boon b, List <BoonEvent> boonEvents)
        {
            if (boonEvents.Count == 0)
            {
                return(0.0);
            }
            int             prev = 0;
            int             curr = 0;
            List <Interval> bi   = new List <Interval>();
            BoonStack       bs   = new BoonStackDuration(b.Capacity);

            foreach (BoonEvent be in boonEvents)
            {
                curr = be.Time;
                bs.Update(curr - prev);
                bs.Add(be.Duration);
                bi.Add(new Interval
                {
                    Start = curr,
                    End   = curr + bs.CalculateValue()
                });
                prev = curr;
            }
            List <Interval> mbi = (bi.Count == 1) ? bi : new List <Interval>();

            if (mbi.Count == 0)
            {
                Interval a = bi[0];
                int      s = a.Start;
                int      e = a.End;
                for (int i = 1; i < bi.Count; i++)
                {
                    Interval c = bi[i];
                    if (c.Start <= e)
                    {
                        e = Math.Max(c.End, e);
                    }
                    else
                    {
                        mbi.Add(new Interval()
                        {
                            Start = s, End = e
                        });
                        s = c.Start;
                        e = c.End;
                    }
                }
                mbi.Add(new Interval()
                {
                    Start = s, End = e
                });
            }
            Interval z = mbi[mbi.Count - 1];

            if (z.End > _time)
            {
                z.End = _time;
            }
            double duration = 0.0;

            foreach (Interval i in mbi)
            {
                duration += (i.End - i.Start);
            }
            return(duration / _time);
        }