//-----------------------------------------------------------------Funciones behavioural del script---------------------------------------------------------------------------- void Start() { tutScript = this.gameObject.GetComponent <TutorialScript>(); initControl(); initAudio(); Screen.showCursor = false; //Generacion del tablero GameObject tablero = GameObject.FindGameObjectWithTag("tablero"); posInicial = tablero.transform.position; for (int i = 0; i < alto; i++) { for (int j = 0; j < ancho; j++) { GameObject casillaTemp; casillaTemp = Instantiate(prefabCasilla, posInicial + Vector3.right * j + Vector3.forward * i, prefabCasilla.transform.rotation) as GameObject; casillaTemp.name = "Casilla_" + i + "_" + j; casillaTemp.transform.parent = tablero.transform; colorBool colTemp = colorAleatorio(probColor); casillaTemp.GetComponent <scriptCasilla>().color = colTemp; Material matTemp = colBoolToMat(colTemp); casillaTemp.renderer.material = matTemp; controlCasilla controlTemp = matToControl(matTemp); controlTemp.agregar(casillaTemp); casillaTemp.GetComponent <scriptCasilla>().control = controlTemp; } } }
private AudioClip colBoolToSFX(colorBool col) { AudioClip sfxSalida = nota1Sample; if (col.r && !col.g && !col.b) //Solo R { sfxSalida = nota1Sample; } else if (!col.r && col.g && !col.b) //Solo G { sfxSalida = nota2Sample; } else if (!col.r && !col.g && col.b) //Solo B { sfxSalida = nota3Sample; } else if (col.r && col.g && !col.b) //Dos, R y G { sfxSalida = nota4Sample; } else if (col.r && !col.g && col.b) //Dos, R y B { sfxSalida = nota5Sample; } else if (!col.r && col.g && col.b) //Dos, G y B { sfxSalida = nota6Sample; } return(sfxSalida); }
public Material colBoolToMat(colorBool col) { Material matSalida = colorBase; if (col.r && !col.g && !col.b) //Solo R { matSalida = color1; } else if (!col.r && col.g && !col.b) //Solo G { matSalida = color2; } else if (!col.r && !col.g && col.b) //Solo B { matSalida = color3; } else if (col.r && col.g && !col.b) //Dos, R y G { matSalida = color4; } else if (col.r && !col.g && col.b) //Dos, R y B { matSalida = color5; } else if (!col.r && col.g && col.b) //Dos, G y B { matSalida = color6; } return(matSalida); }
public void cambiaColorJug(colorBool col, GameObject cas, controlCasilla cont, int numCas) { Material matTemp = colBoolToMat(col); controlCasilla controlTemp = matToControl(matTemp); cont.quitar(numCas); controlTemp.agregar(cas); cas.renderer.material = matTemp; scriptCasilla casilla = cas.GetComponent <scriptCasilla>(); casilla.control = controlTemp; }
private colorBool colorAleatorio(float prob) { colorBool colorSalida = new colorBool(); colorSalida.r = false; colorSalida.g = false; colorSalida.b = false; if (Random.Range(0.0f, 1.0f) < prob) { int t = Random.Range(0, 6); switch (t) { case 0: colorSalida.r = true; break; case 1: colorSalida.g = true; break; case 2: colorSalida.b = true; break; case 3: colorSalida.r = true; colorSalida.g = true; break; case 4: colorSalida.r = true; colorSalida.b = true; break; case 5: colorSalida.g = true; colorSalida.b = true; break; default: Debug.LogError("Algo ha ocurrido durante la eleccion aleatoria de color. Valor de la tirada = " + t + "."); break; } } return(colorSalida); }
public void Update() { if (moving) { transform.position = Vector3.Lerp(transform.position, targetPosition, movementSpeed * Time.smoothDeltaTime); if (Mathf.Abs(transform.position.z - targetPosition.z) < 0.05f && Mathf.Abs(transform.position.x - targetPosition.x) < 0.05f) { transform.position = targetPosition; moving = false; //Debug.Log("Final :"+Time.time); } } else { if (Input.anyKey) { if (Time.time > lastPressTime + delayMovimiento) { x = transform.position.x; z = transform.position.z; casillaActual = Utilidades.dameCasilla(x, z); casillaActualScript = casillaActual.GetComponent <scriptCasilla>(); // Movimiento if ((Input.GetAxisRaw("Vertical") != 0) && !(animation.IsPlaying("subir") || animation.IsPlaying("bajar"))) { lastPressTime = Time.time; if (Utilidades.hayCasilla(x, z + Input.GetAxisRaw("Vertical"))) { animation.PlayQueued("bajar"); //transform.Translate(Vector3.forward*Input.GetAxisRaw("Vertical"),Space.World); targetPosition = transform.position + Vector3.forward * Input.GetAxisRaw("Vertical"); //Debug.Log("Inicio :"+Time.time); moving = true; animation.PlayQueued("subir"); } } if ((Input.GetAxisRaw("Horizontal") != 0) && !(animation.IsPlaying("subir") || animation.IsPlaying("bajar"))) { lastPressTime = Time.time; if (Utilidades.hayCasilla(x + Input.GetAxisRaw("Horizontal"), z)) { animation.PlayQueued("bajar"); //transform.Translate(Vector3.right*Input.GetAxisRaw("Horizontal"),Space.World); targetPosition = transform.position + Vector3.right * Input.GetAxisRaw("Horizontal"); moving = true; animation.PlayQueued("subir"); } } } } if (Time.time > lastPressTime + delayAbsorber) { //Acciones casilla if (Input.GetButton("Fire1")) { lastPressTime = Time.time; if (casillaActualScript.quitarRojo()) { absorberBits.particleSystem.renderer.material.SetColor("_Emission", Color.red); animation.PlayQueued("absorber"); } colorBool color = casillaActualScript.color; logicaControl.cambiaColorJug(color, casillaActual, casillaActualScript.control, casillaActualScript.ordenControl); } else if (Input.GetButton("Fire2")) // && !(animation.IsPlaying("subir"))) { lastPressTime = Time.time; if (casillaActualScript.quitarVerde()) { absorberBits.particleSystem.renderer.material.SetColor("_Emission", Color.yellow); animation.PlayQueued("absorber"); } colorBool color = casillaActualScript.color; logicaControl.cambiaColorJug(color, casillaActual, casillaActualScript.control, casillaActualScript.ordenControl); } else if (Input.GetButton("Fire3")) // && !(animation.IsPlaying("subir"))) { lastPressTime = Time.time; if (casillaActualScript.quitarAzul()) { animation.PlayQueued("absorber"); absorberBits.particleSystem.renderer.material.SetColor("_Emission", new Color(0.0f, 0.2f, 1.0f, 1.0f)); } colorBool color = casillaActualScript.color; logicaControl.cambiaColorJug(color, casillaActual, casillaActualScript.control, casillaActualScript.ordenControl); } } } //Zoom if ((Input.GetAxis("Mouse ScrollWheel") > 0) && (Camera.main.fieldOfView > 30)) { Camera.main.fieldOfView -= 3; } if ((Input.GetAxis("Mouse ScrollWheel") < 0) && (Camera.main.fieldOfView < 90)) { Camera.main.fieldOfView += 3; } }