예제 #1
0
파일: Family.cs 프로젝트: EmilieS/Gleipnir
        internal Family(Game game, Villager mother, Villager father, string name)
            : base(game)
        {
            // Initialized historized value for gold
            _goldStash = new HistorizedValue<int, Family>(this, @"_goldstash", 20);
            _hungry = new HistorizedValue<bool, Family>(this, @"_hungry", 5);

            if (mother.ParentFamily != null && father.ParentFamily != null)
            {
                _goldStash.Current = mother.ParentFamily.TakeFromGoldStash(mother.ParentFamily.GoldStash / 10); //10%
                _goldStash.Current += father.ParentFamily.TakeFromGoldStash(father.ParentFamily.GoldStash / 10); //10%
                RemoveFromFamily(mother, mother.ParentFamily);
                RemoveFromFamily(father, father.ParentFamily);
            }
            else
                _goldStash.Current = 20;

            game.GoldAdded(_goldStash.Current);

            if (mother.StatusInFamily == Status.SINGLE && father.StatusInFamily == Status.SINGLE)
                mother.Engage(father);

            var firstNamesPath = File.ReadAllLines(@"Extra\nameList.txt");
            _firstNameGenerator = new NameGenerator(firstNamesPath, 1, 1);

            _name = name;
            _mother = mother;
            _father = father;
            _mother.StatusInFamily = Status.MARRIED;
            _father.StatusInFamily = Status.MARRIED;

            _familyMembersList = new FamilyMemberList(this);
            _familyMembersList.Add(_mother);
            _familyMembersList.Add(_father);
            _mother.ParentFamily = this;
            _father.ParentFamily = this;

            //=> marriage pendant convocation ? ils s'enfuyent.
            _mother.ActivityStatus = _mother.ActivityStatus & ~ActivityStatus.CONVOCATED;
            _father.ActivityStatus = _father.ActivityStatus & ~ActivityStatus.CONVOCATED;
        }
예제 #2
0
파일: Game.cs 프로젝트: EmilieS/Gleipnir
        // NEW GAME
        public Game(double timeStep = 0)
        {
            // Created "windows values"
            _totalGold = new HistorizedValue<int, Game>(this, @"_totalGold", 20);
            _totalPop = new HistorizedValue<int, Game>(this, @"_totalPop", 20);
            _offerings = new HistorizedValue<int, Game>(this, @"_offerings", 20);

            // Created lists
            _items = new List<GameItem>();
            _singleMenList = new List<Villager>();
            _villagesList = new List<Village>();
            _eventList = new List<IEvent>();

            // FamilyNames Generator
            var namesPath = File.ReadAllLines(@"Extra\nameList.txt");
            _nameGenerator = new NameGenerator(namesPath, 1, 1);
            var firstNamesPath = File.ReadAllLines(@"Extra\firstNameList.txt");
            _firstNameGenerator = new NameGenerator(namesPath, 1, 1);

            // GodSpell Initialization
            _currentEpidemicList = new List<GodSpell.Epidemic>();

            // BirthDates Initialisation
            _regularBirthDates = new double[5];
            #region To Be CHANGED
            //_ageTickTime = 0.0834;//time(years) between each tick.
            _ageTickTime = 1;
            Rand = new Random();//to be moved elsewhere.

            int j = 216; // j = 18
            for (int i = 0; i < 5; i++) // Must be kept orderly
            {
                _regularBirthDates[i] = j;
                j = j + 4 * 12; // j = j + 4
            }
            #endregion

            // Create Village
            Village village = CreateVillage(@"Ragnar");

            // Create Table
            new TablePlace(village);

            // Create default jobs buildings
            Farm farm = new Farm(village, village.JobsList.Farmer);
            village.JobsList.Farmer.Building = farm;
            Forge forge = new Forge(village, village.JobsList.Blacksmith);
            village.JobsList.Blacksmith.Building = forge;
            UnionOfCrafter uoc = new UnionOfCrafter(village, village.JobsList.Construction_Worker);
            village.JobsList.Construction_Worker.Building = uoc;

            // Create 5 families
            Family FamilyA = village.CreateFamilyFromScratch(village.JobsList.Farmer, village.JobsList.Blacksmith);
            Family FamilyB = village.CreateFamilyFromScratch(village.JobsList.Farmer, village.JobsList.Construction_Worker);
            Family FamilyC = village.CreateFamilyFromScratch();
            Family FamilyD = village.CreateFamilyFromScratch();
            Family FamilyE = village.CreateFamilyFromScratch();

            // Set player's offerings
            _offerings.Current = 100;
        }