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
 public ChangeElementReferenceTool(ElementReference elementReference2, float scale2)
 {
     this.elementReference = elementReference2;
     this.scale            = scale2;
     this.oldScale         = elementReference.getScale();
     changePosition        = false;
     changeScale           = true;
 }
Exemplo n.º 3
0
    private void instanceElement <T>(ElementReference context) where T : Element
    {
        if (!ConditionChecker.check(context.getConditions()))
        {
            return;
        }

        if (!contexts.ContainsKey(context))
        {
            ElementReference new_context = new ElementReference(context.getTargetId(), context.getX(), context.getY());
            new_context.setScale(context.getScale());
            contexts.Add(context, new_context);
        }

        context = contexts [context];

        GameObject base_prefab;
        Transform  parent;
        Element    element;

        switch (typeof(T).ToString())
        {
        case "Atrezzo":
            base_prefab = Atrezzo_Prefab;
            parent      = Atrezzos;
            element     = Game.Instance.GameState.getAtrezzo(context.getTargetId());
            break;

        case "NPC":
            base_prefab = Character_Prefab;
            parent      = Characters;
            element     = Game.Instance.GameState.getCharacter(context.getTargetId());
            break;

        case "Item":
            base_prefab = Object_Prefab;
            parent      = Objects;
            element     = Game.Instance.GameState.getObject(context.getTargetId());
            break;

        default:
            return;
        }

        GameObject ret   = GameObject.Instantiate(base_prefab);
        Transform  trans = ret.GetComponent <Transform> ();

        ret.GetComponent <Representable> ().Context = context;
        ret.GetComponent <Representable> ().Element = element;
        trans.SetParent(parent);
    }
 /**
  * Get the scale for the element reference
  *
  * @return the scale for the element reference
  */
 public float getElementScale()
 {
     return(elementReference.getScale());
 }
Exemplo n.º 5
0
 protected void Adaptate()
 {
     rend.material.mainTexture = texture;
     this.transform.localScale = new Vector3(texture.width / DIVISOR, texture.height / DIVISOR, 1) * context.getScale();
 }
Exemplo n.º 6
0
    // Use this for initialization
    void Start()
    {
        foreach (ResourcesUni ar in ad.getResources())
        {
            if (ConditionChecker.check(ar.getConditions()))
            {
                Texture2DHolder th  = new Texture2DHolder(ar.getAssetPath(Atrezzo.RESOURCE_TYPE_IMAGE));
                Texture2D       tmp = th.Texture;
                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());
                break;
            }
        }
    }
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;
    }