コード例 #1
0
ファイル: GameScreen.cs プロジェクト: blazes816/Xanx
        public void AddComponent(Component Component)
        {
            if (!components.Contains(Component))
            {
                components.Add(Component);
                Component.Parent = this;
                Component.LoadComponent();
                PutComponentInOrder(Component);

                // Store timers so we can delete them when needed
                if (Component.GetType() == typeof(Timer) && !timers.Contains((Timer)Component))
                {
                    timers.Add((Timer)Component);
                }
            }
        }
コード例 #2
0
ファイル: GameScreen.cs プロジェクト: blazes816/Xanx
 public void RemoveComponent(Component Component)
 {
     if (Component != null && components.Contains(Component))
     {
         components.Remove(Component);
         Component.Parent = null;
     }
 }
コード例 #3
0
ファイル: GameScreen.cs プロジェクト: blazes816/Xanx
        // The components are stored in their draw order, so it is easy to loop
        // through them and draw them in the correct order without having to sort
        // them every time they are drawn
        public void PutComponentInOrder(Component component)
        {
            if (components.Contains(component))
            {
                components.Remove(component);

                int i = 0;

                // Iterate through the components in order until we find one with
                // a higher or equal draw order, and insert the component at that
                // position.
                for (i = 0; i < components.Count; i++)
                    if (components[i].DrawOrder >= component.DrawOrder)
                        break;

                components.Insert(i, component);
            }
        }