Example #1
0
        void Start()
        {
            startingPos = Vector3.zero;

            // get grid component.
            grid = gridGO.GetComponent <CustomGrid>();

            // get ship manager.
            if (ship.GetComponent <Ship>() != null)
            {
                shipManager = ship.GetComponent <Ship>();
            }
            else
            {
                Debug.LogError("Ship (script) component is missing on GO: " + this.name);
            }

            // get number of tiles.
            numberOfNodes = grid.GetGridSize;

            // set starting position.
            Vector3 gridTopLeft = new Vector3(-grid.GetGridSizeX / 2, grid.GetGridSizeY / 2, startingPos.z);

            startingPos = gridTopLeft;

            // set impassable tiles.
            CalculateImpassable();

            // start generating tiles.
            GenerateTiles();

            // align it with the ship.
            //this.transform.localPosition = ship.transform.position + grid.GetGridOffset;
            this.transform.localPosition = ship.transform.position;
        }
Example #2
0
        private void Start()
        {
            // set this grid's ship
            ship = GetComponentInParent <Ship>();
            // get grid from ship
            grid = ship.pathGrid;

            thisTransform = this.transform;
        }