Exemplo n.º 1
0
 public PopulationUpdater(CountryController country, PopulationController population, MoneyController money, MapController map)
 {
     _country    = country;
     _population = population;
     _money      = money;
     _map        = map;
 }
Exemplo n.º 2
0
    void Start()
    {
        source             = GetComponent <AudioSource>();
        anim               = GetComponent <Animator>();
        waitTime           = startWaitTime;
        rotationCalculated = false;
        healthBar.GetComponent <Slider>().value   = health;
        immunityBar.GetComponent <Slider>().value = immunity;
        immunityBar.SetActive(true);

        populationController = gameManager.GetComponent <PopulationController>();
        pauseManagerScript   = FindObjectOfType <PauseManagerScript>();

        //setting up initial values
        minX          = -10f;
        maxX          = 10f;
        minZ          = -10f;
        maxZ          = 10f;
        startWaitTime = Random.Range(1, 5);
        moveSpot      = new Vector3(Random.Range(minX, maxX), transform.position.y, Random.Range(minZ, maxZ));

        if (isInfected)
        {
            enableInfectionForceField();
        }
        else
        {
            disableInfectionForceField();
        }
    }
Exemplo n.º 3
0
 public void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Exemplo n.º 4
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();         // for other non-HideInInspector fields
        PopulationController script = (PopulationController)target;

        script.employWorking = EditorGUILayout.Toggle("Employ Working", script.employWorking);
        if (script.employWorking)
        {
            EditorGUI.indentLevel++;
            script.idleTime = EditorGUILayout.IntField("Idle Time", script.idleTime);
            EditorGUI.indentLevel--;
        }

        script.walkingAround = EditorGUILayout.Toggle("Walking Around", script.walkingAround);
        if (script.walkingAround)
        {
            EditorGUI.indentLevel++;
            script.activeTime    = EditorGUILayout.FloatField("Active Time", script.activeTime);
            script.restTime      = EditorGUILayout.FloatField("Rest Time", script.restTime);
            script.movementSpeed = EditorGUILayout.FloatField("Movement Speed", script.movementSpeed);
            script.widthX        = EditorGUILayout.FloatField("Width X", script.widthX);
            script.widthY        = EditorGUILayout.FloatField("Width Y", script.widthY);
            script.widthZ        = EditorGUILayout.FloatField("Width Z", script.widthZ);
            EditorGUI.indentLevel--;
        }
    }
Exemplo n.º 5
0
    void Start()
    {
        populationController = GameObject.Find("PopulationController").GetComponent(typeof(PopulationController)) as PopulationController;
        populationController.ChangePopulation(populationValue);

        navMeshAgent = gameObject.GetComponent(typeof(NavMeshAgent)) as NavMeshAgent;

        InhabitAFreeHouse();
    }
Exemplo n.º 6
0
    public override void OnPlace(Tile[] parentTiles)
    {
        base.OnPlace(parentTiles);

        UpdateHouseLevel();

        populationController = GameObject.Find("PopulationController").GetComponent(typeof(PopulationController)) as PopulationController;
        populationController.ChangeMaxPopulation(maxSupportedHabitants);
    }
Exemplo n.º 7
0
 public void RegisterUpgradeSignal(PopulationController population)
 {
     int upgradeCost = population.GetUpgradeCost();
     if(population.GetUpgradeCost() <= energy) {
         population.Upgrade();
         SetEnergy(energy - upgradeCost);
     } else {
         Debug.Log("Not enough energy to upgrade.");
     }
 }
 // Use this for initialization
 void Start()
 {
     killed    = false;
     direction = endPosition - startingPosition;
     direction.Normalize();
     this.transform.position = startingPosition;
     popController           = PopulationController.instance;
     buildingController      = BuildingController.instance;
     SetRandomLightingStrikeTimer();
 }
