public override Finite.Mode act(Finite collection) { if (path.Count == 0) { collection.set_next("idle"); return(Finite.Mode.Next); } var from = Context.transform.position; var to = room.grid_to_world(path.Peek(), true) - Context.transform.position; var angle = Vector3.SignedAngle(from.normalized, to.normalized, Vector3.up); rb.rotation = Quaternion.Euler(0.0f, angle + 45.0f, 0.0f); to.Normalize(); to.y = 0; to *= 3.0f * Time.deltaTime; rb.MovePosition(rb.position + to); draw_rect(room.grid_to_world(path.Peek(), true), 1.0f, Color.yellow); if (Vector3.Distance(rb.position, room.grid_to_world(path.Peek(), true)) < 0.15f) { path.Pop(); } foreach (var value in debug) { draw_rect(room.grid_to_world(value, true), 1.0f, Color.blue); } return(mode); }
public override void decide(Finite collection) { if (!is_reachable) { collection.set_next("Idle"); mode = Finite.Mode.Next; } }
public override void decide(Finite collection) { if (in_range) { Next = "Chase"; collection.set_next(Next); mode = Finite.Mode.Next; } }
public override Finite.Mode update(Finite collection) { sense_timer -= Time.deltaTime; decide_timer -= Time.deltaTime; if (sense_timer < 0) { sense(); sense_timer = sense_interval; } if (decide_timer < 0) { decide(collection); decide_timer = decide_interval; } return(act(collection)); }
public abstract void decide(Finite collection);
public abstract Finite.Mode act(Finite collection);
public override Finite.Mode update(Finite collection) { return(Finite.Mode.Run); }
public Machine(IState state) { collection = new Finite(state); }
public override void enter(Finite collection) { mode = Finite.Mode.Run; }
public override void exit(Finite collection) { }
public abstract void enter(Finite collection);
public abstract void exit(Finite collection);
public override void exit(Finite collection) { damage.unregister(this); }
public override void enter(Finite collection) { damage.register(this); mode = Finite.Mode.Run; }
public override Finite.Mode update(Finite collection) { Debug.Log("Entry"); collection.set_next(Next); return(Finite.Mode.Next); }
public override void exit(Finite collection) { Debug.Log("Entry Exit"); }
public override void enter(Finite collection) { Debug.Log("Entry Enter"); }
public abstract Mode update(Finite collection);
public override Finite.Mode act(Finite collection) { return(mode); }
public Machine(string name, IState state) { collection = new Finite(name, state); collection.current.enter(collection); }
public override void enter(Finite collection) { }