Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        updateResource();
        if (current_resource != null)
        {
            string path = current_resource.getAssetPath(NPC.RESOURCE_TYPE_STAND_UP);

            //current_anim = Loader.loadAnimation(AssetsController.InputStreamCreatorEditor.getInputStreamCreator (path),path,new EditorImageLoader());
            current_anim = new eAnim(path);

            this.gameObject.name = player.getId();

            current_frame = 0;

            // ## ANIMATION METHOD ##

            /*Texture2D tmp = current_anim.getFrame(0).getImage(false,false,0).texture;
             * update_ratio = current_anim.getFrame(0).getTime();//Duration/1000f;*/

            // ## EANIM METHOD ##
            Texture2D tmp = current_anim.frames [0].Image;
            update_ratio = current_anim.frames [0].Duration / 1000f;
            this.GetComponent <Renderer> ().material.mainTexture = tmp;
            this.transform.localScale = new Vector3(tmp.width / 10, tmp.height / 10, 1) * context.getScale();
        }


        Vector2 tmppos = new Vector2(context.getX(), context.getY()) / 10 + (new Vector2(0, -transform.localScale.y)) / 2;

        transform.localPosition = new Vector3(tmppos.x, 60 - tmppos.y, -context.getLayer());
    }
Exemplo n.º 2
0
        // Use this for initialization
        protected void Start()
        {
            spriteRenderer = GetComponent <SpriteRenderer>();

            if (this.action.getType() == Action.CUSTOM)
            {
                actionName = ((CustomAction)action).getName();

                CustomAction ca = action as CustomAction;
                foreach (ResourcesUni ru in ca.getResources())
                {
                    if (ConditionChecker.check(ru.getConditions()))
                    {
                        this.resource = ru;
                    }
                }
            }
            else
            {
                /*resource = new ResourcesUni ();
                 * CustomButton button = Game.Instance.getButton (ActionNameWrapper.Names [action.getType ()],DescriptorData.NORMAL_BUTTON);
                 * CustomButton highlighted = Game.Instance.getButton (ActionNameWrapper.Names [action.getType ()],DescriptorData.HIGHLIGHTED_BUTTON);
                 *
                 * if (button == null || highlighted == null) {
                 *  button = Game.Instance.getButton (ActionNameWrapper.AuxNames [action.getType ()], DescriptorData.NORMAL_BUTTON);
                 *  highlighted = Game.Instance.getButton (ActionNameWrapper.AuxNames [action.getType ()], DescriptorData.HIGHLIGHTED_BUTTON);
                 * }
                 *
                 * resource.addAsset (DescriptorData.NORMAL_BUTTON, button.getPath());
                 * resource.addAsset (DescriptorData.HIGHLIGHTED_BUTTON, highlighted.getPath());*/

                resource = GUIManager.Instance.Provider.getButton(this.action);

                actionName = ConstantNames.L["ES"].Actions[action.getType()];
            }

            Sprite tmp;

            if (this.action.getType() == Action.CUSTOM)
            {
                tmp = Game.Instance.ResourceManager.getSprite(resource.getAssetPath("buttonNormal"));
            }
            else
            {
                tmp = Game.Instance.ResourceManager.getSprite(resource.getAssetPath(DescriptorData.NORMAL_BUTTON));
            }

            spriteRenderer.sprite = tmp;
            if (InventoryManager.Instance.Opened)
            {
                this.gameObject.AddComponent <BoxCollider2D>();
            }
            else
            {
                this.gameObject.AddComponent <BoxCollider>();
            }
            //this.transform.localScale = new Vector3(tmp.width / 75f, tmp.height / 75f, 1);
        }
Exemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        if (this.action.getType() == Action.CUSTOM)
        {
            name = ((CustomAction)action).getName();

            CustomAction ca = action as CustomAction;
            foreach (ResourcesUni ru in ca.getResources())
            {
                if (ConditionChecker.check(ru.getConditions()))
                {
                    this.resource = ru;
                }
            }
        }
        else
        {
            /*resource = new ResourcesUni ();
             * CustomButton button = Game.Instance.getButton (ActionNameWrapper.Names [action.getType ()],DescriptorData.NORMAL_BUTTON);
             * CustomButton highlighted = Game.Instance.getButton (ActionNameWrapper.Names [action.getType ()],DescriptorData.HIGHLIGHTED_BUTTON);
             *
             * if (button == null || highlighted == null) {
             *  button = Game.Instance.getButton (ActionNameWrapper.AuxNames [action.getType ()], DescriptorData.NORMAL_BUTTON);
             *  highlighted = Game.Instance.getButton (ActionNameWrapper.AuxNames [action.getType ()], DescriptorData.HIGHLIGHTED_BUTTON);
             * }
             *
             * resource.addAsset (DescriptorData.NORMAL_BUTTON, button.getPath());
             * resource.addAsset (DescriptorData.HIGHLIGHTED_BUTTON, highlighted.getPath());*/

            resource = GUIManager.Instance.Provider.getButton(this.action);

            name = ConstantNames.L ["ES"].Actions [action.getType()];
        }

        Texture2D tmp;

        if (this.action.getType() == Action.CUSTOM)
        {
            tmp = ResourceManager.Instance.getImage(resource.getAssetPath("buttonNormal"));
        }
        else
        {
            tmp = ResourceManager.Instance.getImage(resource.getAssetPath(DescriptorData.NORMAL_BUTTON));
        }

        this.GetComponent <Renderer> ().material.mainTexture = tmp;
        this.transform.localScale = new Vector3(tmp.width / 75f, tmp.height / 75f, 1);
    }
