Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Temas - Pedro

#1
General (Antiguo) / Juego 2D
Mayo 20, 2018, 05:58:14 PM
Hola a todos, otra vez 
 
Tengo este script que es el que controla todo el juego 2D
 

using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class GameController : MonoBehaviour
{
    public static GameController gameController;
    public GameObject Player;
    [Header("Mecanica de Vidas")]
    public Sprite spriteHeartFull;
    public Sprite spriteHeartVacio;
    public Image[] heart;
    private int cantidadDeCorazones;
    [Header("Sistema de Pausa")]
    public GameObject gameObjectPause;
    private bool pauseActive;
    [Header("Sistema de Cuenta Regresivs")]
    public float tiempo;
    private float tiempoInicial;
    public Text textTiempoRegresivo;
    [Header("Victoria y Derrota")]
    public GameObject ganar;
    public GameObject gameOver;
    private void Awake()
    {
        //Un sistema que no entiendo pero se usa para variables STATIC
        DontDestroyOnLoad(this);
        if(GameController.gameController == null)
        {
            GameController.gameController = this;
        }
        else if(GameController.gameController != null)
        {
            Destroy(gameObject);
        }
    }
    private void Start()
    {
        //Compruebo si el objeto pausa esta activo y si es asi lo desactivo
        if (gameObjectPause == true)
        {
            gameObjectPause.SetActive(false);
        }
        //La cantidad de corazones sera el tama�o del Arrays
        cantidadDeCorazones = heart.Length - 1;
        //La variable tiempoInicial sera el tiempo establecido para cada mapa
        tiempoInicial = tiempo;
    }
    private void Update()
    {
        //Compruebo cuando preciono el boton escape para activar o desactivar la pausa
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            ActiveODesactivarPause();
        }
        //Inicio La cuenta regresiva
        tiempo -= Time.deltaTime;
        textTiempoRegresivo.text = tiempo.ToString("000");
        //Si el tiempo ya va por la mita o mas abajo del tiempo incial la cuenta regresiva tendra un color rojo
        if (tiempo <= (tiempoInicial / 2))
        {
            textTiempoRegresivo.color = Color.red;
        }
    }
    public void QuitarUnaVida()
    {
        //Me aseguro de que cantidadDeCorzones nunca sea menor que 0 y que cuando llegue a ser 1 activar el gameOver
        if (cantidadDeCorazones <= -1)
        {
            //Llamo al metodo ActivarGameOver
            ActivarGameOver();
            cantidadDeCorazones = 0;
        }
        //Quito una vida usando la cantidadDeCorazones para saber a cual corazon dirijirme y cambiarle el sprite
        heart[cantidadDeCorazones].sprite = spriteHeartVacio;
        //Le resto una a la cantidadDeCorzonse porque le quite una vida
        cantidadDeCorazones--;
        //Desvuelvo al jugador a su posicion incial
        Player.transform.position = Player.GetComponent<PlayerController>().posicionIncial;
    }
    public void DarUnaVida()
    {
        //CantidadDeCorazones le sumo 1
        cantidadDeCorazones++;
        //Doy una vida usando la cantidadDeCorazones para saber a cual corazon dirijirme y cambiarle el sprite
        heart[cantidadDeCorazones].sprite = spriteHeartFull;
        //Me aseguro que cantidadDeCorazones nunca sea mayor que el heart.Length - 1(Es decir no tener mas corazones de los que poseo)
        if (cantidadDeCorazones == heart.Length) cantidadDeCorazones = heart.Length - 1;
    }
    public void ActiveODesactivarPause()
    {
        //si apusa es activa la paso a desactiva y si es desactiva la paso a activa
        pauseActive = !pauseActive;
        //Activo o descativo el objeto pausa dependiendo del valor de pauseActive
        gameObjectPause.SetActive(pauseActive);
        //Detengo o prosigo el tiempo dependiendo de pauseActive
        Time.timeScale = pauseActive ? 0 : 1;
    }
    private void ActivarGameOver()
    {
        //Activo el objeto gameOver
        gameOver.SetActive(true);
        //Paralizo el tiempo
        Time.timeScale = 0;
    }
}

 
El caso es que cuando le doy a pausa o pierdo y me aparece la ui de gameover y le doy a reiniciar o a menu principal me sale este error
 



   
      MissingReferenceException: The object of type 'Text' has been destro*** but you are still trying to access it.
      Your script should either check if it is null or you should not destroy the object.
      UnityEngine.EventSystems.UIBehaviour.IsActive () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/UIBehaviour.cs:22)
      UnityEngine.UI.Graphic.SetVerticesDirty () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Graphic.cs:100)
      UnityEngine.UI.Text.set_text (System.String value) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Text.cs:138)
      GameController.Update () (at Assets/Scripts/GameController.cs:68)
   

