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; } } } }