void SpawnTraveler()
    {
        if (BlobVisible)
        {
            return;
        }

        Debug.Assert(LinkedCities.Length > 0, this.Name + " has no linked cities.");

        GameObject t = (GameObject)Instantiate(CitizenPrefab, CityPosition, Quaternion.identity);

        CitizenController c = t.GetComponent <CitizenController>();

        Debug.Assert(c, "CitizenController not found for " + this.Name + "'s citizen prefab.");



        CityController Destination = ChooseDestination();

        if (c)
        {
            c.SetHome(this);
            c.SetDestination(Destination);
        }

        CountTravelerOut(Destination);

        c.Knowledge.TravelersSent = TravelersSent[Destination.Name];
        c.Knowledge.OriginThreat  = Threat;
    }
    private void GenerateOccupants()
    {
        int occupantCount = Random.Range(minOccupantCount, maxOccupantCount + 1);

        for (int i = 0; i < occupantCount; i++)
        {
            //change size and color
            GameObject newOccupant = Instantiate(occupantPrefab, house.position, Quaternion.identity);
            newOccupant.transform.localScale = transform.localScale;
            newOccupant.transform.GetChild(0).GetComponent <MeshRenderer>().material.color             = house.color.color;
            newOccupant.transform.GetChild(1).GetChild(0).GetComponent <MeshRenderer>().material.color = house.color.color;
            newOccupant.transform.GetChild(2).GetChild(0).GetComponent <MeshRenderer>().material.color = house.color.color;
            CitizenController citizenControl = newOccupant.GetComponent <CitizenController>();
            citizenControl.myHouse = this;
            citizenControl.Initialize();
        }
    }
    public void AddNewPopulation()
    {
        //maxに達しているか
        if (model.citizens.Count >= GameManager.Instance.gameModel.maxPopulation)
        {
            return;
        }

        //十分な余剰食糧があるか



        GameObject        citizenGameObject = Instantiate(citizenPrefab) as GameObject;
        CitizenController citizen           = citizenGameObject.GetComponent <CitizenController>();

        citizen.Init();
        citizen.transform.SetParent(getRow(), false);
        model.citizens.Add(citizen);
    }
        public async void GetCitizens_Returns_List_Of_Citizens()
        {
            var connection = new SqliteConnection("DataSource=:memory:");
            await connection.OpenAsync();

            var options = new DbContextOptionsBuilder <RCCSContext>()
                          .UseSqlite(connection)
                          .Options;


            using (var context = new RCCSContext(options))
            {
                context.Database.EnsureCreated();

                context.Citizens.AddRange(
                    new Citizen
                {
                    FirstName = "Jens",
                    LastName  = "Jensen",
                    CPR       = 2020201987
                },
                    new Citizen
                {
                    FirstName = "Anker",
                    LastName  = "Sørensen",
                    CPR       = 2121211947
                });

                context.SaveChanges();
            }

            using (var context = new RCCSContext(options))
            {
                var citizenController = new CitizenController(context);

                var citizenList = await citizenController.GetCitizens();

                Assert.NotNull(citizenList);
                var actionResult = Assert.IsType <ActionResult <List <Citizen> > >(citizenList);
                var returnValue  = Assert.IsAssignableFrom <IEnumerable <Citizen> >(actionResult.Value);
            }
        }
Beispiel #5
0
    void CitizenSeen(GameObject Friend)
    {
        CitizenController citizen = Friend.GetComponent <CitizenController>();

        if (citizen == null)
        {
            return;
        }

        // Check to see if the citizen is fleeing!
        if (Knowledge.DestinationCity != citizen.Knowledge.DestinationCity)
        {
            return;
        }

        if (citizen.Knowledge.TravelerPanicked)
        {
            Panic();
        }
    }