Example #1
0
 protected void checkResources()
 {
     foreach (ResourcesUni resource in element.getResources())
     {
         if (ConditionChecker.check(resource.getConditions()))
         {
             this.resource = resource;
             break;
         }
     }
 }
        /**
         * Contructor.
         *
         * @param resources
         *            Resources of the data control structure
         * @param resourcesType
         *            Type of the resources
         */
        public ResourcesDataControl(ResourcesUni resources, int resourcesType)
        {
            this.resources     = resources;
            this.resourcesType = resourcesType;

            // Initialize the assetsInformation, depending on the assets type
            switch (resourcesType)
            {
            case Controller.SCENE:
                assetsInformation = new AssetInformation[] { new AssetInformation("Resources.DescriptionSceneBackground", "background", true, AssetsConstants.CATEGORY_BACKGROUND, AssetsController.FILTER_JPG), new AssetInformation("Resources.DescriptionSceneForeground", "foreground", false, AssetsConstants.CATEGORY_BACKGROUND, AssetsController.FILTER_PNG), /*new AssetInformation( TextConstants.getText( "Resources.DescriptionSceneHardMap" ), "hardmap", false, AssetsController.CATEGORY_BACKGROUND, AssetsController.FILTER_PNG ), */ new AssetInformation("Resources.DescriptionSceneMusic", "bgmusic", false, AssetsConstants.CATEGORY_AUDIO, AssetsController.FILTER_NONE) };

                if (!resources.existAsset("background"))
                {
                    resources.addAsset("background", SpecialAssetPaths.ASSET_EMPTY_BACKGROUND);
                }
                break;

            case Controller.CUTSCENE_SLIDES:
                assetsInformation = new AssetInformation[] { new AssetInformation("Resources.DescriptionSlidesceneSlides", "slides", true, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_JPG), new AssetInformation("Resources.DescriptionSceneMusic", "bgmusic", false, AssetsConstants.CATEGORY_AUDIO, AssetsController.FILTER_NONE) };

                if (!resources.existAsset("slides"))
                {
                    resources.addAsset("slides", SpecialAssetPaths.ASSET_EMPTY_ANIMATION);
                }
                break;

            case Controller.ACTION_CUSTOM:
            case Controller.ACTION_CUSTOM_INTERACT:
                assetsInformation = new AssetInformation[] { new AssetInformation("Resources.DescriptionButtonNormal", "buttonNormal", true, AssetsConstants.CATEGORY_BUTTON, AssetsController.FILTER_PNG), new AssetInformation("Resources.DescriptionButtonOver", "buttonOver", true, AssetsConstants.CATEGORY_BUTTON, AssetsController.FILTER_PNG), new AssetInformation("Resources.DescriptionButtonSound", "buttonSound", false, AssetsConstants.CATEGORY_AUDIO, AssetsController.FILTER_NONE) /*, new AssetInformation( "Resources.DescriptionButtonPressed" , "buttonPressed", true, AssetsConstants.CATEGORY_BUTTON, AssetsController.FILTER_PNG )*/, new AssetInformation("Resources.DescriptionActionAnimation", "actionAnimation", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_NONE), new AssetInformation("Resources.DescriptionActionAnimationLeft", "actionAnimationLeft", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_NONE) };
                assetsGroups      = new int[][] { new int[] { 0, 1, 2 }, new int[] { 3, 4 } };
                groupsInfo        = new string[] { "Resources.Button", "Resources.Animations" };

                // For each asset, if it has not been declared attach the empty animation
                string[] assets = new string[] { "buttonNormal", "buttonOver", "buttonPressed" };
                foreach (string asset in assets)
                {
                    if (!resources.existAsset(asset))
                    {
                        resources.addAsset(asset, SpecialAssetPaths.ASSET_EMPTY_ANIMATION);
                    }
                }

                break;

            case Controller.CUTSCENE_VIDEO:
                assetsInformation = new AssetInformation[] { new AssetInformation("Resources.DescriptionVideoscenes", "video", true, AssetsConstants.CATEGORY_VIDEO, AssetsController.FILTER_NONE) };
                break;

            case Controller.BOOK:
                assetsInformation = new AssetInformation[] { new AssetInformation("Resources.DescriptionBookBackground", "background", true, AssetsConstants.CATEGORY_BACKGROUND, AssetsController.FILTER_JPG),
                                                             new AssetInformation("Resources.ArrowLeftNormal", "arrowLeftNormal", false, AssetsConstants.CATEGORY_ARROW_BOOK, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.ArrowRightNormal", "arrowRightNormal", false, AssetsConstants.CATEGORY_ARROW_BOOK, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.ArrowLeftOver", "arrowLeftOver", false, AssetsConstants.CATEGORY_ARROW_BOOK, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.ArrowRightOver", "arrowRightOver", false, AssetsConstants.CATEGORY_ARROW_BOOK, AssetsController.FILTER_PNG) };

                if (!resources.existAsset("background"))
                {
                    resources.addAsset("background", SpecialAssetPaths.ASSET_EMPTY_BACKGROUND);
                }
                break;

            case Controller.ITEM:
                assetsInformation = new AssetInformation[] { new AssetInformation("Resources.DescriptionItemImage", "image", true, AssetsConstants.CATEGORY_IMAGE, AssetsController.FILTER_NONE), new AssetInformation("Resources.DescriptionItemIcon", "icon", false, AssetsConstants.CATEGORY_ICON, AssetsController.FILTER_NONE)
                                                             , new AssetInformation("Resources.DescriptionItemImageOver", "imageover", false, AssetsConstants.CATEGORY_IMAGE, AssetsController.FILTER_NONE) };
                imageIconMap = new Dictionary <string, string>();
                imageIconMap.Add("icon", "image");
                if (!resources.existAsset("image"))
                {
                    resources.addAsset("image", SpecialAssetPaths.ASSET_EMPTY_IMAGE);
                }
                if (!resources.existAsset("icon"))
                {
                    resources.addAsset("icon", SpecialAssetPaths.ASSET_EMPTY_ICON);
                }
                break;

            case Controller.PLAYER:
            case Controller.NPC:
                assetsInformation = new AssetInformation[] { new AssetInformation("Resources.DescriptionCharacterAnimationStandUp", "standup", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.DescriptionCharacterAnimationStandDown", "standdown", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),
                                                             //check if is 3rd or 1st person game to set the asset as necessary
                                                             new AssetInformation("Resources.DescriptionCharacterAnimationStandRight", "standright", Controller.Instance.PlayTransparent?false:true, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.DescriptionCharacterAnimationStandLeft", "standleft", Controller.Instance.PlayTransparent?false:true, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),

                                                             new AssetInformation("Resources.DescriptionCharacterAnimationSpeakUp", "speakup", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.DescriptionCharacterAnimationSpeakDown", "speakdown", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.DescriptionCharacterAnimationSpeakRight", "speakright", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.DescriptionCharacterAnimationSpeakLeft", "speakleft", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.DescriptionCharacterAnimationUseRight", "useright", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.DescriptionCharacterAnimationUseLeft", "useleft", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.DescriptionCharacterAnimationWalkUp", "walkup", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.DescriptionCharacterAnimationWalkDown", "walkdown", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.DescriptionCharacterAnimationWalkRight", "walkright", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.DescriptionCharacterAnimationWalkLeft", "walkleft", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG) };
                assetsGroups = new int[][] { new int[] { 0, 1, 2, 3 }, new int[] { 4, 5, 6, 7 }, new int[] { 8, 9 }, new int[] { 10, 11, 12, 13 } };
                groupsInfo   = new string[] { "Resources.StandingAnimations", "Resources.SpeakingAnimations", "Resources.UsingAnimations", "Resources.WalkingAnimations" };

                foreach (string asset in new string[]
                {
                    "standup", "standdown", "standright", "standleft", "speakup", "speakdown", "speakright", "speakleft",
                    "useright", "useleft", "walkup", "walkdown", "walkright", "walkleft"
                })
                {
                    if (!resources.existAsset(asset))
                    {
                        resources.addAsset(asset, SpecialAssetPaths.ASSET_EMPTY_ANIMATION);
                    }
                }

                break;

            case Controller.ATREZZO:
                assetsInformation = new AssetInformation[] { new AssetInformation("Resources.DescriptionItemImage", "image", true, AssetsConstants.CATEGORY_IMAGE, AssetsController.FILTER_NONE) };
                if (!resources.existAsset("image"))
                {
                    resources.addAsset("image", SpecialAssetPaths.ASSET_EMPTY_IMAGE);
                }
                break;
            }

            // Create subcontrollers
            conditionsController = new ConditionsController(resources.getConditions(), Controller.RESOURCES, "");
        }
 public override void updateVarFlagSummary(VarFlagSummary varFlagSummary)
 {
     // Update the flag summary with the conditions
     ConditionsController.updateVarFlagSummary(varFlagSummary, resources.getConditions());
 }
    public static XmlNode buildDOM(ResourcesUni resources, int resourcesType)
    {
        XmlElement resourcesNode = null;

        // Create the necessary elements to create the DOM
        XmlDocument doc = Writer.GetDoc();

        // Create the root node
        resourcesNode = doc.CreateElement("resources");
        resourcesNode.SetAttribute("name", resources.getName());

        // Append the conditions block (if there is one)
        if (!resources.getConditions().isEmpty())
        {
            XmlNode conditionsNode = ConditionsDOMWriter.buildDOM(resources.getConditions());
            doc.ImportNode(conditionsNode, true);
            resourcesNode.AppendChild(conditionsNode);
        }

        // Take the array of types and values of the assets
        string[] assetTypes  = resources.getAssetTypes();
        string[] assetValues = resources.getAssetValues();
        for (int i = 0; i < resources.getAssetCount(); i++)
        {
            XmlElement assetElement = doc.CreateElement("asset");
            assetElement.SetAttribute("type", assetTypes[i]);
            assetElement.SetAttribute("uri", assetValues[i]);
            resourcesNode.AppendChild(assetElement);
        }

        // If the owner is an item
        if (resourcesType == RESOURCES_ITEM)
        {
            // If the item has no image, add the default one
            if (resources.getAssetPath("image") == null)
            {
                XmlElement assetElement = doc.CreateElement("asset");
                assetElement.SetAttribute("type", "image");
                assetElement.SetAttribute("uri", SpecialAssetPaths.ASSET_EMPTY_IMAGE);
                resourcesNode.AppendChild(assetElement);
            }

            // If the item has no icon, add the default one
            if (resources.getAssetPath("icon") == null)
            {
                XmlElement assetElement = doc.CreateElement("asset");
                assetElement.SetAttribute("type", "icon");
                assetElement.SetAttribute("uri", SpecialAssetPaths.ASSET_EMPTY_ICON);
                resourcesNode.AppendChild(assetElement);
            }
        }

        // If the owner is a scene
        if (resourcesType == RESOURCES_SCENE)
        {
            // If the item has no image, add the default one
            if (resources.getAssetPath("background") == null)
            {
                XmlElement assetElement = doc.CreateElement("asset");
                assetElement.SetAttribute("type", "background");
                assetElement.SetAttribute("uri", SpecialAssetPaths.ASSET_EMPTY_BACKGROUND);
                resourcesNode.AppendChild(assetElement);
            }
        }

        // If the owner is a scene
        if (resourcesType == RESOURCES_CUTSCENE)
        {
            // If the item has no image, add the default one
            if (resources.getAssetPath("slides") == null)
            {
                XmlElement assetElement = doc.CreateElement("asset");
                assetElement.SetAttribute("type", "slides");
                assetElement.SetAttribute("uri", SpecialAssetPaths.ASSET_EMPTY_ANIMATION);
                resourcesNode.AppendChild(assetElement);
            }
        }

        // If the owner is a character
        else if (resourcesType == RESOURCES_CHARACTER)
        {
            // For each asset, if it has not been declared attach the empty animation
            string[] assets = new string[]
            {
                "standup", "standdown", "standright", "standleft", "speakup", "speakdown", "speakright", "speakleft",
                "useright", "useleft", "walkup", "walkdown", "walkright", "walkleft"
            };
            foreach (string asset in assets)
            {
                if (resources.getAssetPath(asset) == null)
                {
                    XmlElement assetElement = doc.CreateElement("asset");
                    assetElement.SetAttribute("type", asset);
                    assetElement.SetAttribute("uri", SpecialAssetPaths.ASSET_EMPTY_ANIMATION);
                    resourcesNode.AppendChild(assetElement);
                }
            }
        }

        // If the owner is a character
        else if (resourcesType == RESOURCES_CUSTOM_ACTION)
        {
            // For each asset, if it has not been declared attach the empty animation
            string[] assets = new string[] { "buttonNormal", "buttonOver", "buttonPressed" };
            foreach (string asset in assets)
            {
                if (resources.getAssetPath(asset) == null)
                {
                    XmlElement assetElement = doc.CreateElement("asset");
                    assetElement.SetAttribute("type", asset);
                    assetElement.SetAttribute("uri", SpecialAssetPaths.ASSET_EMPTY_ICON);
                    resourcesNode.AppendChild(assetElement);
                }
            }
        }

        // if the owner is a book
        else if (resourcesType == RESOURCES_BOOK)
        {
            // For each asset, if it has not been declared attach the empty animation
            string[] assets = new string[]
            { "background" /*, "arrowLeftNormal", "arrowRightNormal", "arrowLeftOver", "arrowRightOver" */ };
            foreach (string asset in assets)
            {
                if (resources.getAssetPath(asset) == null)
                {
                    XmlElement assetElement = doc.CreateElement("asset");
                    assetElement.SetAttribute("type", asset);
                    assetElement.SetAttribute("uri", SpecialAssetPaths.ASSET_EMPTY_BACKGROUND);
                    resourcesNode.AppendChild(assetElement);
                }
            }
        }

        return(resourcesNode);
    }