Esempio n. 1
0
    /// <summary>
    /// Generates a random Color for the specific part.
    /// </summary>
    /// <param name="parts">The part a Color should be generated for</param>
    /// <returns>The generated Color</returns>
    internal Color32 GenerateColor(EmployeePart parts)
    {
        Dictionary <Color32, float> current = GetCurrentDictionary(parts);
        // Generate a Random weighted Color
        float   rand        = UnityEngine.Random.value;
        float   totalWeight = 0;
        Color32 chosenColor = Color.black;

        foreach (var color in current)
        {
            totalWeight += color.Value;
            if (rand < totalWeight)
            {
                chosenColor = color.Key;
                return(chosenColor);
            }
        }
        return(chosenColor);
    }
Esempio n. 2
0
    /// <summary>
    /// Gets the Color Dictionary for the EmployeePart.
    /// </summary>
    /// <param name="part">The part of the Employee.</param>
    /// <returns>The Color Dictionary</returns>
    internal Dictionary <Color32, float> GetCurrentDictionary(EmployeePart part)
    {
        switch (part)
        {
        case EmployeePart.HAIR:
            return(hairColors);

        case EmployeePart.EYES:
            return(eyesColors);

        case EmployeePart.SHIRT:
            return(shirtColors);

        case EmployeePart.SHOES:
            return(shoesColors);

        case EmployeePart.SHORTS:
            return(shortsColors);

        default:
            return(skinColors);
        }
    }
 public void SetColorToPart(Color32 col, EmployeePart part)
 {
     switch (part)
     {
         case EmployeePart.EYES:
             this.eyeColor = col;
             break;
         case EmployeePart.HAIR:
             this.hairColor = col;
             break;
         case EmployeePart.SHIRT:
             this.shirtColor = col;
             break;
         case EmployeePart.SHOES:
             this.shoeColor = col;
             break;
         case EmployeePart.SHORTS:
             this.shortsColor = col;
             break;
         default:
             this.skinColor = col;
             break;
     }
 }