private void CheckPoint() { //Reset Coralina to Start Position before the movements character.transform.position = CurrentPosition; //Deletes the previous blocks AlgothimDevelopment.resetCell(); }
// Depeding of the type of action blocks, the player will be able to place a direction and quantity block. //it will also destroy any previously deposity item. void DisableDropOtherblocks(int x) { GameObject parent = this.transform.parent.gameObject; parent.transform.Find("Direction Cell").GetComponent <DragAndDropCell>().canDrop = true; parent.transform.Find("Quantity Cell").GetComponent <DragAndDropCell>().canDrop = true; if (x == 1) // Pickup or Drop Block { //Dirrection parent.transform.Find("Direction Cell").GetComponent <DragAndDropCell>().canDrop = false; parent.transform.Find("Direction Cell").GetComponent <DragAndDropCell>().DestroyItem(); AlgothimDevelopment.deleteCellArray(parent.name, 1); //Quantity parent.transform.Find("Quantity Cell").GetComponent <DragAndDropCell>().canDrop = false; parent.transform.Find("Quantity Cell").GetComponent <DragAndDropCell>().DestroyItem(); AlgothimDevelopment.deleteCellArray(parent.name, 2); } else if (x == 2) // Jump Block { parent.transform.Find("Quantity Cell").GetComponent <DragAndDropCell>().canDrop = false; parent.transform.Find("Quantity Cell").GetComponent <DragAndDropCell>().DestroyItem(); AlgothimDevelopment.deleteCellArray(parent.name, 2); } }
/// <summary> /// Item is dropped in this cell /// </summary> /// <param name="data"></param> public void OnDrop(PointerEventData data) { if (DragAndDropItem.icon != null) { DragAndDropItem item = DragAndDropItem.draggedItem; DragAndDropCell sourceCell = DragAndDropItem.sourceCell; if (DragAndDropItem.icon.activeSelf == true) // If icon inactive do not need to drop item into cell { if ((item != null) && (sourceCell != this)) { DropEventDescriptor desc = new DropEventDescriptor(); switch (cellType) // Check this cell's type { case CellType.Swap: // Item in destination cell can be swapped UpdateMyItem(); switch (sourceCell.cellType) { case CellType.Swap: // Item in source cell can be swapped // Fill event descriptor desc.item = item; desc.sourceCell = sourceCell; desc.destinationCell = this; SendRequest(desc); // Send drop request StartCoroutine(NotifyOnDragEnd(desc)); // Send notification after drop will be finished if (desc.permission == true) // If drop permitted by application { if (myDadItem != null) // If destination cell has item { // Fill event descriptor DropEventDescriptor descAutoswap = new DropEventDescriptor(); descAutoswap.item = myDadItem; descAutoswap.sourceCell = this; descAutoswap.destinationCell = sourceCell; SendRequest(descAutoswap); // Send drop request StartCoroutine(NotifyOnDragEnd(descAutoswap)); // Send notification after drop will be finished if (descAutoswap.permission == true) // If drop permitted by application { SwapItems(sourceCell, this); // Swap items between cells } else { PlaceItem(item); // Delete old item and place dropped item into this cell } } else { PlaceItem(item); // Place dropped item into this empty cell } } break; default: // Item in source cell can not be swapped // Fill event descriptor desc.item = item; desc.sourceCell = sourceCell; desc.destinationCell = this; SendRequest(desc); // Send drop request StartCoroutine(NotifyOnDragEnd(desc)); // Send notification after drop will be finished if (desc.permission == true) // If drop permitted by application { PlaceItem(item); // Place dropped item into this cell } break; } break; case CellType.DropOnly: // Item only can be dropped into destination cell // Fill event descriptor desc.item = item; desc.sourceCell = sourceCell; desc.destinationCell = this; SendRequest(desc); // Send drop request StartCoroutine(NotifyOnDragEnd(desc)); // Send notification after drop will be finished //Object Parent GameObject parent = this.transform.parent.gameObject; if (!Tutorial) { if (this.Action && item.Action && desc.permission == true) { PlaceItem(item); AlgothimDevelopment.addCellArray(item.name, parent.name, 0); switch (item.name) { case ("Jump"): DisableDropOtherblocks(2); break; case ("PickUp"): case ("Drop"): DisableDropOtherblocks(1); break; default: DisableDropOtherblocks(0); break; } } else if (this.Quantiy && item.Quantiy && desc.permission == true && this.canDrop == true) { AlgothimDevelopment.addCellArray(item.name, parent.name, 2); PlaceItem(item); } else if (this.Direction && item.Direction && desc.permission == true && this.canDrop == true) { AlgothimDevelopment.addCellArray(item.name, parent.name, 1); PlaceItem(item); } } else //Tutorial Enable ------------------------------------------------------------------------------------ { //Swim if (this.Action && item.Action && desc.permission == true && item.name.Equals("Swim") && Tutorialstep == 1) { PlaceItem(item); AlgothimDevelopment.addCellArray(item.name, parent.name, 0); Dialogue.text = "Dirígeme hacia dónde debo nadar."; Tutorialstep++; } //Right else if (this.Direction && item.Direction && desc.permission == true && this.canDrop == true && item.name.Equals("Right") && Tutorialstep == 2) { AlgothimDevelopment.addCellArray(item.name, parent.name, 1); PlaceItem(item); Dialogue.text = "Indícame cuantos espacios debo nadar."; Tutorialstep++; } //4 else if (this.Quantiy && item.Quantiy && desc.permission == true && this.canDrop == true && item.name.Equals("4") && Tutorialstep == 3) { AlgothimDevelopment.addCellArray(item.name, parent.name, 2); PlaceItem(item); Dialogue.text = "Ayúdame a saber qué hacer con el aluminio."; Tutorialstep++; } //Pick Up else if (this.Action && item.Action && desc.permission == true && item.name.Equals("PickUp") && Tutorialstep == 4 && item.name.Equals("PickUp")) { AlgothimDevelopment.addCellArray(item.name, parent.name, 0); PlaceItem(item); Dialogue.text = "Ayúdame a llevar la botella sobre el contenedor de reciclaje de aluminio."; Tutorialstep++; DisableDropOtherblocks(1); } //Swim else if (this.Action && item.Action && desc.permission == true && item.name.Equals("Swim") && Tutorialstep == 5) { AlgothimDevelopment.addCellArray(item.name, parent.name, 0); PlaceItem(item); Dialogue.text = "Ayúdame a llevar la botella sobre el contenedor de reciclaje de aluminio."; Tutorialstep++; } //Down else if (this.Direction && item.Direction && desc.permission == true && this.canDrop == true && item.name.Equals("Down") && Tutorialstep == 6) { AlgothimDevelopment.addCellArray(item.name, parent.name, 1); PlaceItem(item); Dialogue.text = "Ayúdame a llevar la botella sobre el contenedor de reciclaje de aluminio."; Tutorialstep++; } //4 else if (this.Quantiy && item.Quantiy && desc.permission == true && this.canDrop == true && item.name.Equals("4") && Tutorialstep == 7) { AlgothimDevelopment.addCellArray(item.name, parent.name, 2); PlaceItem(item); Dialogue.text = "Ayúdame a saber qué hacer cuando este sobre el contenedor."; Tutorialstep++; } //Drop else if (this.Action && item.Action && desc.permission == true && item.name.Equals("Drop") && Tutorialstep == 8 && item.name.Equals("Drop")) { AlgothimDevelopment.addCellArray(item.name, parent.name, 0); PlaceItem(item); Dialogue.text = "Presiona Play para correr el algoritmo de recoger y desechar la lata de aluminio."; Tutorialstep++; DisableDropOtherblocks(1); } //Wait for play button else if (Tutorialstep == 9) // wait for play button { Dialogue.text = "Dirígeme hacia dónde debo nadar para alcanzar el cristal."; } //Secon Part ----------------------- //swim else if (this.Action && item.Action && desc.permission == true && item.name.Equals("Swim") && Tutorialstep == 10) { AlgothimDevelopment.addCellArray(item.name, parent.name, 0); PlaceItem(item); Dialogue.text = "Dirígeme hacia dónde debo nadar para alcanzar el cristal."; Tutorialstep++; } //left else if (this.Direction && item.Direction && desc.permission == true && this.canDrop == true && item.name.Equals("Left") && Tutorialstep == 11) { AlgothimDevelopment.addCellArray(item.name, parent.name, 1); PlaceItem(item); Dialogue.text = "Dirígeme hacia dónde debo nadar para alcanzar el cristal."; Tutorialstep++; } //1 else if (this.Quantiy && item.Quantiy && desc.permission == true && this.canDrop == true && item.name.Equals("1") && Tutorialstep == 12) { AlgothimDevelopment.addCellArray(item.name, parent.name, 2); PlaceItem(item); Dialogue.text = "Ayúdame a recoger la botella de cristal."; Tutorialstep++; } //pick up else if (this.Action && item.Action && desc.permission == true && Tutorialstep == 13 && item.name.Equals("PickUp")) { AlgothimDevelopment.addCellArray(item.name, parent.name, 0); PlaceItem(item); Dialogue.text = "Dirígeme hacia dónde debo nadar para alcanzar el cristal."; Tutorialstep++; DisableDropOtherblocks(1); } //Swim else if (this.Action && item.Action && desc.permission == true && item.name.Equals("Swim") && Tutorialstep == 14) { AlgothimDevelopment.addCellArray(item.name, parent.name, 0); PlaceItem(item); Dialogue.text = "Dirígeme hacia dónde debo nadar para alcanzar el cristal."; Tutorialstep++; } //Up else if (this.Direction && item.Direction && desc.permission == true && this.canDrop == true && item.name.Equals("Up") && Tutorialstep == 15) { AlgothimDevelopment.addCellArray(item.name, parent.name, 1); PlaceItem(item); Dialogue.text = "Dirígeme hacia dónde debo nadar para alcanzar el cristal."; Tutorialstep++; } //2 else if (this.Quantiy && item.Quantiy && desc.permission == true && this.canDrop == true && item.name.Equals("2") && Tutorialstep == 16) { AlgothimDevelopment.addCellArray(item.name, parent.name, 2); PlaceItem(item); Dialogue.text = "Dirígeme hacia dónde debo nadar para alcanzar el cristal."; Tutorialstep++; } //Swim else if (this.Action && item.Action && desc.permission == true && item.name.Equals("Swim") && Tutorialstep == 17) { AlgothimDevelopment.addCellArray(item.name, parent.name, 0); PlaceItem(item); Dialogue.text = "Dirígeme hacia dónde debo nadar para alcanzar el cristal."; Tutorialstep++; } //Right else if (this.Direction && item.Direction && desc.permission == true && this.canDrop == true && item.name.Equals("Right") && Tutorialstep == 18) { AlgothimDevelopment.addCellArray(item.name, parent.name, 1); PlaceItem(item); Dialogue.text = "Dirígeme hacia dónde debo nadar para alcanzar el cristal."; Tutorialstep++; } //2 else if (this.Quantiy && item.Quantiy && desc.permission == true && this.canDrop == true && item.name.Equals("2") && Tutorialstep == 19) { AlgothimDevelopment.addCellArray(item.name, parent.name, 2); PlaceItem(item); Dialogue.text = "Ayudame a recoger la botella de cristal."; Tutorialstep++; } //PickUp else if (this.Action && item.Action && desc.permission == true && Tutorialstep == 20 && item.name.Equals("PickUp")) { AlgothimDevelopment.addCellArray(item.name, parent.name, 0); PlaceItem(item); Dialogue.text = "Ayúdame a llevar la botella sobre el contenedor de reciclaje de cristal."; Tutorialstep++; DisableDropOtherblocks(1); } //Jump else if (this.Action && item.Action && desc.permission == true && item.name.Equals("Jump") && Tutorialstep == 21) { AlgothimDevelopment.addCellArray(item.name, parent.name, 0); PlaceItem(item); Dialogue.text = "Ayúdame a llevar la botella sobre el contenedor de reciclaje de cristal."; Tutorialstep++; DisableDropOtherblocks(2); } //Down else if (this.Direction && item.Direction && desc.permission == true && this.canDrop == true && item.name.Equals("Down") && Tutorialstep == 22) { AlgothimDevelopment.addCellArray(item.name, parent.name, 1); PlaceItem(item); Dialogue.text = "Ayúdame a saber que hago con la botella de cristal en el contendor."; Tutorialstep++; } //Drop else if (this.Action && item.Action && desc.permission == true && Tutorialstep == 23 && item.name.Equals("Drop")) { AlgothimDevelopment.addCellArray(item.name, parent.name, 0); PlaceItem(item); Dialogue.text = "Presiona el botón de play para correr el algoritmo."; Tutorialstep++; DisableDropOtherblocks(1); } } //ends tutorial --------------------------------------------------------------------------------------------- break; default: break; } } } if (item != null) { if (item.GetComponentInParent <DragAndDropCell>() == null) // If item have no cell after drop { Destroy(item.gameObject); // Destroy it } } UpdateMyItem(); UpdateBackgroundState(); sourceCell.UpdateMyItem(); sourceCell.UpdateBackgroundState(); } }