// returns true if there is no startingCircle set public bool CanBeActivated(GameObject circle) { if (whoseTurn != myPlayerID) { return(false); } if (startingCircle == null) { startingCircle = circle; startingCircleScript = startingCircle.GetComponent <ActivateCircle>(); return(true); } else if (CheckNeighbour(circle)) { endingCircle = circle; endingCircleScript = endingCircle.GetComponent <ActivateCircle>(); endingCircleScript.Activate(); // activate neighbour circle biscuitWasMarked = false; float startingCircleY = startingCircle.transform.position.y; float startingCircleX = startingCircle.transform.position.x; float endingCircleY = endingCircle.transform.position.y; float endingCircleX = endingCircle.transform.position.x; try { //PlaceLine(); PlayerMoveMade(startingCircleX, startingCircleY, endingCircleX, endingCircleY); } catch (System.ArgumentException) { } catch (KeyNotFoundException) { } DeactivateCircles(); // set the circles to null startingCircle = null; endingCircle = null; return(false);// returns false so that the onMouseDown method from ActivateCircle of ending circle wont activate it(not low coupling, sorry :'( ) } else { return(false); } }
// returns true if there is no startingCircle set public bool CanBeActivated(GameObject circle) { if (startingCircle == null) { startingCircle = circle; startingCircleScript = startingCircle.GetComponent <ActivateCircle>(); return(true); } else if (CheckNeighbour(circle)) { endingCircle = circle; endingCircleScript = endingCircle.GetComponent <ActivateCircle>(); endingCircleScript.Activate(); // activate neighbour circle biscuitWasMarked = false; try { PlaceLine(); if (!biscuitWasMarked) { SwitchTurns(); } CheckForWin(); } catch (System.ArgumentException) { } catch (KeyNotFoundException) { } DeactivateCircles(); // set the circles to null startingCircle = null; endingCircle = null; return(false);// returns false so that the onMouseDown method from ActivateCircle of ending circle wont activate it(not low coupling, sorry :'( ) } else { return(false); } }