private void Start() { if (FindObjectOfType <TutorialController>().tutorialChar != this) { outfit = GetComponentInChildren <OutfitController>(); startingScale = transform.localScale.x; isAgent = IsAgentOrFemale(); gender = IsAgentOrFemale() ? Constants.Genders.Female : Constants.Genders.Male; skinColor = IsBlack() ? Constants.SkinColor.Black : Constants.SkinColor.White; selectedPattern = outfit.SetOutfit(ref isAgent, gender, skinColor); StartBreathing(); faceController.SetFace(Constants.FaceType.Basic, this, gender, skinColor); lastTarget = transform.position; } }
public void OnValidate() { bool wasSet = false; for (int i = 0; i < patternDetails.Count; i++) { Structs.PatternDetails temp = patternDetails[i]; if (temp.sprite != null) { wasSet = true; bool isAgent = !temp.sprite.name.Contains("_civil_") ? true : false; temp.forGender = setGender(temp.sprite.name); temp.isAgent = isAgent; temp.isActive = !isAgent; temp.differenceType = isAgent ? parseDifferenceType(temp.sprite.name) : Constants.DifferenceType.Civil; patternDetails[i] = temp; } } if (wasSet) { patternDetails.Sort((s1, s2) => s1.sprite.name.CompareTo(s2.sprite.name)); wasSet = false; } for (int i = 0; i < partDetails.Count; i++) { Structs.PartDetails temp = partDetails[i]; if (temp.sprite != null) { wasSet = true; bool isFemale = temp.sprite.name.Contains("_f_") ? true : false; Constants.SkinColor skin = temp.sprite.name.Contains("_b_") ? Constants.SkinColor.Black : Constants.SkinColor.White; temp.gender = isFemale ? Constants.Genders.Female : Constants.Genders.Male; temp.skinColor = skin; partDetails[i] = temp; } } if (wasSet) { partDetails.Sort((s1, s2) => s1.sprite.name.CompareTo(s2.sprite.name)); } }
public Sprite SetOutfit(ref bool isAgent, Constants.Genders gender, Constants.SkinColor skinColor) { bodyPartsWithPatterns = new List <BodyPart>(); List <Structs.PartDetails> availableParts = bodyParts[0].partDetails.Where(part => (part.gender == gender || part.gender == Constants.Genders.Both) && !part.isDisabled).ToList(); Structs.PartDetails selectedBodyPart = availableParts[CommonMethods.RandomizeIndex(availableParts)]; selectedSet = bodyParts[0].partDetails.IndexOf(selectedBodyPart); foreach (BodyPart bodyPart in bodyParts) { bodyPart.SetBodyPart(selectedSet); if (bodyPart.pattern) { bodyPartsWithPatterns.Add(bodyPart); } } //Na razie random 1 elementu hairController.SetHair(gender); faceController.SetFace(Constants.FaceType.Basic, GetComponent <Character>(), gender, skinColor); return(bodyPartsWithPatterns[CommonMethods.RandomizeIndex(bodyPartsWithPatterns)].SetPattern(ref isAgent, gender)); }
public void SetFace(Constants.FaceType face, Character chr, Constants.Genders gender, Constants.SkinColor skinColor) { chr.currentFace = face; spriteRenderer.sortingOrder = GetComponentInParent <SpriteRenderer>().sortingOrder++; List <Structs.Face> availableFaces = faces.Where(x => x.gender == gender && x.type == face && x.skinColor == skinColor).ToList(); spriteRenderer.sprite = availableFaces[CommonMethods.RandomizeIndex(availableFaces)].sprite; }