/// <summar /// y>Runs all game logic.</summary> public static void Update() { OverallProgress = progressBar.Min(x => x.Value); if (OverallProgress == 100) { ServerSend.EndGame(); Reset(); } newPlayerCount = 0; foreach (Client _client in Server.clients.Values) { if (_client.player != null) { newPlayerCount += 1; _client.player.Update(); } } if (lastPlayerCount == 0 && newPlayerCount > 0) { serverTimer.Start(); } if (lastPlayerCount > 0 && newPlayerCount == 0) { Reset(); } lastPlayerCount = newPlayerCount; serverTimer.Update(); /* * OverallProgress = Math.Min(progressBar["Coal"], Math.Min(progressBar["Water"], progressBar["Metal"])); * if (OverallProgress > 100) // and time remain > red win * { * Console.WriteLine("progress completed."); * } */ ThreadManager.UpdateMain(); }
public static void PlayerAttack(int _fromClient, Packet _packet) { int _id = _packet.ReadInt(); if (Server.clients[_fromClient].player != null) { ServerSend.PlayerAttacked(Server.clients[_fromClient].player, Server.clients[_id].player); Server.clients[_id].player.hp -= 1; if (Server.clients[_id].player.hp <= 0) { ServerSend.PlayerDown(Server.clients[_id].player); int i = 0; Player winner = null; foreach (Client _client in Server.clients.Values) { if (_client.player != null && _client.player.hp > 0) { i++; winner = _client.player; } } if (i == 1) { ServerSend.EndGame(winner); // ELIMINATE ALL PLAYER DATA, RESET GAME, fix camera on victory. // lesch olle jusa! foreach (Client _client in Server.clients.Values) { _client.Disconnect(); } Server.clients = new Dictionary <int, Client>(); Server.InitializeServerData(); } } } }