Esempio n. 1
0
        //Create grid
        private Color32[,] createGrid()
        {
            //Read from file
            //build grid
            Texture2D map = Resources.Load <Texture2D>("Maps/BiggerMap");

            dim = map.height;
            Color32[] pixels = map.GetPixels32();

            Color32[,] trueGrid = new Color32[dim, dim];

            //getpixels goes from bottom to top and left to right
            //our spatial reasoning is from top to bottom and from left to right
            for (int i = 0; i < pixels.Length; i++)
            {
                int column = i % dim;
                int row    = dim - (i / dim) - 1;
                trueGrid[column, row] = pixels[i];
            }

            GameObject floorPrefab     = Resources.Load <GameObject>("Prefabs/Floor");
            var        floorGameObject = Instantiate(floorPrefab);

            fGrid = floorGameObject.GetComponent <FloorGrid>();
            floorGameObject.GetComponent <FloorGrid>().grid = trueGrid;
            return(trueGrid);
        }
        //TODO observe grid
        public void ObserveGrid(int x, int y, CentralFloor floor /* extra params for fear */)
        {
            int       r     = 0; //ViewRadius
            FloorGrid eGrid = floor.Grid;
            //Potentially simplify --> Observe a square


            //Get the grid from the centralfloor
            //Observe everything in a certain radius, while not going through walls
            //flood fill to a certain eucledian distance? --> allows the agent to look around corners
            //Square of width and height 2r, collision check for each squah (expensive??)
            //Create a spiral that either observes/does not observe if it hits a wall
            //Smoke decreases this radius
            //Panic decreases this radius

            //TODO: colision detection (walls) --> talk about this with timon
            //If a door is found --> perform collision detection for walls AND objects
        }