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 { Stage1bController.decrementScore(5); Debug.Log("Desligue o Disjutor!"); } if (Stage1bController.isElementOfGoal(chave: chave)) { // verifica o elemento é parte do objetivo para poder ter pontuação if (result) { Stage1bController.incrementScore(10); } } 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; } else { 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; } else { Debug.Log("Desligue a Chave!"); } } if (hasBypass) { if (bypassStatus && !disjuntorStatus) { Debug.Log("Feche o Bypass !"); result = false; } } if (Stage1bController.isElementOfGoal(disjuntor: disjuntor)) { // verifica o elemento é parte do objetivo para poder ter pontuação if (result) { Stage1bController.incrementScore(10); } else { Stage1bController.decrementScore(5); } } else { if (!result) { Stage1bController.decrementScore(5); } } return(result); }