Exemplo n.º 1
0
    void Awake()
    {
        Neighbors           = new GridNeighbors(this);
        _gridParams         = new PlayerParams();
        _unitsMovingThrough = new List <UnitController>();
        _bC = GetComponent <BoxCollider2D>();
        var textObj = GameObject.FindGameObjectWithTag("test");

        text = textObj.GetComponent <TextMeshProUGUI>();
    }
Exemplo n.º 2
0
        public static Plane Init(string input, GridNeighbors <Seat> neighbors)
        {
            var chars = input.CharPixels();
            var plane = new Plane(chars.Cols, chars.Rows);
            var seats = chars.Where(p => p.Value == 'L').Select(p => p.Key);

            plane.InitTiles(
                locations: seats,
                ctor: (id, location) => new Seat(id, location),
                neighbors: neighbors);
            return(plane);
        }
Exemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        actions    = new Stack <ARAstarAction>();
        outputPlan = new Dictionary <DefaultState, ARAstarNode>();

        domainList = new List <PlanningDomainBase>();
        domainList.Add(new ARAstarDomain());

        planner = new ARAstarPlanner();
        planner.init(ref domainList, 100);
        planner.usingHeap = usingHeap;

        startState    = new ARAstarState(startObject.transform.position);
        goalState     = new ARAstarState(goalObject.transform.position);
        prevGoalState = goalState;
        DStartState   = startState as DefaultState;
        DGoalState    = goalState as DefaultState;
        neighborMap   = new GridNeighbors();
    }
Exemplo n.º 4
0
        /// <summary>Initializes tiles for a grid.</summary>
        /// <typeparam name="T">
        /// The type of tile.
        /// </typeparam>
        /// <param name="grid">
        /// The grid to initialize tiles for.
        /// </param>
        /// <param name="locations">
        /// The locations to initialize.
        /// </param>
        /// <param name="ctor">
        /// The constructor to create the tiles with.
        /// </param>
        /// <param name="neighbors">
        /// The function to determine the neighbors.
        /// </param>
        public static void InitTiles <T>(
            this Grid <T> grid,
            IEnumerable <Point> locations,
            GridTileCtor <T> ctor,
            GridNeighbors <T> neighbors) where T : GridTile <T>
        {
            Guard.NotNull(grid, nameof(grid));
            Guard.NotNull(locations, nameof(locations));
            Guard.NotNull(ctor, nameof(ctor));
            Guard.NotNull(neighbors, nameof(neighbors));

            int id = 0;

            foreach (var location in locations)
            {
                grid[location] = ctor(id++, location);
            }
            foreach (var tile in grid.Tiles)
            {
                tile.Neighbors.AddRange(neighbors(grid, tile.Location).Select(loc => grid[loc]).Where(n => n is not null));
            }
        }