public ArenaStatus GenerateReport() { var report = new ArenaStatus(this.food == null ? null : new XY(this.food.x, this.food.y)); foreach (var snake in snakes) { if (snake.Value == null) { continue; } else if (!snake.Value.IsActive) { report.AddDisabledSnake(snake.Key); } else { var head = snake.Value.Head().ConvertToXY(); var tail = snake.Value.Tail?.ConvertToXY(); var color = snake.Value.GetColorString(); var tempSnake = new JsonLibrary.Snake(snake.Key, color, head, tail); report.AddActiveSnake(tempSnake); } } return(report); }
private void OnTimedUpdate(object source, System.Timers.ElapsedEventArgs e) { // update new status arena.UpdateActions(); bool isEnd = IsGameEnd(); // Chech if game has ended if (isEnd) { SendLobbyMessage(new Message("server", this.ID, "End", null)); if (timer != null) { this.timer.Stop(); this.timer.Dispose(); } this.State = LobbyStates.Idle; } else { // generate new arena status ArenaStatus report = arena.GenerateReport(); // send lobby message SendLobbyMessage(new Message("server", this.ID, "Update", new { status = report })); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,ArenaStatusName")] ArenaStatus arenaStatus) { if (id != arenaStatus.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(arenaStatus); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ArenaStatusExists(arenaStatus.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(ListArenaStatuses))); } return(View(arenaStatus)); }
public Arena(Map map, ArenaInfo arena, NetConnection <NetSession> red, NetConnection <NetSession> blue) { this.map = map; this.ArenaInfo = arena; this.Red = red; this.Blue = blue; arena.ArenaId = map.InstanceId; this.ArenaStatus = ArenaStatus.Wait; this.RoundStatus = ArenaRoundStatus.None; }
public async Task <IActionResult> Create([Bind("Id,ArenaStatusName")] ArenaStatus arenaStatus) { if (ModelState.IsValid) { _context.Add(arenaStatus); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(ListArenaStatuses))); } return(View(arenaStatus)); }
internal void EntityReady(int entityId) { if (this.Red.Session.Character.entityId == entityId) { this.redReady = true; } if (this.Blue.Session.Character.entityId == entityId) { this.blueReady = true; } if (this.Ready) { this.ArenaStatus = ArenaStatus.Game; this.Round = 0; NextRound(); } }
public void OnTimer() { if (m_pStatus == ArenaStatus.WAITING_APPROVE && m_tInvite.IsTimeOut(60)) { if (m_bP1Accept && !m_bP2Accept) { Finish(m_pPlayer1, m_pPlayer2, true); } else if (m_bP2Accept && !m_bP1Accept) { Finish(m_pPlayer2, m_pPlayer1, true); } else { if (Calculations.ChanceCalc(50f)) { Finish(m_pPlayer1, m_pPlayer2, true); } else { Finish(m_pPlayer2, m_pPlayer1, true); } } } if (m_pStatus == ArenaStatus.NOT_STARTED && m_tStartup.IsActive() && m_tStartup.IsTimeOut(10)) { m_tMatchTime.Startup(300); m_pStatus = ArenaStatus.RUNNING; } else if (m_pStatus == ArenaStatus.RUNNING && m_tMatchTime.IsTimeOut(300)) { Finish(); m_tStartup.Startup(3); m_pStatus = ArenaStatus.FINISHED; } else if (m_pStatus == ArenaStatus.FINISHED && m_tStartup.IsTimeOut(3)) { Dispose(); m_pStatus = ArenaStatus.DISPOSED; } }
public void Dispose() { try { m_pPlayer1.ChangeMap(m_pPlayer1.RecordMapX, m_pPlayer1.RecordMapY, m_pPlayer1.RecordMapIdentity); if (!m_pPlayer1.IsAlive) { m_pPlayer1.Reborn(false, true); } m_pPlayer1.PkMode = m_pPkMode1; } catch { } try { m_pPlayer2.ChangeMap(m_pPlayer2.RecordMapX, m_pPlayer2.RecordMapY, m_pPlayer2.RecordMapIdentity); if (!m_pPlayer2.IsAlive) { m_pPlayer2.Reborn(false, true); } m_pPlayer2.PkMode = m_pPkMode2; } catch { } if (Win1) { ShowFinalDialog(m_pPlayer1, m_pPlayer2); } else { ShowFinalDialog(m_pPlayer2, m_pPlayer1); } TeleportBack(); m_pStatus = ArenaStatus.DISPOSED; }
private void ArenaRsult() { this.ArenaStatus = ArenaStatus.Result; //执行结算 }
public void Finish(Character pWinner, Character pLoser, bool bDispose) { if (pWinner == m_pPlayer1) { Win1 = true; } else { Win2 = true; } pWinner.ArenaQualifier.Points = (uint)(pWinner.ArenaQualifier.Points * 1.03f); pLoser.ArenaQualifier.Points = (uint)(pLoser.ArenaQualifier.Points * .97f); pWinner.ArenaQualifier.TodayWins += 1; pWinner.ArenaQualifier.TotalWins += 1; pLoser.ArenaQualifier.TodayLoses += 1; pLoser.ArenaQualifier.TotalLoses += 1; int todayMatch0 = (int)(pWinner.ArenaQualifier.TodayWins + pWinner.ArenaQualifier.TodayLoses); int todayMatch1 = (int)(pLoser.ArenaQualifier.TodayWins + pLoser.ArenaQualifier.TodayLoses); if (pWinner.ArenaQualifier.TodayWins == 9) { pWinner.ArenaQualifier.TotalHonorPoints += 5000; pWinner.ArenaQualifier.HonorPoints += 5000; } if (todayMatch0 == 20) { pWinner.ArenaQualifier.TotalHonorPoints += 5000; pWinner.ArenaQualifier.HonorPoints += 5000; } if (todayMatch1 == 20) { pLoser.ArenaQualifier.TotalHonorPoints += 5000; pLoser.ArenaQualifier.HonorPoints += 5000; } MsgQualifyingInteractive pMsg = new MsgQualifyingInteractive { Type = ArenaType.DIALOG, Option = 3 // lose }; try { pLoser.Send(pMsg); } catch { } pMsg.Option = 1; // win try { pWinner.Send(pMsg); } catch { } pWinner.ArenaQualifier.Save(); pLoser.ArenaQualifier.Save(); if (pWinner.Syndicate != null && pLoser.Syndicate != null) { ServerKernel.SendMessageToAll(string.Format(ServerString.STR_ARENIC_MATCH_END3, pWinner.SyndicateName, pWinner.Name, pLoser.SyndicateName, pLoser.Name, pWinner.ArenaQualifier.Ranking), ChatTone.QUALIFIER); } else if (pWinner.Syndicate != null && pLoser.Syndicate == null) { ServerKernel.SendMessageToAll(string.Format(ServerString.STR_ARENIC_MATCH_END1, pWinner.SyndicateName, pWinner.Name, pLoser.Name, pWinner.ArenaQualifier.Ranking), ChatTone.QUALIFIER); } else if (pWinner.Syndicate == null && pLoser.Syndicate != null) { ServerKernel.SendMessageToAll(string.Format(ServerString.STR_ARENIC_MATCH_END2, pWinner.Name, pLoser.SyndicateName, pLoser.Name, pWinner.ArenaQualifier.Ranking), ChatTone.QUALIFIER); } else { ServerKernel.SendMessageToAll(string.Format(ServerString.STR_ARENIC_MATCH_END0, pWinner.Name, pLoser.Name, pWinner.ArenaQualifier.Ranking), ChatTone.QUALIFIER); } if (bDispose) { m_pStatus = ArenaStatus.DISPOSED; ShowFinalDialog(pWinner, pLoser); } else { m_tStartup.Startup(3); m_pStatus = ArenaStatus.FINISHED; } }
public void Start() { m_tStartup.Startup(10); m_pStatus = ArenaStatus.NOT_STARTED; m_pPlayer1.DetachBadlyStatus(m_pPlayer1); m_pPlayer2.DetachBadlyStatus(m_pPlayer2); //Console.WriteLine("Players {0} vs {1} has been sent to map {2}", m_pPlayer1.Name, m_pPlayer2.Name, m_pMap.Identity); if (m_pPlayer1.Map.IsRecordDisable()) { uint dwMapId = m_pPlayer1.RecordMapIdentity; Point pos = new Point(m_pPlayer1.RecordMapX, m_pPlayer1.RecordMapY); m_pPlayer1.Map.GetRebornMap(ref dwMapId, ref pos); m_pPlayer1.SetRecordPos(dwMapId, (ushort)pos.X, (ushort)pos.Y); } else { m_pPlayer1.SetRecordPos(m_pPlayer1.MapIdentity, m_pPlayer1.MapX, m_pPlayer1.MapY); } if (m_pPlayer2.Map.IsRecordDisable()) { uint dwMapId = m_pPlayer2.RecordMapIdentity; Point pos = new Point(m_pPlayer2.RecordMapX, m_pPlayer2.RecordMapY); m_pPlayer2.Map.GetRebornMap(ref dwMapId, ref pos); m_pPlayer2.SetRecordPos(dwMapId, (ushort)pos.X, (ushort)pos.Y); } else { m_pPlayer2.SetRecordPos(m_pPlayer2.MapIdentity, m_pPlayer2.MapX, m_pPlayer2.MapY); } if (!m_pPlayer1.IsAlive) { m_pPlayer1.Reborn(false, true); } if (!m_pPlayer2.IsAlive) { m_pPlayer2.Reborn(false, true); } try { m_pPlayer1.ChangeMap((ushort)ThreadSafeRandom.RandGet(35, 70), (ushort)ThreadSafeRandom.RandGet(35, 70), m_pMap.Identity); } catch { Finish(m_pPlayer2, m_pPlayer1, true); return; } try { m_pPlayer2.ChangeMap((ushort)ThreadSafeRandom.RandGet(35, 70), (ushort)ThreadSafeRandom.RandGet(35, 70), m_pMap.Identity); } catch { Finish(m_pPlayer1, m_pPlayer2, true); return; } SendToMap(); m_pPkMode1 = m_pPlayer1.PkMode; m_pPkMode2 = m_pPlayer2.PkMode; m_pPlayer1.PkMode = PkModeType.PK_MODE; m_pPlayer2.PkMode = PkModeType.PK_MODE; m_pPlayer1.SendArenaInformation(m_pPlayer2); m_pPlayer2.SendArenaInformation(m_pPlayer1); MsgQualifyingInteractive pMsg = new MsgQualifyingInteractive(); pMsg.Type = ArenaType.MATCH; pMsg.Option = 5; // Match On m_pPlayer1.Send(pMsg); m_pPlayer2.Send(pMsg); m_pPlayer1.DetachStatus(FlagInt.RIDING); m_pPlayer2.DetachStatus(FlagInt.RIDING); m_pPlayer1.FillLife(); m_pPlayer1.FillMana(); m_pPlayer2.FillLife(); m_pPlayer2.FillMana(); }