[/quote]
 

 
 
Lo he buscado en el inspector y lo que ocurre es que se destruye el objeto text, pero al iniciar la partida vuelve a estar pero ya no funciona. Alguna idea=?
 
Ya esta echo
#2
General (Antiguo) / Scripts Problemas3
Mayo 19, 2018, 08:36:28 PM
Tengo este script
 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Gif : MonoBehaviour {
    public Button Boton;
    public Sprite[] frames;
    public int FramesPorSegundo = 10;
// Use this for initialization
void Start () {
        Boton = GameObject.Find("Boton").GetComponent<Button>();
}

// Update is called once per frame
void Update () {
        int Index = FramesPorSegundo * Time.deltaTime;
        Index = Index % frames.Length;
        Boton.image.sprite = frames[Index];
}
}

 
Y me lanza el siguiente error:
 
Assets/Scripts/Gif.cs(18,21): error CS0266: Cannot implicitly convert type `float' to `int'. An explicit conversion exists (are you missing a cast?)
 
Es decir el error esta en:
 

int Index = FramesPorSegundo * Time.deltaTime;

 
Pero si cambio estas variables a float, se me quita este error pero me aparece en la linea:
 

Boton.image.sprite = frames[Index];

 
Alguna idea?
 
Lo unico que quiero es insertar un Gif en la imagen de un botton
#3
General (Antiguo) / Scripts Problemas
Mayo 12, 2018, 01:38:17 PM
Acabo de hacer un par de scripts para un inventario y no me funcionan. Pulso E y no ocurre nada.
 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Pan : MonoBehaviour {
 
    GameObject player;
    Inventario Inventario;
 
    void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player");
        Inventario = player.GetComponent<Inventario>();
        Inventario.Slot1Lleno = false;
        Inventario.Slot2Lleno = false;
        Inventario.Slot3Lleno = false;
        Inventario.Slot4Lleno = false;
        Inventario.Slot5Lleno = false;
    }
    // Update is called once per frame
    void Update()
    {
    }
    public void OnTriggerStay(Collider collision)
    {
        if (collision.gameObject.name == "Pan")
        {
            if (Input.GetKeyDown(KeyCode.E) && Inventario.Slot1Lleno != true)
            {
                Inventario.Pan = true;
                Inventario.Slot1Lleno = true;
                Destroy(collision, 0);
            }
            if (Input.GetKeyDown(KeyCode.E) && Inventario.Slot1Lleno != false)
            {
                Inventario.Pan = true;
                Inventario.Slot2Lleno = true;
                Destroy(collision, 0);
            }
            if (Input.GetKeyDown(KeyCode.E) && Inventario.Slot1Lleno != false && Inventario.Slot2Lleno != false)
            {
                Inventario.Pan = true;
                Inventario.Slot3Lleno = true;
                Destroy(collision, 0);
            }
            if (Input.GetKeyDown(KeyCode.E) && Inventario.Slot1Lleno != false && Inventario.Slot2Lleno != false && Inventario.Slot3Lleno != false)
            {
                Inventario.Pan = true;
                Inventario.Slot4Lleno = true;
                Destroy(collision, 0);
            }
            if (Input.GetKeyDown(KeyCode.E) && Inventario.Slot1Lleno != false && Inventario.Slot2Lleno != false && Inventario.Slot3Lleno != false && Inventario.Slot5Lleno != false)
            {
                Inventario.Pan = true;
                Inventario.Slot5Lleno = true;
                Destroy(collision, 0);
            }
        }
    }
 
}


