Ejemplo n.º 1
0
        // ---------------------------------------------------------------------------------------
        public void Randomize(int startValue, string teamName)
        // ---------------------------------------------------------------------------------------
        {
            BaseColor   = Rng.RandomColor();
            AccentColor = new Color(1 - BaseColor.r, 1 - BaseColor.g, 1 - BaseColor.b);


            float amtRemaining     = startValue;
            float perPerson        = amtRemaining / (float)RoughStartNumPlayers;
            float amtSlopRemaining = startValue * 1.2f;

            int failedTries = 0;

            while (amtRemaining > 0 && failedTries < 20)
            {
                BS_Combatant pc = new BS_Combatant();
                pc.SetTeam(this);
                pc.Randomize(perPerson);

                float value = pc.Cost;
                if (amtSlopRemaining - value > 0)  // value isn't pushing us over the slop amt
                {
                    amtRemaining     -= value;
                    amtSlopRemaining -= value;
                    AllTeamMembers.Add(pc);
                }
                else
                {
                    failedTries++;
                }
            }
            DisplayName = teamName;
        }