Пример #1
0
        public void Update(Point p_new, int timestamp, float hp)
        {
            p = p_new;
            // remove old ones
            hpQ = hpQ.FindAll(delegate(TimedHP thp) { return(timestamp - thp.timeStamp <= FRESH_TIME); });

            TimedHP newthp = new TimedHP();

            newthp.hp        = hp;
            newthp.timeStamp = timestamp;
            hpQ.Add(newthp);
        }
Пример #2
0
        public override string ToString()
        {
            TimedHP       recent  = hpQ.Last();
            StringBuilder builder = new StringBuilder();

            builder.Append("(" + p.ToString() + ") : [");
            foreach (TimedHP thp in hpQ)
            {
                builder.Append("( " + (thp.timeStamp - recent.timeStamp).ToString() + "," + thp.hp + "), ");
            }
            builder.Append("]");
            return(builder.ToString());
        }
Пример #3
0
        public float GetPredictionAfter(int seconds)
        {
            TimedHP recent = hpQ.Last();
            TimedHP oldest = hpQ.First();

            // calc simple deriv
            double dx = recent.timeStamp - oldest.timeStamp;

            if (dx <= 0.0)
            {
                return(recent.hp);
            }
            double dy     = recent.hp - oldest.hp;
            double result = recent.hp + dy / dx * seconds;

            return((float)result);
        }
Пример #4
0
        public void Update(Point p_new, int timestamp, float hp)
        {
            p = p_new;
            // remove old ones
            hpQ = hpQ.FindAll(delegate(TimedHP thp) { return timestamp - thp.timeStamp <= FRESH_TIME; });

            TimedHP newthp = new TimedHP();
            newthp.hp = hp;
            newthp.timeStamp = timestamp;
            hpQ.Add(newthp);
        }