Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.T))
        {
            Debug.Log("dropZoneChildCount: " + dropZoneChildCount);
            Debug.Log("requestZoneChildCount: " + requestZoneChildCount);
            ////itemsInDropZone = new GameObject[transform.childCount];

            //            itemsInDropZone = new DragHandler.Slot[dropZoneChildCount];
            //            itemsInRequestZone = new DragHandler.Slot[requestZoneChildCount];
            dropZoneChildCount = dropZone.GetComponent <Transform>().childCount;
            itemsInDropZone    = new GameObject[dropZoneChildCount];
            itemsInRequestZone = new GameObject[requestZoneChildCount];

            for (int i = 0; i < requestZoneChildCount; i++)
            {
                itemsInRequestZone[i] = character.items[i]; //.GetComponent<DragHandler>().typeOfItem;
            }
            for (int i = 0; i < dropZoneChildCount; i++)
            {
                ////itemsInDropZone[i] = transform.GetChild(i).gameObject;
                itemsInDropZone[i] = dropZone.transform.GetChild(i).gameObject; //.GetComponent<DragHandler>().typeOfItem;
            }
            CheckItems();
        }
        if (Input.GetKey(KeyCode.R))
        {
            RemoveItemsFromRequestZone();
        }
    }
 private void OnMouseDown()                                             //al hacer click en la caja
 {
     if (zonaDrop.gameObject.transform.childCount >= 10 && estado == 0) //si ya ingreso los 10 objetos y es el primer estado
     {
         estado = 1;                                                    //cambio de estado
         foreach (Dragable a in dragChildren)
         {
             a.enabled = false;//desabilito la posibilidad de sacar los objetos de la caja
         }
         //muevo los objetos dentro de la caja
         zonaDrop.GetComponent <Transform>().DOMove(new Vector3(zonaDrop.transform.position.x + 6, zonaDrop.transform.position.y, zonaDrop.transform.position.z), 0.5f);
         Invoke("shake", 0.8f);   //invoco la funcion que mueve la caja hacia los lados
         Invoke("mostrar", 1.5f); //muestro los objetos dependiendo del valor randomizado
     }
     else
     {
         return;//sino ingreso los objetos o el juego esta en su segundo estado no sucede nada
     }
 }
	// Refactor
	public void DropHere(BlockGroup group, DropZone dropenOn, bool WithAnimation = false){
		BoxCell cellDropenOn = dropenOn.GetComponent<BoxCell>();
		foreach (var position in group.positions) {
			(grid.GetCell (cellDropenOn.coord + position) as BoxCell).SetColor (group.color);
		}

		if (OnSuccessfulDrop != null)
			OnSuccessfulDrop (group, dropenOn);
		
		blocksContainer.blocks.Remove (group);
		Destroy (group.gameObject);

		grid.ClearSolvedRowsAndColumns ();
	}
    public void contarDinero()                                       //metodo utilizado por el boton de validación de la escena
    {
        foreach (Transform child in drop.GetComponent <Transform>()) //por cada child en la zonadrop
        {
            switch (child.name)                                      //me fijo en el nombre y dependiendo el nombre es el valor que se le va sumando al contador
            {
            case "2pesos":
                count = count + 2;
                break;

            case "5pesos":
                count = count + 5;
                break;

            case "10pesos":
                count = count + 10;
                break;

            case "20pesos":
                count = count + 20;
                break;

            case "50pesos":
                count = count + 50;
                break;
            }
        }
        if (count == precio) //si el contador tiene el mismo valor del precio a equiparar
        {
            popUP.Bien();    //muestro el popup de etapa completada
        }
        else//sino
        {
            popUP.Mal();//muestro el popup de intentar de nuevo
        }
    }
	bool CanDropHere(BlockGroup group, DropZone dropenOn){
		BoxCell cellDropenOn = dropenOn.GetComponent<BoxCell>();
		return CanDropHere (group, cellDropenOn);
	}
	public Coord CoordForDropZone(DropZone dropZone){
		return dropZone.GetComponent<BoxCell> ().coord;
	}