Ejemplo n.º 1
0
    void StartTime()
    {
        if (isDayPaused)
        {
            return;
        }
        this.week += 1;
        if (week > 4)
        {
            this.week   = 1;
            this.month += 1;
            if (this.month > 12)
            {
                this.month = 1;
                this.year += 1;
                RoyaltyEventDelegate.TriggerIncreaseIllnessAndAccidentChance();
            }
        }
        if (turnEnded != null)
        {
            turnEnded();
        }

        if (this.kingdoms.Count > 0)
        {
//			for (int i = 0; i < this.kingdoms.Count; i++) {
//				for (int j = 0; j < this.kingdoms[i].kingdom.lord.relationshipLords.Count; j++) {
//					if(this.kingdoms[i].kingdom.lord.relationshipLords[j].lord.kingdom.cities.Count <= 0){
//						this.kingdoms [i].kingdom.lord.relationshipLords.RemoveAt (j);
//						j--;
//					}
//				}
//			}
            for (int i = 0; i < this.kingdoms.Count; i++)
            {
                if (this.kingdoms[i].kingdom.cities.Count <= 0)
                {
                    this.kingdoms [i].kingdom.isDead = true;
//					turnEnded -= this.kingdoms [i].TurnActions;
//					Destroy (this.kingdoms [i].gameObject);
                    this.kingdoms.RemoveAt(i);
                    i--;
                }
            }
        }
    }
Ejemplo n.º 2
0
    internal void AssignNewLord(Royalty newLord)
    {
        if (newLord == null)
        {
            CreateInitialRoyalties();
        }
        else
        {
            if (newLord.isMarried)
            {
                if (newLord.spouse.kingdom.assignedLord.id == newLord.spouse.id)
                {
                    AssimilateKingdom(newLord.spouse.kingdom);
                    return;
                }
                else
                {
                    if (newLord.kingdom.id != this.id)
                    {
                        //if not loyal to lord of your current kingdom
                        if (newLord.loyalLord.id != this.assignedLord.id)
                        {
                            int assimilateChance = UnityEngine.Random.Range(0, 100);
                            if (assimilateChance < 35)
                            {
                                AssimilateKingdom(newLord.loyalLord.kingdom);
                                return;
                            }
                            else
                            {
                                this.SearchRelationshipKingdomsById(newLord.loyalLord.kingdom.id).isAtWar = false;
                                newLord.loyalLord.kingdom.SearchRelationshipKingdomsById(this.id).isAtWar = false;
                            }
                        }

                        //Transfer whole family to kingdom
                        newLord.spouse.kingdom   = this;
                        newLord.spouse.loyalLord = newLord;
                        for (int i = 0; i < newLord.children.Count; i++)
                        {
                            if (!newLord.children [i].isMarried)
                            {
                                newLord.children [i].kingdom   = this;
                                newLord.children [i].loyalLord = newLord;
                            }
                        }
                    }
                    else
                    {
                        //if not loyal to lord of your current kingdom
                        if (newLord.loyalLord.id != this.assignedLord.id)
                        {
                            int assimilateChance = UnityEngine.Random.Range(0, 100);
                            if (assimilateChance < 35)
                            {
                                AssimilateKingdom(newLord.loyalLord.kingdom);
                                return;
                            }
                            else
                            {
                                this.SearchRelationshipKingdomsById(newLord.loyalLord.kingdom.id).isAtWar = false;
                                newLord.loyalLord.kingdom.SearchRelationshipKingdomsById(this.id).isAtWar = false;
                            }
                        }
                    }
                }
            }
            else
            {
                //if not loyal to lord of your current kingdom
                if (newLord.loyalLord.id != this.assignedLord.id)
                {
                    int assimilateChance = UnityEngine.Random.Range(0, 100);
                    if (assimilateChance < 35)
                    {
                        AssimilateKingdom(newLord.loyalLord.kingdom);
                        return;
                    }
                    else
                    {
                        this.SearchRelationshipKingdomsById(newLord.loyalLord.kingdom.id).isAtWar = false;
                        newLord.loyalLord.kingdom.SearchRelationshipKingdomsById(this.id).isAtWar = false;
                    }
                }
            }
            newLord.loyalLord = newLord;
            RoyaltyEventDelegate.TriggerMassChangeLoyalty(newLord, this.assignedLord);
            if (!newLord.isDirectDescendant)
            {
//				RoyaltyEventDelegate.TriggerChangeIsDirectDescendant (false);
                Utilities.ChangeDescendantsRecursively(newLord, true);
                Utilities.ChangeDescendantsRecursively(this.assignedLord, false);
            }
            this.assignedLord = newLord;
            UpdateLordSuccession();
        }
    }