Exemplo n.º 9
0
    void Start()
    {
        popCon = GetComponent <PopulationController>();

        popCon.populationSize = Mathf.FloorToInt(populationSizeSlider.value);
        popCon.genomLength    = Mathf.FloorToInt(genomLengthSlider.value);
        popCon.cutoff         = CutoffSlider.value;
        popCon.mutationRate   = MutationRateSlider.value;
        popCon.survivorKeep   = Mathf.FloorToInt(surviovrsKeepSlider.value);
    }
Exemplo n.º 10
0
    public void BuildPopulation()
    {
        creatureReferences = new GameObject[populationSize];
        for (int i = 0; i < populationSize; i++)
        {
            creatureReferences[i] = Instantiate(creatureTemplate);
        }

        pop = new PopulationController(populationSize, creatureReferences, lifeSpan, brain, speed, angle, rayLength, inititalX, initialY, NumberOfProbes, walls, food);
    }
Exemplo n.º 11
0
 public float RegisterFoodRequest(PopulationController popController, float foodAmt)
 {
     int foodChainRank = popController.foodChainRank;
     // if lowest on food chain, give free food
     if(foodChainRank == 0) {
         return foodAmt;
     } else {
         return populationControllers[foodChainRank-1].TakeFood(foodAmt);
     }
 }
    public override void OnInspectorGUI()
    {
        // base.OnInspectorGUI();

        serializedObject.Update();

        PopulationController popController = (PopulationController)target;



        if (GUILayout.Button("Kill All Agents"))
        {
            popController.KillAll();
        }
        GUILayout.Space(20);



        popController.reproductionMethod = (PopulationController.ReproductionMethod)EditorGUILayout.EnumPopup(new GUIContent("Reproduction Method", "This is the method used when transitioning to the next generation of agents.\nSexual: The top two most fit agents will have their weights mixed in various ways in order to create the next generation of agents.\nASexual: The weights from the best performing agent will be copied to all other agents and then they will all be mutated by the specified amount to get genetic diversity"), popController.reproductionMethod);

        EditorGUI.BeginChangeCheck();

        EditorGUILayout.PropertyField(neuronsPerLayer, true);

        GUILayout.Space(20);

        popController.mutationType = (PopulationController.MutationType)EditorGUILayout.EnumPopup(new GUIContent("Mutation Type: ", "Entire network means that the specified number of weights can be mutated from anywhere in the network.\nCustom range means that only weights within the specified range will be mutated"), popController.mutationType);
        if (popController.mutationType == PopulationController.MutationType.CustomRange)
        {
            //Custom mutate options
            EditorGUILayout.LabelField("Custom Mutation Range");
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(minLayer, true);
            EditorGUILayout.PropertyField(maxLayer, true);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(minNeuron, true);
            EditorGUILayout.PropertyField(maxNeuron, true);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(minConnection, true);
            EditorGUILayout.PropertyField(maxConnection, true);
            EditorGUILayout.EndHorizontal();
        }


        GUILayout.Label(new GUIContent("Mutation  Rate:", "This is how many genes should be mutated each time the agents reproduce"));
        mutationRate.intValue = EditorGUILayout.IntSlider(mutationRate.intValue, 1, 999);

        //Applies all changes to variables
        serializedObject.ApplyModifiedProperties();
    }
Exemplo n.º 13
0
 public Population(PopulationController populationController,
                   OrganismFactory organismFactory,
                   int initCount)
 {
     this.populationController = populationController;
     this.organismFactory = organismFactory;
     AddOrganisms(initCount);
     InitParams();
     // subscribe self to organism death messages
     SubscribeDeath(HandleDeath);
 }
Exemplo n.º 14
0
 public ArmyInterface(
     CountryController country, PopulationController population, ArmyController army,
     InputController input, OutputController output, ContextController context
     )
 {
     _country    = country;
     _population = population;
     _army       = army;
     _input      = input;
     _out        = output;
     _context    = context;
 }
