public void Init(WS_Tile tile, EntityType _type) { type = _type; switch (type) { case EntityType.CULTURE: minTraits = WS_Culture.MIN_TRAITS_CULTURE; maxTraits = WS_Culture.MAX_TRAITS_CULTURE; name = WS_WordCreator.Create(); break; case EntityType.RELIGION: minTraits = WS_Religion.MIN_TRAITS_RELIGION; maxTraits = WS_Religion.MAX_TRAITS_RELIGION; name = WS_WordCreator.Create(); break; case EntityType.GOVERNMENT: minTraits = WS_Government.MIN_TRAITS_GOVERNMENT; maxTraits = WS_Government.MAX_TRAITS_GOVERNMENT; break; } float selector = 1.0f; while (selector > 0.0f) { addRandomTrait(tile); selector = Random.Range(minTraits - traits.Count - 0.99f, maxTraits - traits.Count - 0.1f); } if (type == EntityType.GOVERNMENT) { ((WS_Government)this).Rename(); } capital = tile; color = new Color(Random.Range(0.3f, 1.0f), Random.Range(0.3f, 1.0f), Random.Range(0.3f, 1.0f)); sprite = WS_CoatManager.GetCoat(); }
public void Init(WS_Entity base_entity, WS_Tile tile) { type = base_entity.type; name = WS_WordCreator.Create(); switch (type) { case EntityType.CULTURE: minTraits = WS_Culture.MIN_TRAITS_CULTURE; maxTraits = WS_Culture.MAX_TRAITS_CULTURE; break; case EntityType.RELIGION: minTraits = WS_Religion.MIN_TRAITS_RELIGION; maxTraits = WS_Religion.MAX_TRAITS_RELIGION; break; } foreach (WS_Trait trait in base_entity.traits) { trait.Apply(this); traits.Add(trait); } int changeNum = Mathf.CeilToInt(Random.Range(0.25f * base_entity.traits.Count, 0.5f * base_entity.traits.Count)); while (changeNum > 0) { addRandomTrait(base_entity.capital); changeNum--; } capital = tile; float r = base_entity.color.r; float g = base_entity.color.g; float b = base_entity.color.b; color = new Color(Random.Range(0.3f, 1.0f), Random.Range(0.3f, 1.0f), Random.Range(0.3f, 1.0f)); sprite = WS_CoatManager.GetCoat(); }
public void Init(WS_Entity base_entity_A, WS_Entity base_entity_B, WS_Tile tile) { type = base_entity_A.type; name = WS_WordCreator.Create(); if (type == EntityType.CULTURE) { ((WS_Culture)this).merged = true; } if (type == EntityType.RELIGION) { ((WS_Religion)this).merged = true; } minTraits = Mathf.Max(base_entity_A.minTraits, base_entity_B.minTraits); maxTraits = Mathf.Max(base_entity_A.maxTraits, base_entity_B.maxTraits); int traitNum = (base_entity_A.traits.Count + base_entity_B.traits.Count) / 2; for (int i = 0; i < traitNum; i++) { bool valid_A = false; bool valid_B = false; if (traitNum < base_entity_A.traits.Count) { if (!traits.Contains(base_entity_A.traits[traitNum])) { valid_A = true; foreach (WS_Trait ownedTrait in traits) { if (ownedTrait.Group() == base_entity_A.traits[traitNum].Group()) { valid_A = false; break; } } } } if (traitNum < base_entity_B.traits.Count) { if (!traits.Contains(base_entity_B.traits[traitNum])) { valid_B = true; foreach (WS_Trait ownedTrait in traits) { if (ownedTrait.Group() == base_entity_B.traits[traitNum].Group()) { valid_B = false; break; } } } } if (valid_A && !valid_B) { traits.Add(base_entity_A.traits[traitNum]); } else if (!valid_A && valid_B) { traits.Add(base_entity_B.traits[traitNum]); } else if (valid_A && valid_B) { float selector = Random.Range(0.0f, 1.0f); if (selector < 0.5f) { traits.Add(base_entity_A.traits[traitNum]); } else { traits.Add(base_entity_B.traits[traitNum]); } } if (valid_A || valid_B) { traits[traits.Count - 1].Apply(this); } } for (int i = traits.Count; i < minTraits; i++) { addRandomTrait(tile); } capital = tile; color = (base_entity_A.color + base_entity_B.color) / 2.0f; sprite = WS_CoatManager.GetCoat(); }