As a learning progression for JAVA inheritance I have put together a scheduler class and actor class. The scheduler class creates a list of actor objects and progresses through them calling on the actor to act().
Now my first instinct for the actor class is to pass the player actor a reference to the Scheduler so that the player can pause the scheduler when his/her turn arrives.
So within the scheduler, I have a reference to the current actor and can do the following..
actor.act( this );
this being the scheduler.
Now within the player class I can declare act as follows...
@Override
public int act( Scheduler queue )
{
//need to pause scheduler here and wait for player to act
queue.lock();
//wait for action from player
if (this.playerActionComplete)
{
queue.unlock();
}
}
Is this the right OOP approach? I've already got weird stuff happening and wondering if I should persevere with this approach.
Cheers!