Exemple #1
0
        public void InitTile(int x, int y, Vector3 position, LayerMask layer, LayerMask obstacles)
        {
            X = x;
            Y = y;
            //g = new GameObject("Tile"+X+","+Y);
            //g.AddComponent<Tile>();
            transform.position = position;
            gameObject.AddComponent <BoxCollider2D>();
            gameObject.layer = GameGrid.layermask_to_layer(layer);

            isWalkable = !Physics2D.OverlapPoint(position, obstacles);
        }
        // Start is called before the first frame update
        void Start()
        {
            grid = GetComponentInChildren <GameGrid>();

            unitList.AddRange(GameObject.FindObjectsOfType <Unit>());

            seeker = GetComponent <Seeker>();

            foreach (Unit u in unitList)
            {
                UpdateUnitGridPosition(u);
            }
        }