Beispiel #1
0
        private bool IsNameUsedByAudioClip(string name, AudioClipFolder folderToCheck, object ignoreObject)
        {
            foreach (AudioClip clip in folderToCheck.Items)
            {
                if ((clip.ScriptName == name) && (clip != ignoreObject))
                {
                    return(true);
                }
            }

            foreach (AudioClipFolder subFolder in folderToCheck.SubFolders)
            {
                if (IsNameUsedByAudioClip(name, subFolder, ignoreObject))
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #2
0
        public Game()
        {
            _guis                    = new List <GUI>();
            _inventoryItems          = new List <InventoryItem>();
            _cursors                 = new List <MouseCursor>();
            _dialogs                 = new List <Dialog>();
            _fonts                   = new List <Font>();
            _characters              = new List <Character>();
            _plugins                 = new List <Plugin>();
            _translations            = new List <Translation>();
            _rooms                   = new RoomList();
            _oldInteractionVariables = new List <OldInteractionVariable>();
            _settings                = new Settings();
            _palette                 = new PaletteEntry[PALETTE_SIZE];
            _sprites                 = new SpriteFolder("Main");
            _views                   = new ViewFolder("Main");
            _audioClips              = new AudioClipFolder("Main");
            _audioClipTypes          = new List <AudioClipType>();
            _textParser              = new TextParser();
            _lipSync                 = new LipSync();
            _propertySchema          = new CustomPropertySchema();
            _globalVariables         = new GlobalVariables();
            _globalMessages          = new string[NUMBER_OF_GLOBAL_MESSAGES];
            _deletedViewIDs          = new Dictionary <int, object>();
            _scripts                 = new Scripts();
            _scriptsToCompile        = new Scripts();
            _scripts.Add(new Script(Script.GLOBAL_HEADER_FILE_NAME, "// script header\r\n", true));
            _scripts.Add(new Script(Script.GLOBAL_SCRIPT_FILE_NAME, "// global script\r\n", false));
            _playerCharacter = null;

            for (int i = 0; i < _globalMessages.Length; i++)
            {
                _globalMessages[i] = string.Empty;
            }

            InitializeDefaultPalette();
        }
Beispiel #3
0
        public void FromXml(XmlNode node)
        {
            node = node.SelectSingleNode("Game");

            _settings.FromXml(node);
            _lipSync.FromXml(node);
            _propertySchema.FromXml(node);

            if (node.SelectSingleNode("InventoryHotspotMarker") != null)
            {
                // Pre-3.0.3
                InventoryHotspotMarker marker = new InventoryHotspotMarker();
                marker.FromXml(node);
                _settings.InventoryHotspotMarker = marker;
            }

            foreach (XmlNode msgNode in SerializeUtils.GetChildNodes(node, "GlobalMessages"))
            {
                _globalMessages[Convert.ToInt32(msgNode.Attributes["ID"].InnerText) - GLOBAL_MESSAGE_ID_START] = msgNode.InnerText;
            }

            _plugins.Clear();
            foreach (XmlNode pluginNode in SerializeUtils.GetChildNodes(node, "Plugins"))
            {
                _plugins.Add(new Plugin(pluginNode));
            }

            _rooms.Clear();
            foreach (XmlNode roomNode in SerializeUtils.GetChildNodes(node, "Rooms"))
            {
                _rooms.Add(new UnloadedRoom(roomNode));
            }

            _guis.Clear();
            foreach (XmlNode guiNode in SerializeUtils.GetChildNodes(node, "GUIs"))
            {
                if (guiNode.FirstChild.Name == NormalGUI.XML_ELEMENT_NAME)
                {
                    _guis.Add(new NormalGUI(guiNode));
                }
                else
                {
                    _guis.Add(new TextWindowGUI(guiNode));
                }
            }

            _inventoryItems.Clear();
            foreach (XmlNode invNode in SerializeUtils.GetChildNodes(node, "InventoryItems"))
            {
                _inventoryItems.Add(new InventoryItem(invNode));
            }

            _textParser = new TextParser(node.SelectSingleNode("TextParser"));

            _characters.Clear();
            foreach (XmlNode invNode in SerializeUtils.GetChildNodes(node, "Characters"))
            {
                _characters.Add(new Character(invNode));
            }

            _playerCharacter = null;
            string playerCharText = SerializeUtils.GetElementString(node, "PlayerCharacter");

            if (playerCharText.Length > 0)
            {
                int playerCharID = Convert.ToInt32(playerCharText);
                foreach (Character character in _characters)
                {
                    if (character.ID == playerCharID)
                    {
                        _playerCharacter = character;
                        break;
                    }
                }
            }

            _dialogs.Clear();
            foreach (XmlNode dialogNode in SerializeUtils.GetChildNodes(node, "Dialogs"))
            {
                _dialogs.Add(new Dialog(dialogNode));
            }

            _cursors.Clear();
            foreach (XmlNode cursNode in SerializeUtils.GetChildNodes(node, "Cursors"))
            {
                _cursors.Add(new MouseCursor(cursNode));
            }

            _fonts.Clear();
            foreach (XmlNode fontNode in SerializeUtils.GetChildNodes(node, "Fonts"))
            {
                _fonts.Add(new Font(fontNode));
            }

            _palette = ReadPaletteFromXML(node);

            _sprites = new SpriteFolder(node.SelectSingleNode("Sprites").FirstChild);

            _views = new ViewFolder(node.SelectSingleNode("Views").FirstChild);

            _deletedViewIDs.Clear();
            if (node.SelectSingleNode("DeletedViews") != null)
            {
                foreach (XmlNode transNode in SerializeUtils.GetChildNodes(node, "DeletedViews"))
                {
                    _deletedViewIDs.Add(Convert.ToInt32(transNode.InnerText), null);
                }
            }

            _scripts = new Scripts(node);

            if (node.SelectSingleNode("AudioClips") != null)
            {
                _audioClips = new AudioClipFolder(node.SelectSingleNode("AudioClips").FirstChild);
            }
            else
            {
                _audioClips = new AudioClipFolder("Main");
                _audioClips.DefaultPriority = AudioClipPriority.Normal;
                _audioClips.DefaultRepeat   = InheritableBool.False;
                _audioClips.DefaultVolume   = 100;
            }

            _audioClipTypes.Clear();
            if (node.SelectSingleNode("AudioClipTypes") != null)
            {
                foreach (XmlNode clipTypeNode in SerializeUtils.GetChildNodes(node, "AudioClipTypes"))
                {
                    _audioClipTypes.Add(new AudioClipType(clipTypeNode));
                }
            }

            _translations.Clear();
            if (node.SelectSingleNode("Translations") != null)
            {
                foreach (XmlNode transNode in SerializeUtils.GetChildNodes(node, "Translations"))
                {
                    _translations.Add(new Translation(transNode));
                }
            }

            if (node.SelectSingleNode("GlobalVariables") != null)
            {
                _globalVariables = new GlobalVariables(node.SelectSingleNode("GlobalVariables"));
            }
            else
            {
                _globalVariables = new GlobalVariables();
            }

            _oldInteractionVariables.Clear();
            if (node.SelectSingleNode("OldInteractionVariables") != null)
            {
                foreach (XmlNode varNode in SerializeUtils.GetChildNodes(node, "OldInteractionVariables"))
                {
                    _oldInteractionVariables.Add(new OldInteractionVariable(SerializeUtils.GetAttributeString(varNode, "Name"), SerializeUtils.GetAttributeInt(varNode, "Value")));
                }
            }

            if (_savedXmlVersionIndex == null)
            {
                // Pre-3.0.3, upgrade co-ordinates
                ConvertCoordinatesToNativeResolution();
            }
        }