コード例 #1
0
ファイル: PrioritySystem.cs プロジェクト: steffan88/Bevelle
        public static void TakePriority(int priority, PriorityBox p, bool addition)
        {
            if (p.Priority == priority)
                return;
            // The new priority is larger than the privious
            if (p.Priority < priority)
            {
                foreach (PriorityBox pb in _priorityBoxes)
                {
                    if (pb == p)
                        continue;

                    if (pb.Priority > p.Priority && pb.Priority <= priority)
                        pb.ChangePriority(pb.Priority - 1);
                }
            }

            if (p.Priority > priority)
            {
                foreach (PriorityBox pb in _priorityBoxes)
                {
                    if (pb == p)
                        continue;

                    if (pb.Priority >= priority && pb.Priority < p.Priority)
                        pb.ChangePriority(pb.Priority + 1);
                }
            }

            if (priority >= _priorityBoxes.Count && addition == false)
                p.ChangePriority(_priorityBoxes.Count-1);
            else
                p.ChangePriority(priority);
        }
コード例 #2
0
ファイル: PrioritySystem.cs プロジェクト: steffan88/Bevelle
        public static void AddPriorityBox(string name)
        {
            PriorityBox p = new PriorityBox(name);
            TakePriority(0, p, true);
            _priorityBoxes.Add(p);

            GuiSystem.AddGuiComponent(p);
        }