public Stage1Model() { this.chave01 = new Chave(false, "1", "1"); this.chave02 = new Chave(false, "2", "2"); this.chave03 = new Chave(false, "3", "3"); this.chave04 = new Chave(false, "4", "3"); this.chave05 = new Chave(false, "5", "4"); this.chave06 = new Chave(false, "6", "4"); this.chave07 = new Chave(false, "7", "1"); this.chave08 = new Chave(false, "8", "2"); this.disjuntor01 = new Disjuntor(false, "1", "1", "7", "1"); this.disjuntor02 = new Disjuntor(false, "2", "2", "8", "2"); this.disjuntor03 = new Disjuntor(false, "3", "3", "4", "3"); this.disjuntor04 = new Disjuntor(false, "4", "5", "6", "4"); this.bypass01 = new Bypass(true, "1", "1"); this.bypass02 = new Bypass(true, "2", "2"); this.bypass03 = new Bypass(true, "3", "3"); this.bypass04 = new Bypass(true, "4", "4"); this.listOfChaves = createListOfChaves(); this.listOfDisjuntores = createListOfDisjuntores(); this.listOfBypass = createListOfBypass(); }
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); }