public ContextMenuTemplate GetSpawnMonsterMenu(BoardTile tile) { ContextMenuTemplate template = new ContextMenuTemplate(); template.textures = ButtonTextures.FromList(contextMenuTextures.blankTileTextures); template.font = contextMenuTextures.baseFont; template.tags = new List <List <string> >() { new List <string>() { "SpawnMonster", SRDLibrary.Monsters.Commoner.ToString() }, new List <string>() { "SpawnMonster", SRDLibrary.Monsters.Goblin.ToString() }, new List <string>() { "SpawnMonster", SRDLibrary.Monsters.Cultist.ToString() }, new List <string>() { "SpawnMonster", SRDLibrary.Monsters.CultFanatic.ToString() } }; template.texts = new List <string>() { "Commoner", "Goblin", "Cultist", "Cult Fanatic" }; return(template); }
public List <BoardTile> GetTilesInRange(BoardTile originSquare, int range, bool includeOrigin = false) { List <BoardTile> tileList = new List <BoardTile>(); //int offset; //The offset for diagonals in distance calculations for square if (boardShape == BoardShape.Square) { int rangeInTiles = (int)(range / tileGameSize); for (int x = -rangeInTiles; x <= rangeInTiles; x++) { for (int y = -rangeInTiles; y <= rangeInTiles; y++) { Vector2 coords = new Vector2(originSquare.coords.X + x, originSquare.coords.Y + y); if (TileExists(coords)) { if (includeOrigin || Tile(coords) != originSquare) { tileList.Add(Tile(coords)); } } } } } return(tileList); }
public void SetInitialTile(BoardTile tile) { SetToTile(tile); encounter = tile.board.encounter; encounter.creatures.Add(this); SortTexture(); }
public Creature(BoardTile tile, Texture2D texture = null) : base(new Vector2(0, 0), texture ?? baseCommonTexture, tile) { Initializing(); baseStats = new BaseStats(this); SetInitialTile(tile); RecalibrateStats(); }
public void SetToTile(BoardTile tile) { transform.localPosition = new Vector2(0, 0); boardTile = tile; tile.creature = this; SetParent(tile, true, true); }
public IEnumerator MoveOrder(BoardTile boardTile) { List <Creature> creaturesNearNewLocation = new List <Creature>(); foreach (BoardTile tile in encounter.board.GetTilesInRange(boardTile, 5)) { if (tile.creature != null) { creaturesNearNewLocation.Add(tile.creature); } } foreach (BoardTile tile in encounter.board.GetTilesInRange(boardTile, 5)) { if (tile.creature != null && !creaturesNearNewLocation.Contains(tile.creature)) { if (!tile.creature.reactionTaken) { OpportunityAttackOption optionDisplay = new OpportunityAttackOption(this, tile.creature); while (!optionDisplay.finished) { yield return(null); } if (optionDisplay.cancelled) { yield break; } } } } MoveTo(boardTile); }
public CreatureContextMenu MakeCommandMenu(BoardTile tile, Creature creature) { ContextMenuTemplate menu = GetCommandMenu(creature, tile); CreatureContextMenu commandMenu = new CreatureContextMenu(tile, creature ?? default(Creature), menu); contextMenu = commandMenu; return(commandMenu); }
public void MakeContextMenu(BoardTile tile) { board.mouseHoverActive = false; if (contextMenu != null) { contextMenu.DestroyAndChildren(); } contextMenu = new EncounterControlsContextMenu(tile, GetContextMenuBlankTile(tile), GetContextMenuEncounterControls()); }
public void ClearHoveredTile() { if (hoveredBoardTile == null) { return; } hoverOverlayTile.DestroyAndChildren(); hoverOverlayTile = null; hoveredBoardTile = null; }
public BoardTile FindTilePixel(Vector2 pixelCoords) { BoardTile reference = boardTiles[0, 0]; Vector2 tilePixelSize = reference.transform.Size; Vector2 positionReference = reference.transform.GlobalPosition - reference.transform.Size / 2; Vector2 relativePosition = pixelCoords - positionReference; Vector2 coords = new Vector2((int)(relativePosition.X / tilePixelSize.X), (int)(relativePosition.Y / tilePixelSize.Y)); return(TileIfExists(coords)); }
public void SetHoveredTile(BoardTile tile) { hoveredBoardTile = tile; if (hoverOverlayTile != null) { hoverOverlayTile.DestroyAndChildren(); } hoverOverlayTile = new GameObject(new Vector2(0, 0), textureSet.tileHoverTexture, tile); hoverOverlayTile.transform.layerDepth = -0.001f; hoverOverlayTile.transform.Size = hoveredBoardTile.transform.Size; }
public OrderControl(Board board, BoardTile originSquare, int range, Color color, List <TileOrderCriteria> criteria = null, string description = "") { SetDefaults(); board.encounter.orderControl = this; encounter = board.encounter; this.color = color; this.description = description; validTiles = new List <BoardTile>(board.GetTilesInRange(originSquare, range)); SetCriteria(criteria); SetHovers(); }
public List <BoardTile> GetCone(BoardTile origin, BoardTile destination, int length, int width, bool includeOrigin = false, int error = 4) { Vector2 originPosition = origin.transform.GlobalPosition; Vector2 destinationPosition = destination.transform.GlobalPosition; Vector2 differencePixels = destinationPosition - originPosition; Vector2 directionPixels = Vector2.Normalize(differencePixels); Vector2 perpendicularDirectionPixels = new Vector2(directionPixels.Y, -directionPixels.X); int tilePixelSize = (int)origin.transform.Size.X; float sizePerPixel = tileGameSize / origin.transform.Size.X; List <BoardTile> tiles = new List <BoardTile>(); tiles.Add(origin); BoardTile lastTile = origin; Vector2 currentPosition = originPosition; int widthInPixels = (int)(width / sizePerPixel); float rateOfWidthGrowth = (widthInPixels) / (length / sizePerPixel); for (int i = (int)(Math.Abs(differencePixels.Length())); i > 0; i -= error) { if (i * sizePerPixel > length) { i = (int)(length / sizePerPixel); } currentPosition = originPosition + (i * directionPixels); Vector2 currentWidthPosition = currentPosition; BoardTile tile; int widthAti = (int)(i * rateOfWidthGrowth); for (int j = -widthAti / 2; j <= widthAti / 2; j += error) { currentWidthPosition = currentPosition + (j * perpendicularDirectionPixels); tile = FindTilePixel(currentWidthPosition); if (tile != null && tile != lastTile && !tiles.Contains(tile)) { tiles.Add(tile); lastTile = tile; } } } if (!includeOrigin) { tiles.Remove(origin); } return(tiles); }
public virtual void SimpleSphereOnSelfTarget(BoardTile origin = null, bool includeOrigin = false) { List <BoardTile> tiles = new List <BoardTile>(); foreach (BoardTile tile in caster.encounter.board.GetTilesInRange(caster.boardTile, maxRange, includeOrigin)) { if (tile.creature != null) { tiles.Add(tile); } } AreaTargeted(tiles); }
public void SetSelection(BoardTile tile, List <BoardTile> boardtiles) { foreach (BoardTile oldHovered in selection) { oldHovered.RemoveHoverColor(); } selected = tile; selection = new List <BoardTile>(boardtiles); foreach (BoardTile hovered in selection) { hovered.SetHoverColor(color); } }
public DirectionalAreaOrder(BoardTile origin, int length, int width, Style style, Color?color = null, Spell spell = null, bool includeOrigin = false) { Debug.WriteLine("Directional Order Started"); board = origin.board; this.origin = origin; this.length = length; this.width = width; this.style = style; this.color = color ?? Color.Goldenrod; this.spell = spell; this.includeOrigin = includeOrigin; board.OnTileSelectionEvent += new Board.BoardDelegate(Selected); selection = new List <BoardTile>(); }
public List <BoardTile> GetCircle(BoardTile origin, BoardTile destination, int length, int width) { Vector2 originCoords = origin.coords; Vector2 destinationCoords = destination.coords; Vector2 difference = destinationCoords - originCoords; if (Math.Abs(difference.Length()) > (length / tileGameSize)) { difference = Vector2.Normalize(difference) * length / tileGameSize; destinationCoords = new Vector2((int)(originCoords.X + difference.X), (int)(originCoords.Y + difference.Y)); } return(GetTilesInRange(Tile(destinationCoords), width, true)); }
public OrderControl(Encounter encounter, List <BoardTile> validTiles, Color color, string description = "", List <TileOrderCriteria> criteria = null) { SetDefaults(); encounter.orderControl = this; this.encounter = encounter; list = false; this.validTiles = new List <BoardTile>(validTiles); this.color = color; this.description = description; this.selection = null; SetCriteria(criteria); SetHovers(); }
public ContextMenuTemplate GetContextMenuBlankTile(BoardTile tile) { ContextMenuTemplate template = new ContextMenuTemplate(); template.textures = ButtonTextures.FromList(contextMenuTextures.blankTileTextures); template.font = contextMenuTextures.baseFont; template.texts = new List <string>() { "Spawn Monster", "Spawn Quick Character", "Spawn Character", "Destroy Encounter" }; template.tags = new List <List <string> >() { new List <string>() { ContextMenu.DefaultTags.ParentMenu.ToString() }, new List <string>() { ContextMenu.DefaultTags.ParentMenu.ToString() }, new List <string>() { EncounterControls.SpawnCharacter.ToString() }, new List <string>() { EncounterControls.DestroyEncounter.ToString() } }; template.childMenus = new List <ContextMenuTemplate>() { GetSpawnMonsterMenu(tile), GetSpawnQuickCharacterSpeciesMenu() }; return(template); }
public void GetSelection(BoardTile tile) { if (selected != null && selected == tile) { return; } switch (style) { case (Style.Circle): SetSelection(tile, board.GetCircle(origin, tile, length, width)); break; case (Style.Cone): SetSelection(tile, board.GetCone(origin, tile, length, width, includeOrigin)); break; case (Style.Line): SetSelection(tile, board.GetLine(origin, tile, length, width, includeOrigin)); break; } }
protected IEnumerator SetOrderControl(Board board, BoardTile originSquare, int range, Color color, List <TileOrderCriteria> criteria = null, string description = "") { orderControl = new OrderControl(board, originSquare, range, color, criteria, description); while (!orderControl.cancelled) { if (orderControl.cancelled) { break; } if (orderControl.selection == null) { yield return(null); } else { orderControl.Cancel(); SelectionMade(); break; } } }
public PlayerCharacter(List <string> quickCharacterChoices, BoardTile tile) : base(tile) { classes = new Dictionary <PlayerClass, int>() { { DnDManager.classes[quickCharacterChoices[(int)QuickCharacterChoices.Class]], int.Parse(quickCharacterChoices[(int)QuickCharacterChoices.Level]) } }; primaryClass = DnDManager.classes[quickCharacterChoices[(int)QuickCharacterChoices.Class]]; subclasses = new List <SubClass>() { DnDManager.subClasses[quickCharacterChoices[(int)QuickCharacterChoices.SubClass]] }; species = DnDManager.species[quickCharacterChoices[(int)QuickCharacterChoices.Species]]; if (quickCharacterChoices[(int)QuickCharacterChoices.SubSpecies] != null) { subSpecies = DnDManager.subSpecies[quickCharacterChoices[(int)QuickCharacterChoices.SubSpecies]]; } else { subSpecies = null; } level = int.Parse(quickCharacterChoices[(int)QuickCharacterChoices.Level]); if (subSpecies != null) { name = string.Format("Lvl " + quickCharacterChoices[(int)QuickCharacterChoices.Level] + " " + quickCharacterChoices[(int)QuickCharacterChoices.SubSpecies] + " " + quickCharacterChoices[(int)QuickCharacterChoices.SubClass]); } else { name = string.Format("Lvl " + quickCharacterChoices[(int)QuickCharacterChoices.Level] + " " + quickCharacterChoices[(int)QuickCharacterChoices.Species] + " " + quickCharacterChoices[(int)QuickCharacterChoices.SubClass]); } RollStats(true); MakePlayerCharacter(); baseStats.RollHP(true); ResetHP(); RecalibrateStats(); }
public BoardTile MakeBoardTileSquare(int xIndex, int yIndex, int xPosition, int yPosition, int squareSize) { boardTiles[xIndex, yIndex] = new BoardTile(BoardShape.Square, new Vector2(xPosition, yPosition), textureSet.tileTexture, squareSize, this); boardTiles[xIndex, yIndex].coords = new Vector2(xIndex, yIndex); return(boardTiles[xIndex, yIndex]); }
public void SetDefaults() { selection = null; selectionList = new List <BoardTile>(); cancelled = false; }
public int GetDistance(BoardTile origin, BoardTile destination) { return(((int)Math.Max(Math.Abs(destination.coords.X - origin.coords.X), Math.Abs(destination.coords.Y - origin.coords.Y))) * tileGameSize); }
public void TileSelected(BoardTile tile) { OnTileSelectionEvent?.Invoke(tile, null); }
public void Select(BoardTile tile) { selection = tile; }
public void Selected(BoardTile tile, Board.BoardEventArgs e) { GetSelection(tile); SelectionMade(); }
public virtual void SimpleSphereTarget(BoardTile origin = null) { new DirectionalAreaOrder(origin ?? caster.boardTile, maxRange, width, TargetTypeToStyle(targetType), null, this); }
public EncounterControlsContextMenu(BoardTile tile, ContextMenuTemplate template1, ContextMenuTemplate template2) : base(template1, template2, new Vector2(0, 0), tile) { this.tile = tile; destroyOnOtherClick = true; }