First we add 2 new properties and a new constructor:
private readonly IGameListener listener;
private IGameState stateStrategy;
public Game(IGameListener listener)
{
this.listener = listener;
this.stateStrategy = Disconnected.Instance;
}
Next we go into Login.cs and modify our Start function to say:
_engine = new Game(this);
Now we can add some error handling to our Game.cs file:
public void OnUnexpectedEventReceive(EventCode eventCode, Hashtable eventData)
{
this.listener.LogError(this, string.Format("unexpected event {0}", eventCode));
}
public void OnUnexpectedOperationError(OperationCode operationCode, ErrorCode errorCode, string debugMessage, Hashtable hashtable)
{
this.listener.LogError(this, string.Format("unexpected operation error {0} from operation {1} in state {2}", errorCode, operationCode, this.stateStrategy.State));
}
public void OnUnexpectedPhotonReturn(int photonReturnCode, OperationCode operationCode, Hashtable hashtable)
{
this.listener.LogError(this, string.Format("unexpected return {0}", photonReturnCode));
}
This gets us all caught up to where we need to be so we can begin to implement our states. We will cover our basic disconnected state and the functions in Game.cs that we need to modify in our next segment. After we get our states set up I will be posting the code to github so that you can follow along if needed.
No comments:
Post a Comment