示例#1
0
文件: Selection.cs 项目: bagnalla/RTS
        public void Remove(RtsObject o)
        {
            objects.Remove(o);

            if (typeCounts.ContainsKey(o.GetType()))
            {
                int count;
                typeCounts.TryGetValue(o.GetType(), out count);
                count--;
                if (count == 0)
                {
                    typeCounts.Remove(o.GetType());
                }
            }

            if (mostPopulousType == o.GetType())
            {
                largestCount = 0;
                foreach (KeyValuePair <Type, int> pair in typeCounts)
                {
                    if (pair.Value > largestCount)
                    {
                        mostPopulousType = pair.Key;
                        largestCount     = pair.Value;
                    }
                }
            }

            if (objects.Count == 0)
            {
                mostPopulousType = null;
                activeType       = null;
                largestCount     = 0;
            }
        }
示例#2
0
文件: Selection.cs 项目: bagnalla/RTS
        public void Add(RtsObject o)
        {
            objects.Add(o);

            if (objects.Count == 1)
            {
                activeType = o.GetType();
            }

            int count;

            if (!typeCounts.ContainsKey(o.GetType()))
            {
                typeCounts.Add(o.GetType(), 1);
                count = 1;
            }
            else
            {
                typeCounts[o.GetType()]++;
                typeCounts.TryGetValue(o.GetType(), out count);
            }

            if (count > largestCount)
            {
                mostPopulousType = o.GetType();
                largestCount     = count;
            }
        }
示例#3
0
        public void Remove(RtsObject o)
        {
            objects.Remove(o);

            if (typeCounts.ContainsKey(o.GetType()))
            {
                int count;
                typeCounts.TryGetValue(o.GetType(), out count);
                count--;
                if (count == 0)
                    typeCounts.Remove(o.GetType());
            }

            if (mostPopulousType == o.GetType())
            {
                largestCount = 0;
                foreach (KeyValuePair<Type, int> pair in typeCounts)
                {
                    if (pair.Value > largestCount)
                    {
                        mostPopulousType = pair.Key;
                        largestCount = pair.Value;
                    }
                }
            }

            if (objects.Count == 0)
            {
                mostPopulousType = null;
                activeType = null;
                largestCount = 0;
            }
        }
示例#4
0
        public void Add(RtsObject o)
        {
            objects.Add(o);

            if (objects.Count == 1)
                activeType = o.GetType();

            int count;

            if (!typeCounts.ContainsKey(o.GetType()))
            {
                typeCounts.Add(o.GetType(), 1);
                count = 1;
            }
            else
            {
                typeCounts[o.GetType()]++;
                typeCounts.TryGetValue(o.GetType(), out count);
            }

            if (count > largestCount)
            {
                mostPopulousType = o.GetType();
                largestCount = count;
            }
        }