static public void SwapAssociatedTiles(HiddenTileBehavior tileBack, HiddenTileBehavior otherTileBack) { // swap associated tiles GameObject tmp = tileBack.tileAssociated; tileBack.tileAssociated = otherTileBack.tileAssociated; otherTileBack.tileAssociated = tmp; TileBehavior tile = tileBack.tileAssociated.GetComponent <TileBehavior>(); TileBehavior otherTile = otherTileBack.tileAssociated.GetComponent <TileBehavior>(); // swap tiles positions Vector3 tempPos = tile.transform.position; tile.transform.position = otherTile.transform.position; otherTile.transform.position = tempPos; // swap tiles indices int tmpIndex = tile.index; tile.index = otherTile.index; otherTile.index = tmpIndex; // finally update cells and swap rotation int rotation = tile.tileRotation; int otherRotation = otherTile.tileRotation; tile.GetComponent <TileBehaviorIHM>().goToDesiredOrientation(0); otherTile.GetComponent <TileBehaviorIHM>().goToDesiredOrientation(0); tile.updateTileCells(); otherTile.updateTileCells(); tile.GetComponent <TileBehaviorIHM>().goToDesiredOrientation(otherRotation); otherTile.GetComponent <TileBehaviorIHM>().goToDesiredOrientation(rotation); }
public override List <GameObject> getadjacent(TileBehavior tile) { List <GameObject> retunitlist = new List <GameObject>(); int thisx = tile.GetComponent <TileBehavior>().xPosition; int thisy = tile.GetComponent <TileBehavior>().yPosition; if (thisy > 0) { int[,] up = new int[thisx, thisy - 1]; GameObject unit = GameManager.GetSingleton().mapArray[thisx, thisy - 1].GetComponent <TileBehavior>().myUnit; if (unit != null) { retunitlist.Add(unit); } } if (thisy < 12) { int[,] down = new int[thisx, thisy + 1]; GameObject unit = GameManager.GetSingleton().mapArray[thisx, thisy + 1].GetComponent <TileBehavior>().myUnit; if (unit != null) { retunitlist.Add(unit); } } if (thisx > 0) { int[,] left = new int[thisx - 1, thisy]; GameObject unit = GameManager.GetSingleton().mapArray[thisx - 1, thisy].GetComponent <TileBehavior>().myUnit; if (unit != null) { retunitlist.Add(unit); } } if (thisx < 18) { int[,] right = new int[thisx + 1, thisy]; GameObject unit = GameManager.GetSingleton().mapArray[thisx + 1, thisy].GetComponent <TileBehavior>().myUnit; if (unit != null) { retunitlist.Add(unit); } } return(retunitlist); }
public void OnTileHoveredIn(TileBehavior tileHovered) { if (this.selectedAction && this.highlightedTiles.Contains(tileHovered)) { this.HighlightTargetTiles(tileHovered); return; } if (tileHovered.Character is Monster) { this.MonsterInfo.ShowMonsterInfo(tileHovered.Character as Monster); } return; this.ClearHighlightedTiles(); if (tileHovered.Character != null && tileHovered.Character is Player) { return; } if (tileHovered.GetComponent <LightTarget>().LightLevel < 0.1f) { return; } if (!tileHovered.Tile.IsPassable) { return; } Point playerPos = this.LevelMng.Player.Pos; Point[] path = this.LevelMng.PathFromAtoB(playerPos, tileHovered.Pos); TileBehavior[] toHighlight = new TileBehavior[path.Length]; for (int i = 0; i < path.Length; i++) { TileBehavior tileBhv = this.LevelMng.GetTileBehavior(path[i]); toHighlight[i] = tileBhv; } this.HighlightTiles(toHighlight); }
public override void TileToXY(TileBehavior tile) { positionx = tile.GetComponent <TileBehavior>().xPosition; positiony = tile.GetComponent <TileBehavior>().yPosition; }