public static bool othergotoNewCell(GameObject newCell, int ida) { ClicCell c; if (ida == 1) { c = otherplayer1.Cells.GetComponent <ClicCell>(); } else { c = otherplayer2.Cells.GetComponent <ClicCell>(); } var c2 = newCell.GetComponent <ClicCell>(); //Debug.Log("c : " + c); //Debug.Log("c2.crosable : " + c2.crosable); //Debug.Log("ida : " + ida); int dist = ClicCell.distanceCells(c, c2); // Debug.Log("dist : " + dist); if (otherplayer1.curPM >= dist && ida == 1 && c2.crosable) { OtherPlayerControler.setTransform(otherplayer1, newCell, dist); reachGlobalUpdate(CellsTab); return(true); } if (otherplayer2.curPM >= dist && ida == 2 && c2.crosable) { OtherPlayerControler.setTransform(otherplayer2, newCell, dist); reachGlobalUpdate(CellsTab); return(true); } return(false); }
public static int distanceCells(ClicCell cell1, ClicCell cell2) { int dist = 0; dist = Mathf.Abs(cell2.getX() - cell1.getX()) + Mathf.Abs(cell2.getY() - cell1.getY()); return(dist); }
public static bool canGotoNewCell(GameObject newCell) { if (Selected._curentCursorState == Selected.CursorState.MOVE) { var c = player.Cells.GetComponent <ClicCell>(); var c2 = newCell.GetComponent <ClicCell>(); int dist = ClicCell.distanceCells(c, c2); if (player.curPM >= dist) { return(true); } else { return(false); } } else if (Selected._curentCursorState == Selected.CursorState.SHOOT) { var c = player.Cells.GetComponent <ClicCell>(); var c2 = newCell.GetComponent <ClicCell>(); int dist = ClicCell.distanceCells(c, c2); if (player.CurWeapon.range >= dist) { return(true); } else { return(false); } } else { var c = player.Cells.GetComponent <ClicCell>(); var c2 = newCell.GetComponent <ClicCell>(); int dist = ClicCell.distanceCells(c, c2); if (player.CurSpell.range >= dist) { return(true); } else { return(false); } } }
public static void reachGlobalUpdate(GameObject[][] tab) { for (int i = 0; i < tab.Length; i++) { for (int j = 0; j < tab[i].Length; j++) { var tempcc = tab[i][j].GetComponent <ClicCell>(); if (Selected._curentCursorState == Selected.CursorState.MOVE) { //print (tempcc); //print (player.curPM); //print (player.Cells.GetComponent<ClicCell>()); if (player != null && player.Cells != null && ClicCell.distanceCells(tempcc, player.Cells.GetComponent <ClicCell>()) <= player.curPM) { tempcc.reachable = true; } else { tempcc.reachable = false; } } else if (Selected._curentCursorState == Selected.CursorState.SHOOT) { if (ClicCell.distanceCells(tempcc, player.Cells.GetComponent <ClicCell>()) <= player.CurWeapon.range) { tempcc.reachable = true; } else { tempcc.reachable = false; } } else if (Selected._curentCursorState == Selected.CursorState.CAST) { if (ClicCell.distanceCells(tempcc, player.Cells.GetComponent <ClicCell>()) <= player.CurSpell.range) { tempcc.reachable = true; } else { tempcc.reachable = false; } } tempcc.askedUpdate = true; } } }
public static void gotoNewCell(GameObject newCell) { var c = player.Cells.GetComponent <ClicCell>(); var c2 = newCell.GetComponent <ClicCell>(); int dist = ClicCell.distanceCells(c, c2); if (player.curPM >= dist) { if (c2.reachable && !c2.playerOnIt) { playerControler.setTransform(player, newCell, dist); reachGlobalUpdate(CellsTab); } } }
public static bool mechantEstARange(int ida) { ClicCell c; ClicCell c2; if (ida == 2) { c = otherplayer1.Cells.GetComponent <ClicCell>(); c2 = otherplayer2.Cells.GetComponent <ClicCell>(); } else { c2 = otherplayer1.Cells.GetComponent <ClicCell>(); c = otherplayer2.Cells.GetComponent <ClicCell>(); } int dist = ClicCell.distanceCells(c, c2); return(dist < otherplayer2.CurWeapon.range); }
public bool canShoot(ClicCell c1, ClicCell c2) { return(ClicCell.distanceCells(c1, c2) <= Po); }