private void ProcessMessageHandler(IPackage package) { client = Owner as IGameClient; switch (package.MesseggeType) { case MesseggeType.Map: { //if (st_g) count++; //if(stopWatch.Elapsed.Seconds == 10) //{ // //тут ставь точку и смотри count // stopWatch.Stop(); //} Map = package.Data as IMap; if (First_Map) { _Entity = Map.Tanks.First(i => i.Tank_ID == client.Passport); First_Map = false; MaxHealthPoints = _Map.Tanks.ElementAt(0).HelthPoints; } break; } case MesseggeType.RoomList: { RoomsStat = (package.Data as IRoomsStat).RoomsStat; break; } case MesseggeType.Passport: { IinitialConectionData initConnData = package.Data as IinitialConectionData; client.Passport = initConnData.passport; client.AddAddressee("Host", initConnData.manageRoomEndpoint); break; } case MesseggeType.RoomInfo: { var roomInfo = package.Data as RoomInfo; client.AddAddressee("Room", roomInfo.roomEndpoint as IAddresssee); Map_size = roomInfo.mapSize; break; } case MesseggeType.TankDeath: { var tank = package.Data as ITank; if (tank.Tank_ID == client.Passport) { //StopGame(); onDeath?.BeginInvoke(this, new ErrorData(), null, null); } OnTankDeath?.BeginInvoke(this, new DestroyableTank() { tankToDestroy = tank }, null, null); break; } case MesseggeType.StartGame: { //st_g = true; //stopWatch.Start(); _ifReadyToSendEntity.Set(); _timerCancelator = _CancelationSource.Token; _timer = new Timer(SendByTimerCallback, _timerCancelator, 0, timerSpeed); Thread.Sleep(500); onGameStart?.BeginInvoke(this, new ErrorData() { errorText = "" }, null, null); break; } case MesseggeType.EndGame: { //StopGame(); onEndGame?.BeginInvoke(this, new ErrorData() { errorText = (package.Data as ITank).Name }, null, null); break; } case MesseggeType.Error: { ErrorText = package.Data as string; break; } default: throw new Exception("Undefine MessaggeType"); } }