private bool tryTransmission(PlugEnds attemptedPlugCoordinates) { foreach (CallRequest curRequest in requestEnds) { if (curRequest.getSolution().Equals(attemptedPlugCoordinates)) { requestEnds.Remove(curRequest); var waitTime = curRequest.CompleteCall(); print("Well done."); score += Mathf.FloorToInt(10f + 50 * waitTime); scoreText.text = "Score: " + score; CreatePlugGoal(); StartCoroutine(removeBothPlugs()); Debug.Log(score); } else { var startString = (startPlug != null) ? startPlug.GetComponent <Plug>().ToString() : "null"; var endString = (endPlug != null) ? endPlug.GetComponent <Plug>().ToString() : "null"; print("You silly goose, look what you've done! You've connected " + startString + " and " + endString); bad_thing_happened.gameObject.SetActive(true); bad_thing_happened.DisplayFuckup(attemptedPlugCoordinates, curRequest.getSolution(), colSyms, rowSyms); GameOver("You made a bad connection. Jimmy ended up calling his ex and now things are awkward."); } // to do: remove curPlugCoordinate, kill the CallRequest UI element. // and play a ding ding sound } return(false); }
/* * Validate a plugging attempt. If this is valid, we need to let the world know that someone succeeded. * If it is not valid, do nothing. */ private bool isValidTransmission(PlugEnds attemptedPlugCoordinates) { foreach (PlugEnds curPlugCoordinate in requestEnds) { if (curPlugCoordinate.Equals(attemptedPlugCoordinates)) { return(true); } } return(false); }
private void CreatePlugGoal() { var goalPlug = new PlugEnds(); print("Okay, now connect " + goalPlug.first.CoordString() + " to " + goalPlug.second.CoordString()); GameObject newCallPanel = Instantiate(callPanelPrefab, commandPanel.transform); CallRequest call = newCallPanel.GetComponent <CallRequest>(); call.StartRequest(goalPlug, colSyms, rowSyms, 20f); requestEnds.Add(call); }
public void StartRequest(PlugEnds answer, char[] colNames, char[] rowNames, float patience) { colCipher = colNames; rowCipher = rowNames; solution = answer; tCol1.text = colCipher[solution.first.x].ToString(); tRow1.text = rowCipher[solution.first.y].ToString(); tCol2.text = colCipher[solution.second.x].ToString(); tRow2.text = rowCipher[solution.second.y].ToString(); countdownStartTime = Time.time; waitTime = patience; waitSlider.value = 1f; }
public void DisplayFuckup(PlugEnds answer, PlugEnds solution, char[] cols, char[] rows) { colCipher = cols; rowCipher = rows; tried = answer; meant = solution; a_col1.text = cols[answer.first.x].ToString(); a_row1.text = rows[answer.first.y].ToString(); a_col2.text = cols[answer.second.x].ToString(); a_row2.text = rows[answer.second.y].ToString(); b_col1.text = cols[solution.first.x].ToString(); b_row1.text = rows[solution.first.y].ToString(); b_col2.text = cols[solution.second.x].ToString(); b_row2.text = rows[solution.second.y].ToString(); }