Esempio n. 1
0
    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();
    }
Esempio n. 2
0
    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();
    }
Esempio n. 3
0
    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();
    }
Esempio n. 4
0
    public void Rename()
    {
        PowerDistribution powerDistribution = PowerDistribution.AUTOCRACY;
        PowerHolder       powerHolder       = PowerHolder.RULER;

        foreach (WS_Trait trait in traits)
        {
            if (trait.Group() == TraitGroup.POWER_DISTRIBUTION)
            {
                if (trait.traitName() == "Oligarchy")
                {
                    powerDistribution = PowerDistribution.OLIGARCHY;
                }
                if (trait.traitName() == "Ruling Council")
                {
                    powerDistribution = PowerDistribution.RULING_COUNCIL;
                }
                if (trait.traitName() == "Democracy")
                {
                    powerDistribution = PowerDistribution.DEMOCRACY;
                }
            }
            else if (trait.Group() == TraitGroup.POWER_HOLDER)
            {
                if (trait.traitName() == "Nobility Holder")
                {
                    powerHolder = PowerHolder.NOBILITY;
                }
                if (trait.traitName() == "Church Holder")
                {
                    powerHolder = PowerHolder.CHURCH;
                }
                if (trait.traitName() == "People Holder")
                {
                    powerHolder = PowerHolder.PEOPLE;
                }
            }
        }

        switch (powerDistribution)
        {
        case PowerDistribution.AUTOCRACY:

            switch (powerHolder)
            {
            case PowerHolder.PEOPLE:    name = "Elective Monarchy";  break;

            case PowerHolder.CHURCH:    name = "Papacy"; break;

            case PowerHolder.NOBILITY:  name = "Electorate"; break;

            case PowerHolder.RULER:     name = "Empire"; break;
            }
            break;

        case PowerDistribution.OLIGARCHY:

            switch (powerHolder)
            {
            case PowerHolder.PEOPLE:    name = "Plutocracy";  break;

            case PowerHolder.CHURCH:    name = "Ecclesiastical State"; break;

            case PowerHolder.NOBILITY:  name = "Oligarchy"; break;

            case PowerHolder.RULER:     name = "Feudal State"; break;
            }
            break;


        case PowerDistribution.RULING_COUNCIL:

            switch (powerHolder)
            {
            case PowerHolder.PEOPLE:    name = "Democratical Assembly"; break;

            case PowerHolder.CHURCH:    name = "Theocracy"; break;

            case PowerHolder.NOBILITY:  name = "War Council"; break;

            case PowerHolder.RULER:     name = "Regent Council"; break;
            }
            break;


        case PowerDistribution.DEMOCRACY:

            switch (powerHolder)
            {
            case PowerHolder.PEOPLE:    name = "Democratic State"; break;

            case PowerHolder.CHURCH:    name = "Clergy State"; break;

            case PowerHolder.NOBILITY:  name = "Republic"; break;

            case PowerHolder.RULER:     name = "Demarchy"; break;
            }
            break;
        }

        name += " of ";
        name += WS_WordCreator.Create();
    }