public void Reflect(NetworkMessage.CellResult cr) { checkStatus = cr.status; ChangeTexture(); switch (checkStatus) { case Status.HIDDEN: MineCounterScript.instance.IncreaseMineNum(); break; case Status.CLICKED: { SetText(cr.surrounding.ToString()); text.gameObject.SetActive(true); if (cr.surrounding == 0) { text.gameObject.SetActive(false); } } break; case Status.FLAGGED: MineCounterScript.instance.DecreaseMineNum(); break; case Status.MINE: GridManager.instance.isLose = true; return; default: break; } }
public bool Clicked(ref NetworkMessage.Result result) //Try to reveal the cell and return whether it was valid click or not { if (checkStatus == Status.HIDDEN) { checkStatus = Status.CLICKED; if (surroundingArea == 0) { if (isMine) { //Game over Debug.Log("Game Over"); checkStatus = Status.MINE; } else { //Debug.Log("Area"); GridManager.instance.RevealAreaAt(index, ref result); } } NetworkMessage.CellResult cr = new NetworkMessage.CellResult(); cr.index = index; cr.status = checkStatus; cr.surrounding = surroundingArea; result.result.Add(cr); return(true); } return(false); }
public bool Flagged(ref NetworkMessage.Result result) //Try to put/remove falg on the cell and return whether it was valid click or not { //TODO mine number should be managed my grid manager if (checkStatus == Status.HIDDEN) { checkStatus = Status.FLAGGED; goto Clickable; } else if (checkStatus == Status.FLAGGED) { checkStatus = Status.HIDDEN; goto Clickable; } return(false); Clickable: NetworkMessage.CellResult cr = new NetworkMessage.CellResult(); cr.index = index; cr.status = checkStatus; result.result.Add(cr); return(true); }