Ejemplo n.º 1
0
 void Update()
 {
     if (Mathf.Abs(myCamera.ScreenToWorldPoint(Input.mousePosition).x - transform.position.x) < entity.ancho / 2 && Mathf.Abs(myCamera.ScreenToWorldPoint(Input.mousePosition).y - transform.position.y) < entity.alto / 2)
     {
         control.puntero = this;
     }
     else if (control.puntero == this)
     {
         control.puntero = null;
     }
     if (Input.GetMouseButtonUp(0) && selection.IsWithinSelectionBounds(gameObject) && entity.type == 1)
     {
         Seleccion();
     }
     if (Input.GetMouseButtonDown(0) && Input.mousePosition.y > myCamera.pixelHeight * interfaz.interfaceFraction)
     {
         if (!selected && control.puntero == this)
         {
             Seleccion();
         }
         else if (selected && !ocupado)
         {
             Deseleccion();
         }
     }
     if (selected)
     {
         if (Input.GetMouseButtonDown(1) && entity.type == 1)
         {
             Destinar();
         }
     }
     if (productionQueue.Count > 0)
     {
         productionQueue [0].Work(this);
     }
     if (recolectando && Vector3.Distance(fuente.transform.position, transform.position) < fuente.entity.size * 2)
     {
         (fuente.entity as ResourceSource).gathering.Action(this);
     }
     if (construyendo && Vector3.Distance(cimientos.transform.position, transform.position) < cimientos.entity.size * 2)
     {
         if (!cimientos.construido)
         {
             Active activa = database.searchAbility("Build") as Active;
             activa.Action(cimientos);
         }
         else
         {
             construyendo = false;
         }
     }
 }
Ejemplo n.º 2
0
    public void CreateHabilityButtons()
    {
        nombre.text = selecs[0].entity.nombre[language];
        icon.sprite = selecs[0].entity.icono;
        float xMax = sizeButtonX;
        float xMin = margenX;
        float yMax = margenY;
        float yMin = margenY - sizeButtonY;

        for (int i = 0; i < selecs[0].entity.creatives.Count; i++)
        {
            Creative      creative = selecs[0].entity.creatives [i];
            Button        boton    = (Button)Instantiate(DefaultButton, PanelHabilidades);
            RectTransform rtrans   = boton.transform as RectTransform;
            rtrans.anchorMax = new Vector2(xMax, yMax);
            rtrans.anchorMin = new Vector2(xMin, yMin);
            rtrans.offsetMax = new Vector2(0, 0);
            rtrans.offsetMin = new Vector2(0, 0);
            xMax            += sizeButtonX;
            xMin            += sizeButtonX;
            if (xMax > 1)
            {
                xMax  = sizeButtonX;
                xMin  = margenX;
                yMax -= sizeButtonY;
                yMin -= sizeButtonY;
            }
            boton.image.sprite = creative.icono;
            boton.onClick.AddListener(delegate { creative.Action(selecs[0]); });
        }
        for (int i = 0; i < selecs[0].entity.activas.Count; i++)
        {
            Active        activa = selecs[0].entity.activas [i];
            Button        boton  = (Button)Instantiate(DefaultButton, PanelHabilidades);
            RectTransform rtrans = boton.transform as RectTransform;
            rtrans.anchorMax = new Vector2(xMax, yMax);
            rtrans.anchorMin = new Vector2(xMin, yMin);
            rtrans.offsetMax = new Vector2(0, 0);
            rtrans.offsetMin = new Vector2(0, 0);
            xMax            += sizeButtonX;
            xMin            += sizeButtonX;
            if (xMax > 1)
            {
                xMax  = sizeButtonX;
                xMin  = margenX;
                yMax -= sizeButtonY;
                yMin -= sizeButtonY;
            }
            boton.image.sprite = activa.icono;
            boton.onClick.AddListener(delegate { activa.Action(selecs[0]); });
        }
        cleared = false;
    }