public void Execute(RobotSM robot) { if (Time.time - tstart > 4.5f) { robot.changeState(new WalkToDisposer()); } }
public void Execute(RobotSM robot) { Vector3 pos = robot.transform.position; Vector3 dir = ptrash - pos; if (dir.magnitude < 0.1f) { GameObject[] copler = GameObject.FindGameObjectsWithTag("waste"); for (int i = 0; i < copler.Length; i++) { if ((copler[i].transform.position - robot.transform.position).magnitude < 0.1f) { int px = Random.Range(0, robot.getSize() - 1); int py = Random.Range(0, robot.getSize() - 1); GameObject.Instantiate( copler[i], new Vector3(px, 0, py), Quaternion.identity); GameObject.Destroy(copler[i]); break; } } robot.changeState(new Pickup()); } dir.Normalize(); robot.transform.LookAt(ptrash); robot.transform.position += dir * Time.deltaTime; }
public void Execute(RobotSM robot) { if (Time.time - tstart > 4.5f) { robot.changeState(new Search()); } }
public void Execute(RobotSM robot) { Vector3 dir = disp - robot.transform.position; if (dir.magnitude < 0.1f) { robot.changeState(new Disposing()); return; } dir.Normalize(); robot.transform.LookAt(disp); robot.transform.position += dir * Time.deltaTime; }
public void Enter(RobotSM robot) { Vector3 minv = Vector3.zero; float minf = float.MaxValue; GameObject[] copler = GameObject.FindGameObjectsWithTag("waste"); for (int i = 0; i < copler.Length; i++) { float d = (copler[i].transform.position - robot.transform.position).magnitude; if (d < minf) { minv = copler[i].transform.position; minf = d; } } robot.changeState(new WalkToTrash(minv)); }