コード例 #1
0
 public Attributes(string name, EyeColour eyes, HairColour hair, int age)
 {
     Name = name;
     Eyes = eyes;
     Hair = hair;
     Age  = age;
 }
コード例 #2
0
 public HumanGenetics(GameObject go, Human human)
 {
     _go         = go;
     _human      = human;
     _eyeColour  = (EyeColour)Random.Range(0, 10);
     _hairColour = (HairColour)Random.Range(0, 17);
     _skinTone   = (SkinTone)Random.Range(0, 24);
     ChooseClothes();
 }
コード例 #3
0
    public HumanGenetics(GameObject go, Human human, Human father, Human mother)
    {
        _go    = go;
        _human = human;
        HumanGenetics temp = BreedHumanGenetics(father._humanGenetics, mother._humanGenetics);

        _eyeColour  = temp._eyeColour;
        _hairColour = temp._hairColour;
        _skinTone   = temp._skinTone;
        ChooseClothes();
    }
コード例 #4
0
 EyeColour SimplifyColour(EyeColour e)
 {
     if ((int)e < 3)
     {
         return(EyeColour.Blue);
     }
     else if ((int)e < 5)
     {
         return(EyeColour.Green);
     }
     else
     {
         return(EyeColour.Brown);
     }
 }
コード例 #5
0
        public async Task <EyeColour> UpdateEyeColorAsync(EyeColour eyeColor)
        {
            try
            {
                _context.EyeColors.Update(eyeColor);
                await _context.SaveChangesAsync();

                return(eyeColor);
            }
            catch (Exception ex)
            {
                _logger.LogError($"{ex.StackTrace}\n{ex.Message}");
                return(null);
            }
        }
コード例 #6
0
        /// <summary>
        /// Update database
        /// </summary>
        /// <param name="eyeColor"></param>
        /// <returns></returns>
        #region Update EyeColor
        public EyeColour UpdateEyeColor(EyeColour eyeColor)
        {
            try
            {
                _context.EyeColors.Update(eyeColor);
                _context.SaveChanges();

                return(eyeColor);
            }
            catch (Exception ex)
            {
                _logger.LogError($"{ex.StackTrace}\n{ex.Message}");
                return(null);
            }
        }
コード例 #7
0
 private bool ValidateField(KeyValuePair <string, string> kvp)
 {
     var(key, value) = kvp;
     return(key switch
     {
         "byr" => BirthYear.IsValid(value),
         "iyr" => IssueYear.IsValid(value),
         "eyr" => ExpirationYear.IsValid(value),
         "hgt" => Height.IsValid(value),
         "hcl" => HairColour.IsValid(value),
         "ecl" => EyeColour.IsValid(value),
         "pid" => PassportId.IsValid(value),
         "cid" => true,
         _ => false
     });
コード例 #8
0
        // step 4: get eyeColor by id
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(BadRequest());
            }

            EyeColor = await _eyeColorService.GetEyeColorByIdAsync(id.Value);

            if (EyeColor == null)
            {
                return(NotFound());
            }

            return(Page());
        }
コード例 #9
0
 EyeColour DesimplifyColour(EyeColour e)
 {
     if (e == EyeColour.Brown)
     {
         int temp = Random.Range(0, 5) + 5;
         return((EyeColour)temp);
     }
     else if (e == EyeColour.Blue)
     {
         int temp = Random.Range(0, 3);
         return((EyeColour)temp);
     }
     else
     {
         int temp = Random.Range(0, 2) + 3;
         return((EyeColour)temp);
     }
 }
コード例 #10
0
    public HumanGenetics(GameObject go, Human human, int template)
    {
        _go         = go;
        _human      = human;
        _eyeColour  = (EyeColour)Random.Range(0, 10);
        _hairColour = (HairColour)Random.Range(0, 17);
        ChooseClothes();
        switch (template)
        {
        case 0:
        {
            _skinTone = SkinTone.light4;
            break;
        }

        case 1:
        {
            _skinTone = SkinTone.light0;
            break;
        }

        case 2:
        {
            _skinTone = SkinTone.light2;
            break;
        }

        case 3:
        {
            _skinTone = SkinTone.dark0;
            break;
        }

        case 4:
        {
            _skinTone = SkinTone.medium0;
            break;
        }
        }
    }
コード例 #11
0
    EyeColour BreedEyeColour(EyeColour father, EyeColour mother)
    {
        father = SimplifyColour(father);
        mother = SimplifyColour(mother);
        int temp = Random.Range(0, 100);   //percentage chance

        if (father == mother)              //same eyes
        {
            if (father == EyeColour.Brown) //brown-brown
            {
                if (temp < 75)             //75% chance of brown
                {
                    return(DesimplifyColour(EyeColour.Brown));
                }
                else if (temp < 75 + 19) //19% chance of green
                {
                    return(DesimplifyColour(EyeColour.Green));
                }
                else //6% chance of blue
                {
                    return(DesimplifyColour(EyeColour.Blue));
                }
            }
            else if (father == EyeColour.Blue) //blue-blue
            {
                if (temp < 99)                 //99% chance of blue
                {
                    return(DesimplifyColour(EyeColour.Blue));
                }
                else   //1% chance of green
                {
                    return(DesimplifyColour(EyeColour.Green));
                }
            }
            else               // green-green
            {
                if (temp < 75) //75% chance of green
                {
                    return(DesimplifyColour(EyeColour.Green));
                }
                else if (temp < 75 + 24)   //24% chance of blue
                {
                    return(DesimplifyColour(EyeColour.Blue));
                }
                else   //1% chance of brown
                {
                    return(DesimplifyColour(EyeColour.Brown));
                }
            }
        }
        else if (father == EyeColour.Green || mother == EyeColour.Green)
        {
            if (father == EyeColour.Brown || mother == EyeColour.Brown) //green-brown
            {
                if (temp < 50)                                          //50% chance of brown
                {
                    return(DesimplifyColour(EyeColour.Brown));
                }
                else if (temp < 50 + 38)   //38% chance of green
                {
                    return(DesimplifyColour(EyeColour.Green));
                }
                else   //12% chance of blue
                {
                    return(DesimplifyColour(EyeColour.Blue));
                }
            }
            else if (father == EyeColour.Blue || mother == EyeColour.Blue) //green-blue
            {
                if (temp < 50)                                             //50% chance of green
                {
                    return(DesimplifyColour(EyeColour.Green));
                }
                else   // 50% chance of blue
                {
                    return(DesimplifyColour(EyeColour.Blue));
                }
            }
        }
        else   //blue-brown
        {
            if (temp < 50)
            {
                return(DesimplifyColour(EyeColour.Brown));
            }
            else
            {
                return(DesimplifyColour(EyeColour.Blue));
            }
        }
        return(EyeColour.Green); //default
    }
コード例 #12
0
 public Material GetEyeColour(EyeColour e)
 {
     return(GameController.instance.eyeColours[(int)e]);
 }