// Update is called once per frame void Update() { if (prevselect) { prevselect.SpriteDeSelect(); } RaycastHit hit; int x, y; x = 0; y = 0; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit2D hitInformation = Physics2D.GetRayIntersection(ray, 10); SpriteSelection select = null; if (hitInformation) { x = System.Convert.ToInt32(hitInformation.transform.position.x); y = System.Convert.ToInt32(hitInformation.transform.position.y); if (hitInformation.transform.tag == "Tile") { select = boardScript.CurrentMapTiled[x][y].prefab.GetComponent <SpriteSelection>(); select.SpriteSelect(); } } prevselect = select; }
protected void MapAvailibleTiles(int x, int y, int move, int moved, bool color) { SpriteSelection select = navigator.CurrentMapTiled[x][y].prefab.GetComponent <SpriteSelection>(); if (color) { select.SpriteSelect(); } else { select.SpriteDeSelect(); } if (moved < move) { for (int i = 0; i <= 3; i++) { switch (i) { case 0: //вверх if (y != 0) { if (navigator.CurrentMapTiled[x][y - 1].ifTaken != 1 && !(navigator.CurrentMapTiled[x][y - 1] is ObjectTile)) { MapAvailibleTiles(x, y - 1, move, moved + 1, color); } } break; case 1: //вправо if (x != navigator.CurrentMapTiled[x].Length) { if (navigator.CurrentMapTiled[x + 1][y].ifTaken != 1 && !(navigator.CurrentMapTiled[x + 1][y] is ObjectTile)) { MapAvailibleTiles(x + 1, y, move, moved + 1, color); } } break; case 2: //вниз if (y != navigator.CurrentMapTiled.Length) { if (navigator.CurrentMapTiled[x][y + 1].ifTaken != 1 && !(navigator.CurrentMapTiled[x][y + 1] is ObjectTile)) { MapAvailibleTiles(x, y + 1, move, moved + 1, color); } } break; case 3: //влево if (x != 0) { if (navigator.CurrentMapTiled[x - 1][y].ifTaken != 1 && !(navigator.CurrentMapTiled[x - 1][y] is ObjectTile)) { MapAvailibleTiles(x - 1, y, move, moved + 1, color); } } break; } } } }