Exemplo n.º 15
0
    private void Start()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(instance);
        }

        generationCount          = 1;
        generationCountText.text = "Generation: " + generationCount.ToString();

        FirstGeneration();
    }
    // Use this for initialization
    void Start()
    {
        killed    = false;
        direction = endPosition - startingPosition;
        direction.Normalize();
        this.transform.position = startingPosition;
        smokeParticleSys        = transform.GetChild(0).GetComponent <ParticleSystem>();
        popController           = FindObjectOfType <PopulationController>();

        if (direction.x < 0)
        {
            Vector3 temp = transform.localScale;
            temp.x = -temp.x;
            transform.localScale = temp;
        }
    }
Exemplo n.º 17
0
    public void BuildPopulation()
    {
        creatureReferences = new GameObject[populationSize];
        for (int i = 0; i < populationSize; i++)
        {
            creatureReferences[i] = Instantiate(creatureTemplate);
        }
        lineRenderers = new GameObject[populationSize * NumberOfProbes];
        for (int i = 0; i < populationSize * NumberOfProbes; i++)
        {
            lineRenderers[i] = Instantiate(lineRendererReference);
        }

        SetRenderLayerOrderToBLUR();

        pop = new PopulationController(populationSize, creatureReferences, lifeSpan, brain, speed, angle, rayLength, inititalX, initialY, NumberOfProbes, walls, food);
        pop.SetCreatureSortingLayer("ThingsOnTopOfBackground");
    }
Exemplo n.º 18
0
    public void Init(PopulationController parentPopulation, GameInfo.PopulationStat populationStat)
    {
        this.parentPopulation = parentPopulation;
        this.stats            = populationStat.stats;
        SphereCollider agroCollider = GetComponentInChildren <SphereCollider>();

        aiDestinationSetter = GetComponent <AIDestinationSetter>();
        aIPath = GetComponent <AIPath>();

        //set the base stats of the individual from its population stats
        aIPath.maxSpeed     = stats[(int)GameInfo.PopulationStat.stat.speed] * 2f + 15f;
        agroCollider.radius = stats[(int)GameInfo.PopulationStat.stat.vision] * 2 + 10;
        timeLeft           += stats[(int)GameInfo.PopulationStat.stat.endurance] * 1.5f;

        newTarget = new GameObject().transform;
        target    = generatePosition();
        aiDestinationSetter.target = target;
        aIPath.SearchPath();
    }
Exemplo n.º 19
0
    public override void OnPlace(Tile[] parentTiles)
    {
        base.OnPlace(parentTiles);

        unitsController = GameObject.Find("UnitsController").GetComponent <UnitsController>();

        UpdateBuildingModel();
        populationController = GameObject.Find("PopulationController").GetComponent(typeof(PopulationController)) as PopulationController;
        populationController.ChangeTotalNumberOfJobs(tileProperties.buildingProperties.workersRequired);

        UpdateRoadAccess();
        CheckForWorkers();

        if ((hasRoadAccess || !tileProperties.buildingProperties.requiresRoadAccess) && foundWorkers)
        {
            ChangeRunningValue(true);
        }
        else
        {
            StartCoroutine("WaitForRoadAccessAndWorkers");
        }
    }
 // Use this for initialization
 void Start()
 {
     popCounter = FindObjectOfType <PopulationController>();
     popCounter.IncreasePopulationSize(maxPeopleInTheHouse);
 }
Exemplo n.º 21
0
 private void Awake()
 {
     Instance = this;
 }
Exemplo n.º 22
0
 public void Start()
 {
     pc = GameObject.FindGameObjectWithTag("PopulationController").GetComponent <PopulationController>();
 }
Exemplo n.º 23
0
 public PopulationSave(PopulationController pc)
 {
     Working = pc.Working;
     Proles  = pc.Proles;
 }
Exemplo n.º 24
0
    //contacts the population controller and returns the count of game objects with that tag.
    public int CountPop(GameObject controller, string tag)
    {
        PopulationController popController = controller.GetComponent(typeof(PopulationController)) as PopulationController;

        return(popController.GetPops()[tag]);
    }