protected void onDiskDown(IntVector2 pos) { int id = RackUtil.checkWin(); if (id > 0) { playerWon(id); } else { if (pos == GameUtil.currentSpecial) { //activateDelete(); if (GameUtil.onTurn) { GameUtil.special1 = Random.Range(1, 4); } else { GameUtil.special2 = Random.Range(1, 4); } GameUtil.playOneShot("SpecialPickUp"); rack.createSpecial(newSpecialLocation()); } GameUtil.onTurn = !GameUtil.onTurn; rack.showDiskSelector(); } }
protected void onDiskDown(IntVector2 pos) { int id = RackUtil.checkWin(); if (id > 0) { playerWon(id); } else { if (pos == GameUtil.currentSpecial) { //activateDelete(); if (GameUtil.onTurn) { GameUtil.special1 = UnityEngine.Random.Range(1, 4); } else { GameUtil.special2 = UnityEngine.Random.Range(1, 4); } GameUtil.playOneShot("SpecialPickUp"); IntVector2 v = newSpecialLocation(); NetworkManager.postNewSpecial(v.x, v.y); rack.createSpecial(v); } } }
IEnumerator RotateRack(Vector3 angle, float inTime) { var fromAngle = container.transform.rotation; var toAngle = Quaternion.Euler(angle); RackUtil.shiftRackToLeft(); for (var t = 0f; t < 1; t += Time.deltaTime / inTime) { container.transform.rotation = Quaternion.Lerp(fromAngle, toAngle, t); for (int i = 0; i < RackUtil.SIZE; i++) { for (int j = 0; j < RackUtil.SIZE; j++) { if (RackUtil.myRack [i] [j].id != 0) { updateRackItemBy(i, j, t); } } } yield return(null); } container.transform.rotation = Quaternion.Euler(angle); //Rotates the array 90 degrees RackUtil.transposeRack(); RackUtil.flipRackColumns(); normalizePositionsAfterRotation(); GameUtil.isAnimating = false; RackRotatedCallback(); }
//Called after rack's animation finishes protected void rackRotated() { rack.createSpecial(newSpecialLocation()); int id = RackUtil.checkWin(); if (id > 0) { playerWon(id); } }
public void opponentDropDisk(int column) { if (!RackUtil.isColumnFull(column)) { rack.hideSelector(); GameUtil.onTurn = false; var pos = rack.dropDisk(column); onDiskDown(pos); } }
protected void dropDisk() { var column = (GameUtil.mousePosition().x + 30) / 10; if (!RackUtil.isColumnFull(column)) { rack.hideSelector(); var pos = rack.dropDisk(column); onDiskDown(pos); } }
public void deleteAllDisks() { for (int i = 0; i < RackUtil.SIZE; i++) { for (int j = 0; j < RackUtil.SIZE; j++) { var disk = RackUtil.myRack [i] [j].disk; RackUtil.deleteDisk(i, j); Destroy(disk); } } }
public void deleteColumn(int column) { GameUtil.isAnimating = true; for (int i = 0; i < RackUtil.SIZE; i++) { var disk = RackUtil.myRack [i] [column].disk; RackUtil.deleteDisk(i, column); Destroy(disk); } StartCoroutine(ColumnDeleteTask()); GameUtil.playOneShot("Special activate"); }
protected void dropDisk() { var column = (GameUtil.mousePosition().x + 30) / 10; if (!RackUtil.isColumnFull(column)) { rack.hideSelector(); var pos = rack.dropDisk(column); onDiskDown(pos); GameUtil.onTurn = false; NetworkManager.postDropDisk(column, true); } }
//Called after rack's animation finishes protected void rackRotated() { IntVector2 v = newSpecialLocation(); NetworkManager.postNewSpecial(v.x, v.y); rack.createSpecial(v); int id = RackUtil.checkWin(); if (id > 0) { playerWon(id); } }
public void deleteRow(int row) { for (int i = 0; i < RackUtil.SIZE; i++) { var disk = RackUtil.myRack [row] [i].disk; RackUtil.deleteDisk(row, i); Destroy(disk); } GameUtil.isAnimating = true; StartCoroutine(RowDeleteTask(row, 0.5f)); GameUtil.playOneShot("InGameSound"); GameUtil.playOneShot("Special activate"); }
public IntVector2 dropDisk(int column) { var clone = GameObject.Instantiate(prefab); clone.transform.SetParent(container.transform); clone.transform.localPosition = new Vector2(column * 10 - 30, 41); clone.GetComponent <SpriteRenderer> ().color = GameUtil.onTurn?Color.red:Color.yellow; var id = GameUtil.onTurn ? 1 : 2; var coordinates = RackUtil.registerDisk(column, id, clone); GameUtil.isAnimating = true; StartCoroutine(updateRackItem(coordinates.x, coordinates.y)); GameUtil.playOneShot("InGameSound"); return(coordinates); }
// Use this for initialization void Start() { RackUtil.initRacks(); rack = MyRack.getInstance(); GameUtil.specialButton = GameObject.Find("SpecialButton"); GameUtil.resetButton = GameObject.Find("ResetButton"); //Handling delegates rack.DiskDroppedCallback += diskDropped; rack.RackRotatedCallback += rackRotated; rack.ColumnDeletedCallback += columnDeleted; rack.RowDeletedCallback += rowDeleted; GameUtil.setResetHandler(resetPressed); GameUtil.setSpecialHandler(specialPressed); setupGame(); }
IEnumerator RowDeleteTask(int row, float inTime) { RackUtil.shiftRackDown(); for (var t = 0f; t < 1; t += Time.deltaTime / inTime) { for (int i = 0; i < RackUtil.SIZE; i++) { for (int j = 0; j < RackUtil.SIZE; j++) { if (RackUtil.myRack [i] [j].id != 0) { updateRackItemBy(i, j, t); } } } yield return(null); } RowDeletedCallback(row); }