using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Inventario : MonoBehaviour
{
    public Image Slot1;
    public Image Slot2;
    public Image Slot3;
    public Image Slot4;
    public Image Slot5;
    public bool Slot1Lleno;
    public bool Slot2Lleno;
    public bool Slot3Lleno;
    public bool Slot4Lleno;
    public bool Slot5Lleno;
    public bool Botella;
    public bool Botiquin;
    public bool Manzana;
    public bool Pan;
    public bool vendas;
    void Start()
    {
        Slot1 = GameObject.Find("Slot1").GetComponent<Image>();
        Slot2 = GameObject.Find("Slot2").GetComponent<Image>();
        Slot3 = GameObject.Find("Slot3").GetComponent<Image>();
        Slot4 = GameObject.Find("Slot4").GetComponent<Image>();
        Slot5 = GameObject.Find("Slot5").GetComponent<Image>();
    }
    void Update()
    {
        //Slot1
        if (Botella && Slot1Lleno != true && Slot2Lleno != false && Slot3Lleno != false && Slot4Lleno != false && Slot5Lleno != false)
        {
            Slot1.sprite = Resources.Load<Sprite>("Inventario/botella");
           
        }
        if (Botiquin && Slot1Lleno != true && Slot2Lleno != false && Slot3Lleno != false && Slot4Lleno != false && Slot5Lleno != false)
        {
            Slot1.sprite = Resources.Load<Sprite>("Inventario/botiquin");
        }
        if (Manzana && Slot1Lleno != true && Slot2Lleno != false && Slot3Lleno != false && Slot4Lleno != false && Slot5Lleno != false)
        {
            Slot1.sprite = Resources.Load<Sprite>("Inventario/manzana");
        }
        if (Pan && Slot1Lleno != true && Slot2Lleno != false && Slot3Lleno != false && Slot4Lleno != false && Slot5Lleno != false)
        {
            Slot1.sprite = Resources.Load<Sprite>("Inventario/Pan");
        }
        if (vendas && Slot1Lleno != true && Slot2Lleno != false && Slot3Lleno != false && Slot4Lleno != false && Slot5Lleno != false)
        {
            Slot1.sprite = Resources.Load<Sprite>("Inventario/vendas");
        }
        //Slot2
        if (Botella && Slot1Lleno != false && Slot2Lleno != true && Slot3Lleno != false && Slot4Lleno != false && Slot5Lleno )
        {
            Slot2.sprite = Resources.Load<Sprite>("Inventario/botella");
        }
        if (Botiquin && Slot1Lleno != false && Slot2Lleno != true && Slot3Lleno != false && Slot4Lleno != false && Slot5Lleno)
        {
            Slot2.sprite = Resources.Load<Sprite>("Inventario/botiquin");
        }
        if (Manzana && Slot1Lleno != false && Slot2Lleno != true && Slot3Lleno != false && Slot4Lleno != false && Slot5Lleno)
        {
            Slot2.sprite = Resources.Load<Sprite>("Inventario/manzana");
        }
        if (Pan && Slot1Lleno != false && Slot2Lleno != true && Slot3Lleno != false && Slot4Lleno != false && Slot5Lleno)
        {
            Slot2.sprite = Resources.Load<Sprite>("Inventario/Pan");
        }
        if (vendas && Slot1Lleno != false && Slot2Lleno != true && Slot3Lleno != false && Slot4Lleno != false && Slot5Lleno)
        {
            Slot2.sprite = Resources.Load<Sprite>("Inventario/vendas");
        }
        //Slot3
        if (Botella && Slot1Lleno != false && Slot2Lleno != false && Slot3Lleno != true && Slot4Lleno != false && Slot5Lleno != false)
        {
            Slot3.sprite = Resources.Load<Sprite>("Inventario/botella");
        }
        if (Botiquin && Slot1Lleno != false && Slot2Lleno != false && Slot3Lleno != true && Slot4Lleno != false && Slot5Lleno != false)
        {
            Slot3.sprite = Resources.Load<Sprite>("Inventario/botiquin");
        }
        if (Manzana && Slot1Lleno != false && Slot2Lleno != false && Slot3Lleno != true && Slot4Lleno != false && Slot5Lleno != false)
        {
            Slot3.sprite = Resources.Load<Sprite>("Inventario/manzana");
        }
        if (Pan && Slot1Lleno != false && Slot2Lleno != false && Slot3Lleno != true && Slot4Lleno != false && Slot5Lleno != false)
        {
            Slot3.sprite = Resources.Load<Sprite>("Inventario/Pan");
        }
        if (vendas && Slot1Lleno != false && Slot2Lleno != false && Slot3Lleno != true && Slot4Lleno != false && Slot5Lleno != false)
        {
            Slot3.sprite = Resources.Load<Sprite>("Inventario/vendas");
        }
        //Slot4
        if (Botella && Slot1Lleno != false && Slot2Lleno != false && Slot3Lleno != false && Slot4Lleno != true && Slot5Lleno != false)
        {
            Slot4.sprite = Resources.Load<Sprite>("Inventario/botella");
        }
        if (Botiquin && Slot1Lleno != false && Slot2Lleno != false && Slot3Lleno != false && Slot4Lleno != true && Slot5Lleno != false)
        {
            Slot4.sprite = Resources.Load<Sprite>("Inventario/botiquin");
        }
        if (Manzana && Slot1Lleno != false && Slot2Lleno != false && Slot3Lleno != false && Slot4Lleno != true && Slot5Lleno != false)
        {
            Slot4.sprite = Resources.Load<Sprite>("Inventario/manzana");
        }
        if (Pan && Slot1Lleno != false && Slot2Lleno != false && Slot3Lleno != false && Slot4Lleno != true && Slot5Lleno != false)
        {
            Slot4.sprite = Resources.Load<Sprite>("Inventario/Pan");
        }
        if (vendas && Slot1Lleno != false && Slot2Lleno != false && Slot3Lleno != false && Slot4Lleno != true && Slot5Lleno != false)
        {
            Slot4.sprite = Resources.Load<Sprite>("Inventario/vendas");
        }
        //Slot5
        if (Botella && Slot1Lleno != false && Slot2Lleno != false && Slot3Lleno != false && Slot4Lleno != false && Slot5Lleno != true)
        {
            Slot5.sprite = Resources.Load<Sprite>("Inventario/botella");
        }
        if (Botiquin && Slot1Lleno != false && Slot2Lleno != false && Slot3Lleno != false && Slot4Lleno != false && Slot5Lleno != true)
        {
            Slot5.sprite = Resources.Load<Sprite>("Inventario/botiquin");
        }
        if (Manzana && Slot1Lleno != false && Slot2Lleno != false && Slot3Lleno != false && Slot4Lleno != false && Slot5Lleno != true)
        {
            Slot5.sprite = Resources.Load<Sprite>("Inventario/manzana");
        }
        if (Pan && Slot1Lleno != false && Slot2Lleno != false && Slot3Lleno != false && Slot4Lleno != false && Slot5Lleno != true)
        {
            Slot5.sprite = Resources.Load<Sprite>("Inventario/Pan");
        }
        if (vendas && Slot1Lleno != false && Slot2Lleno != false && Slot3Lleno != false && Slot4Lleno != false && Slot5Lleno != true)
        {
            Slot5.sprite = Resources.Load<Sprite>("Inventario/vendas");
        }
    }
}

 
 
