public void ShowTilesThatInTrapRange(int startX, int startY) { Vector3 ret = new Vector3(); Vector3 retTarget = new Vector3(); ret.y = startY; ret.z = startX - (startY - (Mathf.Abs(startY) % 2)) / 2; ret.x = -ret.y - ret.z; GameObject[] ClickableTiles = GameObject.FindGameObjectsWithTag("Hex"); foreach (GameObject v in ClickableTiles) { ClickableTile clickableTile = v.GetComponent <ClickableTile> (); retTarget.y = clickableTile.tileY; retTarget.z = clickableTile.tileX - (clickableTile.tileY - (Mathf.Abs(clickableTile.tileY) % 2)) / 2; retTarget.x = -retTarget.y - retTarget.z; int d = (int)((Mathf.Abs(ret.x - retTarget.x) + Mathf.Abs(ret.y - retTarget.y) + Mathf.Abs(ret.z - retTarget.z)) / 2); if (d <= skillRange && clickableTile.hexVisible && map.UnitCanEnterTile(clickableTile.tileX, clickableTile.tileY) == true && d != 0) { Material[] mat = clickableTile.GetComponent <Renderer>().materials; mat[1] = hoverMaterialAllowed; clickableTile.GetComponent <Renderer>().materials = mat; clickableTile.rangeTargetted = true; clickableTile.canAttack = true; clickableTile.willTakeHit = false; // tileX = clickableTile.tileX; // tileY = clickableTile.tileY; } else { clickableTile.rangeTargetted = false; } } }
///<summary> /// Sets tile visible with colorfader enabled ///</summary> private void HighlightTile(int x, int y) { GameObject t = GameObject.Find("Tile" + x + "-" + y); ClickableTile ct = t.GetComponent<ClickableTile>(); ct.Enabled = true; ct.GetComponent<Renderer>().enabled = true; ct.GetComponent<ColorFader>().IsEnabled = true; }
public void ShowTilesThatCanBeHit() { GameObject Tile = GameObject.Find("Hex_" + tileX + "_" + tileY); ClickableTile tile = Tile.GetComponent <ClickableTile>(); Material[] mat = tile.GetComponent <Renderer>().materials; mat[1] = hoverMaterialAllowed; tile.GetComponent <Renderer>().materials = mat; tile.willTakeHit = false; }
public void ShowTilesThatWillBeHitSkill() { GameObject Tile = GameObject.Find("Hex_" + tileX + "_" + tileY); ClickableTile tile = Tile.GetComponent <ClickableTile>(); Material[] mat = tile.GetComponent <Renderer>().materials; mat[1] = materialWillBeHit; tile.GetComponent <Renderer>().materials = mat; tile.willTakeHit = true; }
public void HideAllAllowedTiles() { GameObject[] ClickableTiles = GameObject.FindGameObjectsWithTag("Hex"); foreach (GameObject v in ClickableTiles) { ClickableTile clickableTile = v.GetComponent <ClickableTile> (); Material[] mat = clickableTile.GetComponent <Renderer>().materials; mat[1] = clickableTile.primaryMaterial; clickableTile.GetComponent <Renderer>().materials = mat; clickableTile.willTakeHit = false; } }
public void ShowHoveringTileSkill() { GameObject Tile = GameObject.Find("Hex_" + tileX + "_" + tileY); ClickableTile tile = Tile.GetComponent <ClickableTile>(); if (tile.rangeTargetted) { Material[] mat = tile.GetComponent <Renderer>().materials; mat[1] = hoverMaterialMouseTileAffected; tile.GetComponent <Renderer>().materials = mat; tile.willTakeHit = false; } }
public void ShowTilesThatWillNotBeHitSkill() { GameObject Tile = GameObject.Find("Hex_" + tileX + "_" + tileY); ClickableTile tile = Tile.GetComponent <ClickableTile>(); if (tile.rangeTargetted) { Material[] mat = tile.GetComponent <Renderer>().materials; mat[1] = hoverMaterialMouseInRangeNotAllowed; tile.GetComponent <Renderer>().materials = mat; tile.willTakeHit = false; // tile.lineTargetted = true; } }
public void ColorTargettedTiles() { GameObject[] Tiles = GameObject.FindGameObjectsWithTag("Hex"); foreach (GameObject Tile in Tiles) { ClickableTile tile = Tile.GetComponent <ClickableTile> (); if (tile.rangeTargetted) { Material[] mat = tile.GetComponent <Renderer>().materials; mat[1] = hoverMaterialAllowed; tile.GetComponent <Renderer>().materials = mat; tile.willTakeHit = false; } } }
public void CheckEnemiesInSkillRange() { GameObject[] Enemies = GameObject.FindGameObjectsWithTag("Enemy"); foreach (GameObject Enemy in Enemies) { BaseEnemy enemy = Enemy.GetComponent <BaseEnemy> (); if (enemy.TileX == tileX && enemy.TileY == tileY) { GameObject Tile = GameObject.Find("Hex_" + tileX + "_" + tileY); ClickableTile tile = Tile.GetComponent <ClickableTile>(); Material[] mat = tile.GetComponent <Renderer>().materials; mat[1] = hoverMaterialAllowed; tile.GetComponent <Renderer>().materials = mat; tile.canAttack = true; tile.willTakeHit = false; } } }
public void LoadTile(ClickableTile tile, int dist, Unit unit) { frame.sprite = frameHalf; shade.sprite = shadeHalf; tileIcon.sprite = tile.GetComponent <SpriteRenderer>().sprite; tileIcon.color = tile.GetComponent <SpriteRenderer>().color; if (!isInRightCorner && !isSliding) { rect.anchoredPosition = new Vector2(-40, 8); } tileType.text = tile.tileType; //tileType.outlineWidth = 10.2f; //tileType.outlineColor = new Color32(255, 128, 255, 255); terrainCost.text = tile.movementCost.ToString(); if (dist > unit.currentMovement || dist < 0) { distanceToActiveUnit.color = Color.red; } else { distanceToActiveUnit.color = Color.white; } if (dist > 1000 || dist < 0) { distanceToActiveUnit.text = "inf"; } else { distanceToActiveUnit.text = dist.ToString(); } gameObject.SetActive(true); if (tile.occupyingUnit != null) { LoadUnit(tile.occupyingUnit); return; } unitTooltip.SetActive(false); }
private void DeselectTile(ClickableTile tile) { if (tile == null) { return; } tile.movable = false; tile.GetComponent <Image>().color = Color.white; }
public void CheckPlayersInSkillRange() { GameObject[] Players = GameObject.FindGameObjectsWithTag("Player"); foreach (GameObject Player in Players) { PlayableCharacter player = Player.GetComponent <PlayableCharacter> (); if (player.PlayerClass.TileX == tileX && player.PlayerClass.TileY == tileY) { GameObject Tile = GameObject.Find("Hex_" + tileX + "_" + tileY); ClickableTile tile = Tile.GetComponent <ClickableTile>(); Material[] mat = tile.GetComponent <Renderer>().materials; mat[1] = hoverMaterialAllowed; tile.GetComponent <Renderer>().materials = mat; tile.canAttack = true; tile.willTakeHit = false; // player.isSelected = true; } } }
public void ShowTilesThatInRangeGeneral(int startX, int startY) { Vector3 ret = new Vector3(); Vector3 retTarget = new Vector3(); ret.y = startY; ret.z = startX - (startY - (Mathf.Abs(startY) % 2)) / 2; ret.x = -ret.y - ret.z; GameObject[] ClickableTiles = GameObject.FindGameObjectsWithTag("Hex"); foreach (GameObject v in ClickableTiles) { ClickableTile clickableTile = v.GetComponent <ClickableTile> (); retTarget.y = clickableTile.tileY; retTarget.z = clickableTile.tileX - (clickableTile.tileY - (Mathf.Abs(clickableTile.tileY) % 2)) / 2; retTarget.x = -retTarget.y - retTarget.z; int d = (int)((Mathf.Abs(ret.x - retTarget.x) + Mathf.Abs(ret.y - retTarget.y) + Mathf.Abs(ret.z - retTarget.z)) / 2); if (d <= skillRange && clickableTile.hexVisible) { Material[] mat = clickableTile.GetComponent <Renderer>().materials; mat[1] = showMaterialInRange; clickableTile.GetComponent <Renderer>().materials = mat; // clickableTile.isInrange = true; clickableTile.rangeTargetted = true; tileX = clickableTile.tileX; tileY = clickableTile.tileY; if (clickableTile.enemyTarget) { CheckEnemiesInSkillRange(); } else { CheckPlayersInSkillRange(); } } else { // clickableTile.isInrange = false; clickableTile.rangeTargetted = false; } } }
private void SelectTile(ClickableTile tile) { if (tile == null) { return; } if (tile.isEmpty()) { tile.movable = true; tile.GetComponent <Image>().color = Color.cyan; } }
///<summary> /// Used to generate (invisible) tiles that the user can click & used in pathfinding ///</summary> private void GenerateMapVisual() { for (int x = 0; x < mapSizeX; x++) { for (int y = 0; y < mapSizeY; y++) { TileType tt = tileTypes[ (int)tiles[x,y] ]; GameObject go = (GameObject)Instantiate( tt.InvisiblePrefab, new Vector3(x, 0, y), Quaternion.identity ); ClickableTile ct = go.GetComponent<ClickableTile>(); ct.TileX = x; ct.TileY = y; ct.Map = this; ct.transform.parent = GameObject.Find("GameBoard").transform; ct.transform.name = "Tile" + x + "-" + y; ct.GetComponent<Renderer>().enabled = false; //debug == true } } }
// Use this for initialization void Start() { tileX = groundTile.GetComponent <ClickableTile>().tileX; tileY = groundTile.GetComponent <ClickableTile>().tileY; }
public void ShowAllowedTilesMovement() { // Debug.Log("test"); // GameObject Unit = GameObject.Find (selectedCharacter); GameObject Player = GameObject.Find(map.selecterPlayer); PlayableCharacter player = Player.GetComponent <PlayableCharacter> (); Vector3 ret = new Vector3(); Vector3 retTarget = new Vector3(); ret.y = player.PlayerClass.TileY; ret.z = player.PlayerClass.TileX - (player.PlayerClass.TileY - (Mathf.Abs(player.PlayerClass.TileY) % 2)) / 2; ret.x = -ret.y - ret.z; GameObject[] ClickableTiles = GameObject.FindGameObjectsWithTag("Hex"); // foreach (Node v in graph) { foreach (GameObject v in ClickableTiles) { ClickableTile clickableTile = v.GetComponent <ClickableTile> (); // int targetX = (int)clickableTile.worldPos.x; // int targetY = (int)clickableTile.worldPos.y; // int targetZ = (int)clickableTile.worldPos.z; retTarget.y = clickableTile.tileY; retTarget.z = clickableTile.tileX - (clickableTile.tileY - (Mathf.Abs(clickableTile.tileY) % 2)) / 2; retTarget.x = -retTarget.y - retTarget.z; if (clickableTile.hexVisible) { } player.PlayerClass.Distance = (int)((Mathf.Abs(ret.x - retTarget.x) + Mathf.Abs(ret.y - retTarget.y) + Mathf.Abs(ret.z - retTarget.z)) / 2); // Debug.Log(unit.distance); // string currentTile = "Hex_" + v.x + "_" + v.y; // bool clicableTile = GameObject.Find (currentTile).GetComponent<ClickableTile> ().isNotWalkable; bool clicableTileWalkable = clickableTile.isWalkable; // Debug.Log("test"); // if(unit.distance <= unit.moveSpeed && UnitCanEnterTile(v.x, v.y) == true && !clicableTile){ // if(currentPathCount <= unit.remainingMovement + 1 && UnitCanEnterTile(clickableTile.tileX, clickableTile.tileY) == true && !clicableTile && currentPath != null && clickableTile.hexVisible){ // if(unit.distance <= unit.moveSpeed && UnitCanEnterTile(clickableTile.tileX, clickableTile.tileY) == true && !clicableTile && currentPath != null && clickableTile.hexVisible){ if (player.PlayerClass.Distance <= player.PlayerClass.RemainingMovement && map.UnitCanEnterTile(clickableTile.tileX, clickableTile.tileY) == true && clicableTileWalkable && clickableTile.hexVisible) { map.GeneratePathToPlayer(clickableTile.tileX, clickableTile.tileY); // if (map.currentPathCount <= player.PlayerClass.RemainingMovement + 1 && map.pathCost <= player.PlayerClass.RemainingMovement) { if (map.pathCost <= player.PlayerClass.RemainingMovement) { Material[] mat = clickableTile.GetComponent <Renderer>().materials; mat[1] = hoverMaterialAllowed; clickableTile.GetComponent <Renderer>().materials = mat; clickableTile.rangeTargetted = true; clickableTile.willTakeHit = false; } else { clickableTile.rangeTargetted = false; } } else { clickableTile.rangeTargetted = false; } } player.currentPath = null; }