static bool verificarChave(int indexChave) { Chave chave = elementosManobra.listOfChaves[indexChave]; Debug.Log(chave.toString()); string nameDisjuntor = "Disjuntor" + elementosManobra.listOfChaves[indexChave].getDisjuntorCode(); int indexDisjuntor = elementosManobra.findDisjuntorIndexByName(nameDisjuntor); bool disjuntorStatus = elementosManobra.listOfDisjuntores[indexDisjuntor].getStatus(); bool result = false; if (disjuntorStatus) {//se o disjuntor estiver desligado result = true; } else { Stage1dController.decrementScore(5); Debug.Log("Desligue o Disjutor!"); } if (Stage1dController.isElementOfGoal(chave: chave)) { // verifica o elemento é parte do objetivo para poder ter pontuação if (result) { Stage1dController.incrementScore(10); } } return(result); }
public void onClick() { if (Stage1dController.mudarStatus(this)) { Debug.Log("PRESSED"); if (this.connected) { objAtual.GetComponentInChildren <Image>().sprite = sprites[1]; if (nome.Contains("Bypass")) { foreach (GameObject obj in this.connectionsBypass) { obj.GetComponentInChildren <Image>().sprite = sprites[3]; } } } else { objAtual.GetComponentInChildren <Image>().sprite = sprites[0]; if (nome.Contains("Bypass")) { foreach (GameObject obj in this.connectionsBypass) { obj.GetComponentInChildren <Image>().sprite = sprites[2]; } } } this.connected = !this.connected; } }
private static bool isElementOfGoal(Chave chave = null, Disjuntor disjuntor = null) { if (chave == null && disjuntor == null) { return(false); } else { Chave[] chavesList = Stage1dController.returnChavesObjective(); Disjuntor[] disjuntoresList = Stage1dController.returnDisjuntoresObjective(); bool result = true; if (chave != null) { foreach (Chave c in chavesList) { result = (chave.getCodigo() == c.getCodigo()) ? true : false; if (result) { break; } } } else if (disjuntor != null) { foreach (Disjuntor d in disjuntoresList) { result = (disjuntor.getCodigo() == d.getCodigo()) ? true : false; if (result) { break; } } } return(result); } }
static bool verificarDisjuntor(int indexDisjuntor) { Disjuntor disjuntor = elementosManobra.listOfDisjuntores[indexDisjuntor]; bool disjuntorStatus = disjuntor.getStatus(); bool hasBypass = elementosManobra.listOfDisjuntores[indexDisjuntor].getIsHasBypass(); bool bypassStatus = false; if (hasBypass) { string nameBypass = "******" + elementosManobra.listOfDisjuntores[indexDisjuntor].getBypassCode(); int indexBypass = elementosManobra.findBypassIndexByName(nameBypass); bypassStatus = elementosManobra.listOfBypass[indexBypass].getStatus(); } string nameKey1 = "Chave" + elementosManobra.listOfDisjuntores[indexDisjuntor].getKeycode1(); int indexChave1 = elementosManobra.findChaveIndexByName(nameKey1); bool chave1Status = elementosManobra.listOfChaves[indexChave1].getStatus(); bool result = false; // verifica se é disjuntor que so tem uma chave ou disjuntor que tem 2 chaves if (elementosManobra.listOfDisjuntores[indexDisjuntor].getIsDoubleKey()) { string nameKey2 = "Chave" + elementosManobra.listOfDisjuntores[indexDisjuntor].getKeycode2(); int indexChave2 = elementosManobra.findChaveIndexByName(nameKey2); bool chave2Status = elementosManobra.listOfChaves[indexChave2].getStatus(); if ((!disjuntorStatus) || //se disjuntor estiver desligado (disjuntorStatus && !chave1Status && !chave2Status)) { //se as chaves estiverem desligadas e o disjuntor estiver ligado result = true; if (Stage1dController.isElementOfGoal(disjuntor: disjuntor)) { // verifica o elemento é parte do objetivo para poder ter pontuação Debug.Log(disjuntor.toString()); Stage1dController.incrementScore(10); } } else { Stage1dController.decrementScore(5); Debug.Log("Desligue as Chaves!"); } } // So tem uma chave else { if ((!disjuntorStatus) || //se disjuntor estiver desligado (disjuntorStatus && !chave1Status)) { //se a chave estiver desligada e o disjuntor estiver ligado result = true; if (Stage1dController.isElementOfGoal(disjuntor: disjuntor)) { // verifica o elemento é parte do objetivo para poder ter pontuação Debug.Log("este elemento pertence ao GOAL 2"); Stage1dController.incrementScore(10); } } else { Stage1dController.decrementScore(5); Debug.Log("Desligue a Chave!"); } } if (hasBypass) { if (bypassStatus && !disjuntorStatus) { Stage1dController.decrementScore(5); Debug.Log("Feche o Bypass !"); result = false; } else { //Stage1dController.incrementScore(10); } } return(result); }