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());
    }
 public ChangeElementReferenceTool(ElementReference elementReference, int x, int y)
 {
     this.elementReference = elementReference;
     this.x         = x;
     this.y         = y;
     this.oldX      = elementReference.getX();
     this.oldY      = elementReference.getY();
     changePosition = true;
     changeScale    = false;
 }
 public ChangeElementReferenceTool(ElementReference elementReference, int x, int y, float scale)
 {
     this.elementReference = elementReference;
     this.x         = x;
     this.y         = y;
     this.scale     = scale;
     this.oldX      = elementReference.getX();
     this.oldY      = elementReference.getY();
     this.oldScale  = this.elementReference.getScale();
     changePosition = true;
     changeScale    = true;
 }
Exemplo n.º 4
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.º 5
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;
    }
 /**
  * Returns the x coordinate of the referenced element
  *
  * @return X coordinate of the referenced element
  */
 public int getElementX()
 {
     return(elementReference.getX());
 }
Exemplo n.º 7
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;

            if (typeof(T) == typeof(Atrezzo))
            {
                base_prefab = Atrezzo_Prefab;
                parent      = Atrezzos;
                element     = Game.Instance.GameState.getAtrezzo(context.getTargetId());
            }
            else if (typeof(T) == typeof(NPC))
            {
                base_prefab = Character_Prefab;
                parent      = Characters;
                element     = Game.Instance.GameState.getCharacter(context.getTargetId());
            }
            else if (typeof(T) == typeof(Item))
            {
                base_prefab = Object_Prefab;
                parent      = Objects;
                element     = Game.Instance.GameState.getObject(context.getTargetId());
            }
            else
            {
                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);
        }
Exemplo n.º 8
0
        protected void Positionate()
        {
            Vector2 tmppos = new Vector2(context.getX(), context.getY()) / DIVISOR + (new Vector2(0, -transform.localScale.y)) / 2;

            transform.localPosition = new Vector3(tmppos.x, HEIGHT - tmppos.y, -context.getLayer() + deformation);
        }