Пример #1
0
    //////////////////////////// GOAL SHAPE //////////////////////////

    // SetGoalShape: Sets Goal Cells according to the given list of Positions
    public void SetGoalShape(IEnumerable <Vector3> listPositions)
    {
        for (int i = 0; i < listPositions.Count(); i++)
        {
            Vector3 point = listPositions.ElementAt(i);

            if (!CM.OutsideBoundaries(point, AreaMin, AreaMax))
            {
                Vector3Int location = grid.GetCellLocation(point);

                Cell currentCell = grid.GetCell(location);
                currentCell.GoalCell = true;
            }
        }
    }
Пример #2
0
    ////////////////////////////   MOVEMENTS  ////////////////////////////

    // INDIVIDUAL MOVE
    // ModuleRotation: Rotate a module around a pivot module
    private void ModuleRotation(Agent agent, Agent pivot, Vector3 rotationAxis, float angle)
    {
        Cell currentCell = agent.Cell;

        agent.Obj.transform.RotateAround(pivot.Obj.transform.position, rotationAxis, angle);
        pivot.Obj.transform.RotateAround(pivot.Obj.transform.position, rotationAxis, angle);

        Cell newCell = grid.GetCell(grid.GetCellLocation(agent.Obj.transform.position));

        agent.Cell = newCell;

        currentCell.Alive = false;
        currentCell.agent = null;

        newCell.Alive = true;
        newCell.agent = agent;
    }
Пример #3
0
    // PlaceAgentsInGivenGeometry: Places the agents in a given list of points that forms a 3D shape (only for points inside the lattice)
    public Agent[] PlaceAgentsInGivenGeometry(IEnumerable <Vector3> listPositions)
    {
        for (int i = 0; i < NumberOfAgents; i++)    // CHECK EXCEPTION: NumAgents != listPositions.Count()
        {
            Vector3Int cellLocation = _grid.GetCellLocation(listPositions.ElementAt(i));

            Cell currentCell = _grid.GetCell(cellLocation);
            currentCell.Alive     = true;
            currentCell.Occupancy = CellOccupancy.Occupied;

            Agent newAgent = new Agent(agent, material, physicsMaterial, currentCell.Center, i);
            currentCell.agent = newAgent;
            newAgent.Cell     = currentCell;

            listAgents[i] = newAgent;
        }
        return(listAgents);
    }