public static SizeTrait createSmall() { if (instantiatedTraits.ContainsKey(TraitFactory.Traits.Small.ToString())) { return(instantiatedTraits[TraitFactory.Traits.Small.ToString()]); } SizeTrait small = new SizeTrait(); small.size = (int)Size.Small; small.attributes.Add(TraitFactory.Attribute.Fighting.ToString(), 0); small.attributes.Add(TraitFactory.Attribute.Strength.ToString(), 0); small.attributes.Add(TraitFactory.Attribute.Tracking.ToString(), 0); small.attributes.Add(TraitFactory.Attribute.Food.ToString(), 1); small.inheritanceChance = 0.5f; small.name = TraitFactory.Traits.Small.ToString(); small.type = TraitFactory.Traits.Small.ToString(); small.traitClass = TraitFactory.TraitClass.Size.ToString(); small.linkageMap.Add(TraitFactory.Traits.Strong.ToString(), -1.0f); small.linkageMap.Add(TraitFactory.Traits.Weak.ToString(), 1.0f); small.linkageMap.Add(TraitFactory.Traits.Slow.ToString(), -1.0f); small.linkageMap.Add(TraitFactory.Traits.Quick.ToString(), 1.0f); small.linkageMap.Add(Size.Tiny.ToString(), 0.5f); small.linkageMap.Add(Size.Small.ToString(), 1.5f); small.linkageMap.Add(Size.Midsized.ToString(), 0.5f); instantiatedTraits[TraitFactory.Traits.Small.ToString()] = small; return(small); }
public static SizeTrait createMidsized() { if (instantiatedTraits.ContainsKey(TraitFactory.Traits.Midsized.ToString())) { return(instantiatedTraits[TraitFactory.Traits.Midsized.ToString()]); } SizeTrait midsized = new SizeTrait(); midsized.size = (int)Size.Midsized; midsized.attributes.Add(TraitFactory.Attribute.Fighting.ToString(), 1); midsized.attributes.Add(TraitFactory.Attribute.Strength.ToString(), 0); midsized.attributes.Add(TraitFactory.Attribute.Tracking.ToString(), 0); midsized.attributes.Add(TraitFactory.Attribute.Food.ToString(), 2); midsized.inheritanceChance = 0.5f; midsized.name = TraitFactory.Traits.Midsized.ToString(); midsized.type = TraitFactory.Traits.Midsized.ToString(); midsized.traitClass = TraitFactory.TraitClass.Size.ToString(); midsized.linkageMap.Add(Size.Small.ToString(), 0.5f); midsized.linkageMap.Add(Size.Midsized.ToString(), 1.5f); midsized.linkageMap.Add(Size.Large.ToString(), 0.5f); instantiatedTraits[TraitFactory.Traits.Midsized.ToString()] = midsized; return(midsized); }
public static SizeTrait createTiny() { if (instantiatedTraits.ContainsKey(TraitFactory.Traits.Tiny.ToString())) { return(instantiatedTraits[TraitFactory.Traits.Tiny.ToString()]); } SizeTrait tiny = new SizeTrait(); tiny.size = (int)Size.Tiny; tiny.attributes.Add(TraitFactory.Attribute.Fighting.ToString(), -1); tiny.attributes.Add(TraitFactory.Attribute.Strength.ToString(), 0); tiny.attributes.Add(TraitFactory.Attribute.Tracking.ToString(), 0); tiny.attributes.Add(TraitFactory.Attribute.Food.ToString(), 0); tiny.inheritanceChance = 0.5f; tiny.name = TraitFactory.Traits.Tiny.ToString(); tiny.type = TraitFactory.Traits.Tiny.ToString(); tiny.traitClass = TraitFactory.TraitClass.Size.ToString(); tiny.linkageMap.Add(TraitFactory.Traits.Strong.ToString(), -2.0f); tiny.linkageMap.Add(TraitFactory.Traits.Weak.ToString(), 1.5f); tiny.linkageMap.Add(TraitFactory.Traits.Slow.ToString(), -2.0f); tiny.linkageMap.Add(TraitFactory.Traits.Quick.ToString(), 1.5f); tiny.linkageMap.Add(TraitFactory.Traits.Flying.ToString(), 0.5f); tiny.linkageMap.Add(Size.Tiny.ToString(), 1.5f); tiny.linkageMap.Add(Size.Small.ToString(), 0.5f); instantiatedTraits[TraitFactory.Traits.Tiny.ToString()] = tiny; return(tiny); }
public static SizeTrait createEnormous() { if (instantiatedTraits.ContainsKey(TraitFactory.Traits.Enormous.ToString())) { return(instantiatedTraits[TraitFactory.Traits.Enormous.ToString()]); } SizeTrait enormous = new SizeTrait(); enormous.size = (int)Size.Enormous; enormous.attributes.Add(TraitFactory.Attribute.Fighting.ToString(), 3); enormous.attributes.Add(TraitFactory.Attribute.Strength.ToString(), 3); enormous.attributes.Add(TraitFactory.Attribute.Tracking.ToString(), 0); enormous.attributes.Add(TraitFactory.Attribute.Food.ToString(), 6); enormous.inheritanceChance = 0.5f; enormous.name = TraitFactory.Traits.Enormous.ToString(); enormous.type = TraitFactory.Traits.Enormous.ToString(); enormous.traitClass = TraitFactory.TraitClass.Size.ToString(); enormous.linkageMap.Add(TraitFactory.Traits.Strong.ToString(), 3.0f); enormous.linkageMap.Add(TraitFactory.Traits.Weak.ToString(), -3.0f); enormous.linkageMap.Add(TraitFactory.Traits.Slow.ToString(), 3.0f); enormous.linkageMap.Add(TraitFactory.Traits.Quick.ToString(), -3.0f); enormous.linkageMap.Add(TraitFactory.Traits.Flying.ToString(), -6.0f); enormous.linkageMap.Add(TraitFactory.Traits.Climb.ToString(), -6.0f); enormous.linkageMap.Add(Size.Huge.ToString(), 0.5f); enormous.linkageMap.Add(Size.Enormous.ToString(), 1.5f); instantiatedTraits[TraitFactory.Traits.Enormous.ToString()] = enormous; return(enormous); }
public static SizeTrait createHuge() { if (instantiatedTraits.ContainsKey(TraitFactory.Traits.Huge.ToString())) { return(instantiatedTraits[TraitFactory.Traits.Huge.ToString()]); } SizeTrait huge = new SizeTrait(); huge.size = (int)Size.Huge; huge.attributes.Add(TraitFactory.Attribute.Fighting.ToString(), 2); huge.attributes.Add(TraitFactory.Attribute.Strength.ToString(), 2); huge.attributes.Add(TraitFactory.Attribute.Tracking.ToString(), 0); huge.attributes.Add(TraitFactory.Attribute.Food.ToString(), 4); huge.inheritanceChance = 0.5f; huge.name = TraitFactory.Traits.Huge.ToString(); huge.type = TraitFactory.Traits.Huge.ToString(); huge.traitClass = TraitFactory.TraitClass.Size.ToString(); huge.linkageMap.Add(TraitFactory.Traits.Strong.ToString(), 1.5f); huge.linkageMap.Add(TraitFactory.Traits.Weak.ToString(), -2.0f); huge.linkageMap.Add(TraitFactory.Traits.Slow.ToString(), 1.5f); huge.linkageMap.Add(TraitFactory.Traits.Quick.ToString(), -2.0f); huge.linkageMap.Add(TraitFactory.Traits.Flying.ToString(), -2.0f); huge.linkageMap.Add(TraitFactory.Traits.Climb.ToString(), -2.0f); huge.linkageMap.Add(Size.Large.ToString(), 0.5f); huge.linkageMap.Add(Size.Huge.ToString(), 1.5f); huge.linkageMap.Add(Size.Enormous.ToString(), 0.5f); instantiatedTraits[TraitFactory.Traits.Huge.ToString()] = huge; return(huge); }
public override bool isCompatible(BaseTrait other) { if (other is SizeTrait) { SizeTrait otherSize = other as SizeTrait; return(1 >= System.Math.Abs(otherSize.size - size)); } return(false); }
public int GetAttributeScore(string attribute) { int score = 3; score += SpeciesTrait.getAttributes(attribute); score += SizeTrait.getAttributes(attribute); foreach (BaseTrait t in Traits) { score += t.getAttributes(attribute); } return score; }
public GameObject createAnimal(SpeciesTrait species, SizeTrait size, int age) { GameObject pf = GameObject.Instantiate(animalPrefab); Animal animal = pf.GetComponent <Animal>(); List <BaseTrait> allTraits = new List <BaseTrait> (); allTraits.Add(species); allTraits.Add(size); List <BaseTrait> miscTraits = TraitSelector.selectTraits(allTraits); animal.Initialize(species, size, miscTraits, age); return(pf); }
public void Initialize(SpeciesTrait species, SizeTrait size, List <BaseTrait> inputTraits, int age) { SpeciesTrait = species; SizeTrait = size; Traits = inputTraits; Image image = GetComponent <Image>(); if (image != null) { image.sprite = animals[species.spriteIndex]; } this.age = age; adjustScaleForAge(); MyEventSystem.OnSeasonAdvance += GetOlder; }
public static SizeTrait selectSize(SpeciesTrait species, SizeTrait leftSize, SizeTrait rightSize) { List <SizeTrait> possibleSize = new List <SizeTrait>(); foreach (SizeTrait size in SizeFactory.GetAllSizeTraits()) { if ((leftSize.size - 1 <= size.size && leftSize.size + 1 >= size.size) || (rightSize.size - 1 <= size.size && rightSize.size + 1 >= size.size)) { possibleSize.Add(size); } } foreach (SizeTrait trait in Randomize(possibleSize)) { float probability = baseInheritance; if (leftSize.size == trait.size) { probability += trait.tenacity; } if (rightSize.size == trait.size) { probability += trait.tenacity; } probability += trait.getLinkageChance(new List <BaseTrait>() { species, leftSize, rightSize }); probability += trait.inheritanceChance; if (Random.value < logistic(probability)) { return(trait); } } if (Random.value < 0.5f) { return(leftSize); } return(rightSize); }
public GameObject breedWith(Animal mate) { if (!CanBreedWith(mate)) { return(null); } GameObject baby = GameObject.Instantiate(animalPrefab); Animal babyAnimal = baby.GetComponent <Animal>(); List <BaseTrait> mandatoryTraits = new List <BaseTrait>(); SizeTrait babySize = TraitSelector.selectSize(SpeciesTrait, SizeTrait, mate.SizeTrait); babyAnimal.Initialize(SpeciesTrait, babySize); mandatoryTraits.Add(SpeciesTrait); mandatoryTraits.Add(babySize); babyAnimal.Traits = TraitSelector.selectTraits(mandatoryTraits, this.Traits, mate.Traits); return(baby); }
public void Initialize(SpeciesTrait species, SizeTrait size) { Initialize(species, size, new List <BaseTrait> (), 0); }
public bool CanBreedWith(Animal mate) { return(SpeciesTrait.isCompatible(mate.SpeciesTrait) && SizeTrait.isCompatible(mate.SizeTrait)); }
public GameObject createAnimal(SpeciesTrait species, SizeTrait size) { return(createAnimal(species, size, /* age */ 0)); }