public void ChangeGUI() { for (int i = 0; i < _width; i++) { for (int j = 0; j < _height; j++) { KVelement temp = _grid.GetObjFromCoordinate(new Vector2Int(i, j)).GetComponent <KVelement>(); if (temp != null) { if (!GUIManager.guiState) { temp.text.text = temp.setting.ToString(); } else { temp.text.text = temp.charge.ToString(); } } } } if (GUIManager.guiState) { GUIManager.guiState = false; } else { GUIManager.guiState = true; } }
private int GetHits(BooleanTerm boolTerm) { int hits = 0; bool foundOs = false; for (int i = 0; i < _width; i++) { for (int j = 0; j < _height; j++) { KVelement temp = _grid.GetObjFromCoordinate(new Vector2Int(i, j)).GetComponent <KVelement>(); if (temp) { if (!temp.highlighted) { if (temp.Highlight(boolTerm.charges.x, boolTerm.charges.y) == 1) { hits++; } if (temp.Highlight(boolTerm.charges.x, boolTerm.charges.y) == 0) { foundOs = true; } } } } } if (!foundOs) { return(hits); } else { return(-1); } }
private void ResetBoard() { for (int i = 0; i < _width; i++) { for (int j = 0; j < _height; j++) { KVelement temp = _grid.GetObjFromCoordinate(new Vector2Int(i, j)).GetComponent <KVelement>(); if (temp) { temp.ResetHighlight(); } } } }
//////////////////////////////////////////////////////////////////////////////////////////// // Harvest Bool Input-Behaviour Methods public void SetElement(InputAction.CallbackContext context) { Ray ray = _camera.go.GetComponent <Camera>().ScreenPointToRay(Mouse.current.position.ReadValue()); RaycastHit hit; Physics.Raycast(ray, out hit); Vector2Int temp = _mainGrid.grid.GetCoordinate(hit.point); KVelement selection = hit.collider.gameObject.GetComponent <KVelement>(); UIClickable tempClickable = hit.collider.gameObject.GetComponent <UIClickable>(); if (temp.x >= 0) { if (selection != null) { AudioManager.instance.PlaySound(clips[1]); selection.SetSetting(); } } }
public void Solve() { if (!_stageOneFinished) { bool result = true; for (int i = 0; i < _width; i++) { for (int j = 0; j < _height; j++) { KVelement temp = _grid.GetObjFromCoordinate(new Vector2Int(i, j)).GetComponent <KVelement>(); if (temp != null) { if (_expectedResults.valueArray[temp.charge] != temp.setting) { result = false; } } } } if (result) { _booleanTerms.booleanTerms = new List <BooleanTerm>(); UITableFiller.FillTable(_stageOnePanel, _booleanTerms.booleanTerms); _stageTwoPanel.SetActive(true); _stageOneFinished = true; ChangeGUI(); InputHandler.instance.ChangeGIT(GameInputType.None); } } else { if (IsDMF()) { GameStateHandler.SetGameState(_rewardSO.value); AudioManager.instance.PlaySound(_clips[0]); _winPanel.SetActive(true); } else { AudioManager.instance.PlaySound(_clips[1]); } } }
public void Highlight(int intToAdd) { ResetBoard(); if (intToAdd > 0) { if ((intToAdd & _currentSelectionPositive) == 0) { _currentSelectionPositive += intToAdd; } else { _currentSelectionPositive -= intToAdd; } } else { if ((intToAdd * -1 & _currentSelectionNegative) == 0) { _currentSelectionNegative += intToAdd * -1; } else { _currentSelectionNegative -= intToAdd * -1; } } for (int i = 0; i < _width; i++) { for (int j = 0; j < _height; j++) { GameObject tempHighlight = _grid.GetObjFromCoordinate(new Vector2Int(i, j)); KVelement currentElement = tempHighlight.GetComponent <KVelement>(); if (currentElement != null) { currentElement.Highlight(_currentSelectionPositive, _currentSelectionNegative); } } } SetText(); }