public Command getRandomCommand(GameObject unit) { unit_behaviour script = unit.GetComponent <unit_behaviour>(); int nbSteps = Random.Range(0, script.lengthOfMovement - 1); int directionOfMov; if (script.diagonal) { directionOfMov = Random.Range(4, 8); } else { directionOfMov = Random.Range(0, 4); } return(new Command(nbSteps, script.id, (Command.Direction)directionOfMov, (Command.Direction)Random.Range(0, 8))); }
void SelectUnit() { RaycastHit whatdIHit; Ray selectionLaser = mainCamera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(selectionLaser, out whatdIHit)) { if (whatdIHit.collider.gameObject.CompareTag("Unit")) { Debug.Log("wwwwwwww"); if (selectedUnit) { selectedUnit.ToggleGrid(false); } selectedUnit = whatdIHit.collider.GetComponent <unit_behaviour>(); selectedUnit.ToggleGrid(true); } } }