public void timerUsersInZone_Tick() //игра { for (int i = 0; i < model.ListUsers.Count; i++) { if (model.ListUsers[i] != null) { if (Math.Sqrt(Math.Pow(model.ListUsers[i].userLocation.X - model.Map.NextZone.ZoneCenterCoordinates.X, 2) + Math.Pow(model.ListUsers[i].userLocation.Y - model.Map.NextZone.ZoneCenterCoordinates.Y, 2)) > model.Map.NextZone.ZoneRadius) { model.ListUsers[i].flagZone = true; } else { model.ListUsers[i].flagZone = false; } if (model.Map.PrevZone != null && Math.Sqrt(Math.Pow(model.ListUsers[i].userLocation.X - model.Map.PrevZone.ZoneCenterCoordinates.X, 2) + Math.Pow(model.ListUsers[i].userLocation.Y - model.Map.PrevZone.ZoneCenterCoordinates.Y, 2)) > model.Map.PrevZone.ZoneRadius) { model.ListUsers[i].hp -= model.DamageZone; if (model.ListUsers[i].hp <= 0) { SingalForDroping Signal = new SingalForDroping(); CTransfers.Writing(Signal, model.ListNs[i]); Thread.Sleep(500); //Чтобы вещи успевали дропнуться до удаления игрока PlayerDeath death = new PlayerDeath(); death.Killer = "ZONA"; CTransfers.Writing(death, model.ListNs[i]); foreach (GeneralInfo g in model.ListGInfo) { if (g.Name == model.ListUsers[i].Name) { g.Dies += 1; } } GetKillsInfo kill = new GetKillsInfo(); kill.kill.killer = "ZONA"; kill.kill.dead = model.ListUsers[i].Name; for (int k = 0; k < model.ListUsers.Count; k++) { if (model.ListUsers[k] != null) { CTransfers.Writing(kill, model.ListNs[k]); } } } } } } }
async public void Bullet(object tmpObject) { bool flagBreak = false; BulletInfo bulletInfo = (BulletInfo)tmpObject; double X = bulletInfo.location.X, Y = bulletInfo.location.Y; X += (15.0 / bulletInfo.speed) * bulletInfo.speedX; bulletInfo.location.X = (int)X; Y += (15.0 / bulletInfo.speed) * bulletInfo.speedY; bulletInfo.location.Y = (int)Y; for (int i = 0; i < bulletInfo.timeLife; i++) { X += bulletInfo.speedX; bulletInfo.location.X = (int)X; Y += bulletInfo.speedY; bulletInfo.location.Y = (int)Y; for (int j = 0; j < model.ListUsers.Count; j++) { if (model.ListUsers[j] != null && Math.Abs(model.ListUsers[j].userLocation.X - X) <= 9 && Math.Abs(model.ListUsers[j].userLocation.Y - Y) <= 9 && model.ListUsers[j].hp > 0) { byte[] popad = new byte[1]; popad[0] = 6; model.ListUsers[j].hp -= bulletInfo.damage; flagBreak = true; if (model.ListUsers[j].hp <= 0) { SingalForDroping Signal = new SingalForDroping(); CTransfers.Writing(Signal, model.ListNs[j]); await Task.Delay(600); foreach (GeneralInfo g in model.ListGInfo) { if (g.Name == model.ListUsers[j].Name) { g.Dies += 1; } if (g.Name == bulletInfo.owner) { g.Kills += 1; } } GetKillsInfo kill = new GetKillsInfo(); kill.kill.killer = bulletInfo.owner; kill.kill.dead = model.ListUsers[j].Name; for (int k = 0; k < model.ListUsers.Count; k++) { if (model.ListUsers[k] != null) { if (model.ListUsers[k].Name == bulletInfo.owner) { model.ListUsers[k].kills += 1; } CTransfers.Writing(kill, model.ListNs[k]); } } PlayerDeath pd = new PlayerDeath(); pd.Killer = bulletInfo.owner; CTransfers.Writing(pd, model.ListNs[j]); } break; } } try { if (model.Map.bordersForBullets[bulletInfo.location.X, bulletInfo.location.Y]) { flagBreak = true; } } catch { break; } if (flagBreak) { break; } Thread.Sleep(20); } lock (model.ListBullet) { model.ListBullet.TryTake(out bulletInfo); } }
public void Grenade(object tmpObject) { bool flagfly = false, stop = false; GrenadeInfo grena = (GrenadeInfo)tmpObject; double X = grena.location.X, Y = grena.location.Y; for (int i = 0; i < 250; i++) { grena.timeBoo--; if (grena.flagFly && !flagfly && !stop) { grena.flagFly = false; grena.location = new Point(userInfo.userLocation.X, userInfo.userLocation.Y); double interval = Math.Sqrt(Math.Pow(userInfo.mouseLocation.X - userInfo.userLocation.X, 2) + Math.Pow(userInfo.mouseLocation.Y - userInfo.userLocation.Y, 2)); double k = interval / 3; grena.speedX = (userInfo.mouseLocation.X - userInfo.userLocation.X) / k; grena.speedY = (userInfo.mouseLocation.Y - userInfo.userLocation.Y) / k; X = grena.location.X; Y = grena.location.Y; flagfly = true; } if (flagfly) { X += grena.speedX; grena.location.X = (int)X; Y += grena.speedY; grena.location.Y = (int)Y; if (grena.timeLife > 0) { grena.timeLife--; } else { flagfly = false; stop = true; } } else if (!stop) { grena.location = userInfo.userLocation; } Thread.Sleep(20); } for (int j = 0; j < model.ListUsers.Count; j++) { if (model.ListUsers[j] != null && Math.Abs(model.ListUsers[j].userLocation.X - X) <= 59 && Math.Abs(model.ListUsers[j].userLocation.Y - Y) <= 59 && model.ListUsers[j].hp > 0) { byte[] popad = new byte[1]; popad[0] = 6; model.ListUsers[j].hp -= grena.damage; if (model.ListUsers[j].hp <= 0) { SingalForDroping Signal = new SingalForDroping(); CTransfers.Writing(Signal, model.ListNs[j]); Thread.Sleep(500); //Чтобы вещи успевали дропнуться до удаления игрока foreach (GeneralInfo g in model.ListGInfo) { if (g.Name == model.ListUsers[j].Name) { g.Dies += 1; } if (g.Name == grena.owner) { g.Kills += 1; } } GetKillsInfo kill = new GetKillsInfo(); kill.kill.killer = grena.owner; kill.kill.dead = model.ListUsers[j].Name; for (int k = 0; k < model.ListUsers.Count; k++) { if (model.ListUsers[k] != null) { if (model.ListUsers[k].Name == grena.owner) { model.ListUsers[k].kills += 1; } CTransfers.Writing(kill, model.ListNs[k]); } } PlayerDeath pd = new PlayerDeath(); pd.Killer = grena.owner; CTransfers.Writing(pd, model.ListNs[j]); } } } Thread.Sleep(700); model.ListGrenade.TryTake(out grena); }