public override void Start() { EventManager.PatrolSwitchChange += SwitchDiection; this.data = this.gameobject.GetComponent <PatrolData>(); this.direction = (targetSide)Random.Range(0, 4); this.target = this.getTarget(this.direction); }
private Vector2 getTarget(targetSide dirction) { Vector2 target = new Vector2(0, 0); switch (direction) { case targetSide.W: target.x = Random.Range(data.Area_min_x - 0.2f, data.Area_max_x + 0.2f); target.y = data.Area_max_y + 0.3f; break; case targetSide.A: target.x = data.Area_min_x - 0.2f; target.y = Random.Range(data.Area_min_y - 0.2f, data.Area_max_y + 0.2f); break; case targetSide.S: target.x = Random.Range(data.Area_min_x - 0.2f, data.Area_max_x + 0.2f); target.y = data.Area_min_y - 0.2f; break; case targetSide.D: target.x = data.Area_max_x + 0.2f; target.y = Random.Range(data.Area_min_y - 0.2f, data.Area_max_y + 0.2f); break; } return(target); }
public void SwitchDiection(int id) { if (data.ID == id) { if (direction == targetSide.A) { direction = targetSide.W; } else { direction += 1; } target = getTarget(direction); } }
var(targetSide, rotationType) = command;