Exemplo n.º 4
0
    public override bool undoTool()
    {
        // Restores the resources object with the information stored in oldResoures
        //try
        //{
        ResourcesUni temp = resources;

        resources.clearAssets();
        string[] oldResourceTypes = oldResourcesUni.getAssetTypes();
        foreach (string type in oldResourceTypes)
        {
            resources.addAsset(type, oldResourcesUni.getAssetPath(type));
        }

        // Update older data
        oldResourcesUni.clearAssets();
        oldResourceTypes = temp.getAssetTypes();
        foreach (string type in oldResourceTypes)
        {
            oldResourcesUni.addAsset(type, temp.getAssetPath(type));
        }
        //			controller.reloadPanel();
        return(true);
        //}
        //catch (CloneNotSupportedException e)
        //{
        //    e.printStackTrace();
        //    return false;
        //}
    }
        private Texture2D LoadResource(ResourcesUni resources, string uri)
        {
            Texture2D image = null;
            var       path  = resources.getAssetPath(uri);

            if (!string.IsNullOrEmpty(path))
            {
                image = resourceManager.getImage(path);
            }
            return(image);
        }
Exemplo n.º 6
0
        private void LoadBackgroundMusic(ResourcesUni sr)
        {
            var musicPath = sr.getAssetPath(Scene.RESOURCE_TYPE_MUSIC);

            if (!string.IsNullOrEmpty(musicPath))
            {
                AudioClip audioClip   = Game.Instance.ResourceManager.getAudio(musicPath);
                var       audioSource = GetComponent <AudioSource>();
                audioSource.clip = audioClip;
                audioSource.loop = true;
                audioSource.Play();
            }
        }
Exemplo n.º 7
0
    void Start()
    {
        foreach (ResourcesUni cr in od.getResources())
        {
            if (ConditionChecker.check(cr.getConditions()))
            {
                current_resource = cr;
                string    path = cr.getAssetPath(Item.RESOURCE_TYPE_IMAGE);
                Texture2D th   = ResourceManager.Instance.getImage(path);

                this.GetComponent <Renderer> ().material.mainTexture = th;
                this.transform.localScale = new Vector3(th.width / 10, th.height / 10, 1) * context.getScale();
                break;
            }
        }

        this.gameObject.name = od.getId();

        Vector2 tmppos = new Vector2(context.getX(), context.getY()) / 10 + (new Vector2(0, -transform.localScale.y)) / 2;

        transform.localPosition = new Vector3(tmppos.x, 60 - tmppos.y, -context.getLayer());

        hasOverSprite = current_resource.getAssetPath(Item.RESOURCE_TYPE_IMAGEOVER) != null;
    }
Exemplo n.º 8
0
        //##############################################
        //################ TEXTURE PART ################
        //##############################################

        protected Texture2D LoadTexture(string uri)
        {
            return(Game.Instance.ResourceManager.getImage(resource.getAssetPath(uri)));
        }
Exemplo n.º 9
0
 protected bool SetTexture(string uri)
 {
     sprite       = Game.Instance.ResourceManager.getSprite(resource.getAssetPath(uri));
     image.sprite = sprite;
     return(sprite != null && !emptyTextures.Where(t => t == sprite.texture.name).Any());
 }
 /**
  * Returns the relative path of the given asset.
  *
  * @param asset
  *            Name of the asset
  * @return The path to the resource if present, null otherwise
  */
 public string getAssetPath(string asset)
 {
     return(resources.getAssetPath(asset));
 }
Exemplo n.º 11
0
    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);
    }
Exemplo n.º 12
0
 protected void LoadTexture(string uri)
 {
     texture = ResourceManager.Instance.getImage(resource.getAssetPath(uri));
 }