#4

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Agua : MonoBehaviour {
 
    GameObject player;
    public GameObject Water;
 
    void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player");
    }
    // Update is called once per frame
    void Update()
    {
    }
    public void OnTriggerEnter(Collider other)
    {
        if (other.gameObject == player)
        {
            RecogerAgua();
        }
    }
        void RecogerAgua()
        {
            if (Input.GetKeyDown(KeyCode.E))
            {
                Water.SetActive(false);
            }
        }
   
}

 
Hola a todos :D estoy intentando crear un script para recoger objetos al pulsar E pero al ponerlo en unity y darle a play no ocurre nada, sabrian decirme por que? aqui os dejo el script.
 
 
#5
General (Antiguo) / Ayuda Urgente Please
Octubre 23, 2017, 02:02:58 PM
Buenas, tengo un pequeño problema, estoy terminando un código, y resulta que me aparece un error y no soy capaz de encontrar la solución, quería saber si alguien podría ayudarme.
 
Aquí dejo el error:
 
"Assets/Scripts/Manager.cs(221,20): error CS0161: `Manager.ObtenerInfo(Cuadricula)': not all code paths return a value"
 
Y aquí el código:
 

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Manager : MonoBehaviour {
public int TamañoX, TamañoY;
GameObject [] _items;
public Cuadricula[,] BidItem;
Cuadricula ItemActual;

public static int minItemsPorEncuentro = 3;
bool Jugando;

void Start () {
   Jugando = true;
   ObtenerItems ();
   Grid ();
   LimpiarGrid();
   Cuadricula.SeleccionItemEvento += SeleccionItem;
}

void OnDisable ()
{
   Cuadricula.SeleccionItemEvento -= SeleccionItem;
}
void Grid () {
      
      BidItem = new Cuadricula [TamañoX, TamañoY];
      for (int x = 0; x < TamañoX; x++)
      {
         for (int y = 0; y < TamañoY; y++)
         {
            BidItem [x,y] = Instanciar (x,y);
         }
      }
    }

void LimpiarGrid()
{
   for (int x = 0; x < TamañoX; x++)
   {
      for (int y = 0; y < TamañoY; y++) {
         Encuentros encuentros = ObtenerInfo (BidItem [x, y]);
         if (encuentros.EncuentroValido) {
            Destroy (BidItem [x, y].gameObject);
            BidItem[x,y] = Instanciar (x, y);
            y--;
       }
      }
          }
                     }


Cuadricula Instanciar (int x, int y)
{
   GameObject ItemRandom = _items[Random.Range (0, _items.Length)];
   GameObject NuevoItem = (GameObject) Instantiate (ItemRandom, new Vector3 (x, y, 0f), Quaternion.identity);
   NuevoItem.GetComponent<Cuadricula>().Posicion (x,y);
   return NuevoItem.GetComponent<Cuadricula> ();
}

void SeleccionItem (Cuadricula item)
{
   if (ItemActual == item || !Jugando) {
      return;
   }
   if (ItemActual == null) {
      ItemActual = item;
   }else
   {
      float xDif = Mathf.Abs (item.x - ItemActual.x);
      float yDif = Mathf.Abs (item.y - ItemActual.y);
      if (xDif + yDif == 1)
      {
         StartCoroutine (Cambio (ItemActual, item));
         //cambiar
      }else
      {
         Debug.Log ("Ese cambio no esta permitido");
      }
      ItemActual = null;
   }
}

IEnumerator IntentoEncuentros ( Cuadricula a, Cuadricula b)
{
   Jugando = false;
   yield return StartCoroutine (Cambio (a, b));
   Encuentros EncuentroA = ObtenerInfo (a);
   Encuentros EncuentroB = ObtenerInfo (b);
   
   if(!EncuentroA.EncuentroValido && !EncuentroB.EncuentroValido) {
      yield return StartCoroutine (Cambio (a, b));
      yield break;
   }
   if (EncuentroA.EncuentroValido)
   {
      yield return StartCoroutine (DestruirItems (EncuentroA.Encuentro));
      yield return StartCoroutine (UpdateGrid (EncuentroA));
   }
   else if (EncuentroB.EncuentroValido)
   {
      yield return StartCoroutine (DestruirItems (EncuentroB.Encuentro));
      yield return StartCoroutine (UpdateGrid (EncuentroB));
   }
   Jugando = true;
}
IEnumerator UpdateGrid (Encuentros encuentro)
{
   if (encuentro.EncuentroStartY == encuentro.EncuentroEndY) {
      for ( int x = encuentro.EncuentroStartX; x <= encuentro.EncuentroEndX; x++){
         for (int y = encuentro.EncuentroStartY; y < TamañoY - 1; y++){
            Cuadricula upIndex = BidItem [x, y + 1];
            Cuadricula current = BidItem [x, y];
            BidItem [x, y] = upIndex;
            BidItem [x, y + 1] = current;
            BidItem [x, y].Posicion (BidItem [x, y].x, BidItem [x, y].y - 1);
         }
         BidItem [x, TamañoY-1] = Instanciar (x, TamañoY - 1);
      }
   }
   else if (encuentro.EncuentroEndX == encuentro.EncuentroStartX){
      int EncuentroHeight = 1 +(encuentro.EncuentroEndY - encuentro.EncuentroStartY);
      for (int y = encuentro.EncuentroStartY + EncuentroHeight; y <= TamañoY - 1; y++){
         Cuadricula lowIndex = BidItem [encuentro.EncuentroStartX, y - EncuentroHeight];
         Cuadricula current = BidItem [encuentro.EncuentroStartX, y];
         BidItem [encuentro.EncuentroStartX, y] = lowIndex;
         BidItem [encuentro.EncuentroStartX, y - EncuentroHeight] = current;
      }
      for (int y = 0; y < TamañoY - EncuentroHeight; y++) {
         BidItem [encuentro.EncuentroStartX, y].Posicion (encuentro.EncuentroStartX, y);
      }
      for (int i = 0; i < encuentro.Encuentro.Count; i++) {
         BidItem [encuentro.EncuentroStartX, (TamañoY-1) - i] = Instanciar (encuentro.EncuentroStartX, (TamañoY -1) -i) ;
      }
   }
   for (int x = 0; x < TamañoX; x++)
   {
      for (int y = 0; y < TamañoY; y++) {
         Encuentros encuentros = ObtenerInfo (BidItem [x, y]);
         if (encuentros.EncuentroValido) {
            yield return new WaitForSeconds (minItemsPorEncuentro);
            yield return StartCoroutine (DestruirItems (encuentros.Encuentro));
            yield return new WaitForSeconds (minItemsPorEncuentro);
            yield return StartCoroutine (UpdateGrid (encuentros));
   
         }
      }
   }
}

IEnumerator DestruirItems ( List <Cuadricula> items)
{
   foreach (Cuadricula i in items) {
      yield return StartCoroutine (i.transform.Escala (Vector3.zero, 0.01f));
      DestroyImmediate (i.gameObject);
   }
}

IEnumerator Cambio ( Cuadricula a, Cuadricula b)
{
   CambioRigidbody (false);
   float DuracionMov = 0.1f;
   Vector3 PosicionItemA = a.transform.position;
   StartCoroutine (a.transform.Move (b.transform.position, DuracionMov));
   StartCoroutine (b.transform.Move (PosicionItemA, DuracionMov));
   yield return new WaitForSeconds (DuracionMov);
   CambioRigidbody (true);
}

void ActualizarValores ( Cuadricula a, Cuadricula b)
{
   Cuadricula TemporalA = BidItem [a.x, a.y];
   BidItem [a.x, a.y] = b;
   BidItem [b.x, b.y] = TemporalA;
   int ViejobX = b.x;
   int ViejobY = b.y;
   b.Posicion (a.x, a.y);
   a.Posicion(ViejobX, ViejobY);
}

List <Cuadricula> BuscarHorizontal ( Cuadricula item)
{
   List <Cuadricula> HItems = new List <Cuadricula>{ item };
   int Left = item.x -1;
   int Right = item.x +1;
   while (Left >= 0 && BidItem [Left, item.y].id == item.id)
   {
      HItems.Add (BidItem [Left,item.y]);
      Left--;
   }
   while (Right < TamañoX && BidItem [Right, item.y].id == item.id)
   {
      HItems.Add (BidItem [Right,item.y]);
      Right--;
   }
      return HItems;
}
List <Cuadricula> BuscarVertical ( Cuadricula item)
{
   List <Cuadricula> VItems = new List <Cuadricula>{ item };
   int Lower = item.y -1;
   int Upper = item.y +1;
   while (Lower >= 0 && BidItem [item.x, Lower].id == item.id)
   {
      VItems.Add (BidItem [item.x, Lower]);
      Lower--;
   }
   while (Upper < TamañoY && BidItem [item.x, Upper].id == item.id)
   {
      VItems.Add (BidItem [item.x, Upper]);
      Upper++;
   }
      return VItems;
}

Encuentros ObtenerInfo ( Cuadricula item)
{
   Encuentros E = new Encuentros ();
   E.Encuentro = null;
   List <Cuadricula> HEncuentro = BuscarHorizontal (item);
   List <Cuadricula> VEncuentro = BuscarVertical (item);
   if (HEncuentro.Count >= minItemsPorEncuentro && HEncuentro.Count > VEncuentro.Count){
      //informar de los encuentros
      E.EncuentroStartX = ObtenerMinimoX(HEncuentro);
      E.EncuentroEndX = ObtenerMinimoX (HEncuentro);
      E.EncuentroStartY = E.EncuentroEndY = HEncuentro[0].y;
      E.Encuentro = HEncuentro;
   }
   else if (VEncuentro.Count >= minItemsPorEncuentro){
      E.EncuentroStartY = ObtenerMinimoX(VEncuentro);
      E.EncuentroEndY = ObtenerMaximoY(VEncuentro);
      E.EncuentroStartX = E.EncuentroEndY = HEncuentro[0].x;
      E.Encuentro = VEncuentro;
   }
}

int ObtenerMinimoX ( List <Cuadricula> items)
{
   float [] indices = new float [ items.Count];
   for (int i = 0; i < indices.Length; i++) {
      indices = items .x;
   }
   return (int)Mathf.Min (indices);
}
   

int ObtenerMaximoX ( List <Cuadricula> items)
{
   float [] indices = new float [ items.Count];
   for (int i = 0; i < indices.Length; i++) {
      indices = items .x;
   }
   return (int) Mathf.Max (indices);
}
   
   
int ObtenerMinimoY ( List <Cuadricula> items)
{
   float [] indices = new float [ items.Count];
   for (int i = 0; i < indices.Length; i++) {
      indices = items .y;
   }
   return (int) Mathf.Min (indices);
}
   

int ObtenerMaximoY ( List <Cuadricula> items)
{
   float [] indices = new float [ items.Count];
   for (int i = 0; i < indices.Length; i++) {
      indices = items .y;
   }
   return (int) Mathf.Max (indices);
}
   

void ObtenerItems()
{
   _items = Resources.LoadAll <GameObject> ("Prefabs");
   for ( int i = 0; i < _items.Length; i++) {
      _items.GetComponent <Cuadricula>().id = i;
   }
}

void CambioRigidbody ( bool Estado)
{
   foreach (Cuadricula c in BidItem) {
      c.GetComponent<Rigidbody2D>().isKinematic =!Estado;
}
}


}

 
 
#6
General (Antiguo) / Buenas :D
Septiembre 18, 2017, 11:17:56 PM
Encantado, me llamo Pedro y vivo en Merida, llevo ya 2 años dedicandome a unity por completo, asique tengo mucha experiencia :D pero siempre surge alguna duda que no soy capaz de resolver asique espero que nos ayudemos entre todos, tanto yo a vosotros como vosotros a mi, asique un placer de estar aqui y hablaremos mucho :D