示例#1
0
        public static void InsertSound(SoundNode soundNode, out SoundItem newSoundItem, out int index)
        {
            newSoundItem = null;
            index        = -1;


            SoundItem newSound = new SoundItem();

            newSound.Name = "*new sound";

            if (soundNode == null)
            {
                newSound.Parent = Sounds;
                index           = Sounds.Nodes.Add(newSound);
            }
            else if (soundNode.IsGroup() == true)
            {
                SoundGroup soundGroup = (SoundGroup)soundNode;
                newSound.Parent = soundNode.Parent;
                index           = soundGroup.Nodes.Add(newSound);
            }
            else
            {
                SoundItem  soundItem = (SoundItem)soundNode;
                SoundGroup group     = (SoundGroup)soundItem.Parent;
                newSound.Parent      = group;
                newSound.Type        = soundItem.Type;
                newSound.Volume      = soundItem.Volume;
                newSound.Loop        = soundItem.Loop;
                newSound.Unique      = soundItem.Unique;
                newSound.MinDistance = soundItem.MinDistance;
                newSound.MaxDistance = soundItem.MaxDistance;
                newSound.Priority    = soundItem.Priority;

                int i;
                for (i = 0; i < group.Nodes.Count; i++)
                {
                    if (group.Nodes[i] == soundNode)
                    {
                        break;
                    }
                }

                i++;
                if (i >= group.Nodes.Count)
                {
                    i = group.Nodes.Add(newSound);
                }
                else
                {
                    group.Nodes.Insert(i, newSound);
                }

                index = i;
            }

            newSoundItem = newSound;
        }
示例#2
0
        public static void InsertGroup(SoundNode soundNode, out SoundGroup newSoundGroup, out int index)
        {
            newSoundGroup = null;
            index         = -1;


            SoundGroup newGroup = new SoundGroup();

            newGroup.Name = "*new group";

            if (soundNode == null)
            {
                newGroup.Parent = Sounds;
                index           = Sounds.Nodes.Add(newGroup);
            }
            else if (soundNode.IsGroup() == true)
            {
                SoundGroup soundGroup = (SoundGroup)soundNode;
                newGroup.Parent = soundGroup;
                index           = soundGroup.Nodes.Add(newGroup);
            }
            else
            {
                SoundGroup parentGroup = (SoundGroup)soundNode.Parent;
                newGroup.Parent = parentGroup;

                int i;
                for (i = 0; i < parentGroup.Nodes.Count; i++)
                {
                    if (parentGroup.Nodes[i] == soundNode)
                    {
                        break;
                    }
                }

                i++;
                if (i >= parentGroup.Nodes.Count)
                {
                    i = parentGroup.Nodes.Add(newGroup);
                }
                else
                {
                    parentGroup.Nodes.Insert(i, newGroup);
                }

                index = i;
            }

            newSoundGroup = newGroup;
        }
示例#3
0
        public bool Remove(SoundNode soundNode)
        {
            foreach (SoundNode childNode in Nodes)
            {
                if (childNode == soundNode)
                {
                    Nodes.Remove(childNode);
                    return(true);
                }

                if (childNode.IsGroup() == true)
                {
                    if (((SoundGroup)childNode).Remove(soundNode) == true)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }