public void OnDeletedEntity(Safir.Dob.EntityProxy entityProxy, bool deprecated) { if (entityProxy.TypeId == Consoden.TankGame.GameState.ClassTypeId && entityProxy.InstanceId == currentGameId) { if (myJoystickId != null) { connection.Delete (new EntityId (Consoden.TankGame.Joystick.ClassTypeId, myJoystickId), myHandlerId); } logic = null; myJoystickId = null; currentGameId = null; myTankId = -1; } }
public void OnDeleteRequest(Safir.Dob.EntityRequestProxy entityRequestProxy, Safir.Dob.ResponseSender responseSender) { responseSender.Send (Safir.Dob.ErrorResponse.CreateErrorResponse (Safir.Dob.ResponseGeneralErrorCodes.SafirNoPermission, "")); }
public void OnRevokedRegistration(long typeId, Safir.Dob.Typesystem.HandlerId handlerId) { System.Console.WriteLine("Revoked by handler "+handlerId.ToString()); }
public void OnUpdatedEntity(Safir.Dob.EntityProxy entityProxy) { if (entityProxy.TypeId == Consoden.TankGame.GameState.ClassTypeId && entityProxy.InstanceId == currentGameId && logic!=null) { Consoden.TankGame.GameState gs = (Consoden.TankGame.GameState)entityProxy.Entity; if (gs.Winner.Val == Consoden.TankGame.Winner.Enumeration.Unknown) { try { logic.MakeMove((Consoden.TankGame.GameState)entityProxy.Entity); } catch { Console.WriteLine("Caught unhandled exception in TankLogic!"); } } } }
public void OnNewEntity(Safir.Dob.EntityProxy entityProxy) { Consoden.TankGame.GameState gameState = entityProxy.Entity as Consoden.TankGame.GameState; if (gameState == null) { return; } for (int i=0; i<gameState.Tanks.Count; i++) { if (!gameState.Tanks [i].IsNull ()) { Consoden.TankGame.Tank tank = gameState.Tanks [i].Obj; if (tank.PlayerId.Val == myPlayerId) { currentGameId = entityProxy.InstanceId; myTankId = tank.TankId.Val; myJoystickId = InstanceId.GenerateRandom (); Consoden.TankGame.Joystick joystick = new Consoden.TankGame.Joystick (); joystickCounter = 0; joystick.PlayerId.Val = myPlayerId; joystick.GameId.Val = currentGameId; joystick.TankId.Val = myTankId; joystick.Counter.Val = joystickCounter++; connection.SetAll (joystick, myJoystickId, myHandlerId); logic = new TankLogic (myTankId, UpdateJoystick); break; } } } }