예제 #1
0
        public void UpdateFractions()
        {
            var playersWithDamage = Players.Where(player => player.Damage > 0);

            if (!playersWithDamage.Any())
            {
                foreach (var player in Players)
                {
                    player.DamageFraction = 0;
                    player.BarFraction    = 0;
                }

                return;
            }

            NormalizeDamagePoints();
            PlayersDamageUpdated?.Invoke(this, EventArgs.Empty);

            var highestDamagePlayers = Players.OrderByDescending(player => player.Damage).Take(1);

            if (highestDamagePlayers.Any())
            {
                int totalDamage = Players.Sum(player => player.Damage);

                var highestDamagePlayer = highestDamagePlayers.First();
                highestDamagePlayer.DamageFraction = (float)highestDamagePlayer.Damage / (float)totalDamage;
                highestDamagePlayer.BarFraction    = 1;
                //Log.WriteLine(String.Format("{0} {1} {2}", highestDamagePlayer.Damage.ToString(), highestDamagePlayer.DamageFraction.ToString(), highestDamagePlayer.BarFraction.ToString()));
                foreach (var otherPlayer in Players.Except(highestDamagePlayers))
                {
                    otherPlayer.DamageFraction = (float)otherPlayer.Damage / (float)totalDamage;
                    otherPlayer.BarFraction    = (float)otherPlayer.Damage / (float)highestDamagePlayer.Damage;
                }
            }
        }
예제 #2
0
 public void ClearPlayers()
 {
     Players.Clear();
     Fake_Players.Clear();
     PlayersDamageUpdated?.Invoke(this, EventArgs.Empty);
 }