public override void Update(ControllableObject actor) { if (!(actor is Unit)) //this ain't a unit! ...it can't move! return; if (!initialized) { //get a path if i haven't already path = Scenario.Map.GetPath(new Point((int)actor.Position.X, (int)actor.Position.Y), destination, new Point(actor.Width, actor.Height)); destination = path.Pop(); initialized = true; } if (actor.Position != destination.Vector) { //i am headed to a point in my path actor.Position = Global.MoveLinearly(actor.Position, 40, destination.Vector); } else if (actor.Position == destination.Vector && path.Count > 0) { //i have reached a point in my path, but have more points to go; head to next point destination = path.Pop(); } else if (actor.Position == destination.Vector && path.Count == 0) { //i am done moving Finished = true; } }
public void RemoveObject(ControllableObject co) { MyStuff.Remove(co); }
public void AddObject(ControllableObject co) { MyStuff.Add(co); }
public FollowTask(ControllableObject target) { this.Target = target; }
//a task tells a unit what to do public virtual void Update(ControllableObject actor) { }