Ejemplo n.º 1
0
        public int GetMiddle(int gameloop, int team)
        {
            KeyValuePair <int, int> lastent = new KeyValuePair <int, int>(0, 0);
            int  mid     = 0;
            bool hasInfo = false;

            foreach (var ent in Middle.OrderBy(o => o.Gameloop))
            {
                if (ent.Gameloop > gameloop)
                {
                    hasInfo = true;
                    if (lastent.Value == team + 1)
                    {
                        mid += gameloop - lastent.Key;
                    }
                    break;
                }

                if (lastent.Key > 0 && lastent.Value == team + 1)
                {
                    mid += ent.Gameloop - lastent.Key;
                }

                lastent = new KeyValuePair <int, int>(ent.Gameloop, ent.Team);
            }
            if (Middle.Any())
            {
                if (hasInfo == false && Middle.OrderBy(o => o.Gameloop).Last().Team == team + 1)
                {
                    mid += gameloop - Middle.OrderBy(o => o.Gameloop).Last().Gameloop;
                }
            }

            if (mid < 0)
            {
                mid = 0;
            }
            return(mid);
        }