public void Init(cellScript cell)
    {
        base.Init();
        segController = GameObject.FindObjectOfType <SegregationController>();

        currentCell             = cell;
        this.transform.position = cell.transform.position;
        currentCell.isOccupied  = true;
        currentCell.occupier    = this;

        this.transform.localScale = Vector3.one * segController.cellSizeInGameWorld;

        agentType = SegregationUtilities.agentType.RED;
        // if(Random.Range(0f,1.0f) < 0.5f){
        if (segController.rand.NextDouble() < 0.5f)
        {
            agentType = SegregationUtilities.agentType.GREEN;
        }

        if (agentType == SegregationUtilities.agentType.RED)
        {
            GetComponent <Renderer>().material.color = Color.red;
        }
        else
        {
            GetComponent <Renderer>().material.color = Color.green;
        }

        CreateStepper(FindNeighbours, 2, 100);
        CreateStepper(CheckNeighbourhoodIsOK, 2, 200);
        CreateStepper(Move, 2, 300, 1);
    }
Пример #2
0
    public void GetCellNeighbours(SegregationController segController)
    {
        Collider[] others = Physics.OverlapBox(this.transform.transform.position, Vector3.one * segController.cellSizeInGameWorld, Quaternion.identity, segController.cellLm);

        List <cellScript> ns = new List <cellScript>();

        foreach (Collider other in others)
        {
            if (other.gameObject != this.gameObject)
            {
                ns.Add(other.GetComponent <cellScript>());
            }
        }
        neighbours = ns.ToArray();
    }