Skip to content

Mephistus/HexTactics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HexTactics — Turn-Based Strategy (Unity C#)

A turn-based tactics game on a hex grid ported from Clickteam Fusion 2.5+ to Unity.

Algorithms Showcased

BFS — Movement Range Flood Fill

Assets/Scripts/Pathfinding/BFSPathfinder.cs

Used to compute all reachable tiles from a unit's position given its movement budget and terrain penalties. Runs a standard BFS queue where each neighbor is evaluated against movement cost, elevation constraints, and occupancy.

Dijkstra's Algorithm — Optimal Path Reconstruction

Assets/Scripts/Pathfinding/DijkstraPathfinder.cs

Used to trace the actual step-by-step path a unit walks after the player picks a destination tile. The BFS already writes predecessor pointers into the pathing grid (TileSetPathing); Dijkstra reconstructs the shortest-cost route by walking those pointers backward from the destination to the origin.

Project Structure

Assets/
  Scripts/
    Core/
      GameConstants.cs       — Enums, magic numbers, phase definitions
      GameManager.cs         — Singleton orchestrator
    Grid/
      HexGrid.cs             — Hex map data + neighbor lookup (offset coords)
      HexTile.cs             — Per-tile runtime state
      HexCoord.cs            — (row, col) struct + offset neighbor math
    Pathfinding/
      PathNode.cs            — Node used by both BFS and Dijkstra
      BFSPathfinder.cs       ★ BFS flood fill for move/attack range
      DijkstraPathfinder.cs  ★ Dijkstra path reconstruction
    Units/
      MovementType.cs        — Ground / Air / Amphibious / Fire enum
      UnitStats.cs           — ScriptableObject: base stats per unit type
      Unit.cs                — Runtime unit component (HP, MP, flags)
      UnitCharacter.cs       — Player-controlled unit subclass
      UnitSpirit.cs          — AI-summoned spirit subclass
    Combat/
      CombatPhase.cs         — All phase enum values
      TurnManager.cs         — CTB speed-based turn order
      CombatManager.cs       — Phase state machine
      DamageCalculator.cs    — Attack / magic formula + element table
      ElementSystem.cs       — 4-element advantage matrix
    AI/
      AIController.cs        — Decides AI move each turn
      AIHeatmap.cs           — Scores tiles near ward objectives
    UI/
      ActionMenu.cs          — Wait / Attack / Magic / Summon / Cancel
      SummonWindow.cs        — Per-spirit summon panel
      DamageDisplay.cs       — Floating damage number
    Input/
      InputHandler.cs        — Mouse click → game action routing
    FX/
      CameraController.cs    — Smooth follow camera
      HexMarkerManager.cs    — Blue/red tile highlight overlays
  Data/
    TileData/
      TileSetPathing.cs      — 3-D int array wrapper (row, col, channel)
    UnitStats/               — Place UnitStats ScriptableObject assets here

How to Run

  1. Open project in Unity 2022 LTS or newer.
  2. Open Assets/Scenes/BattleScene.unity.
  3. Attach GameManager to an empty GameObject.
  4. Hit Play.

🔗 GitHub

Push this folder as the repo root. Add Assets/Scenes/*.unity and ProjectSettings/ for a full Unity project.

About

Unity C# Scripts for Hextactics Engine. A comprehensible turn-based hex engine that includes BFS (Breadth-First Search) and Dijkstra's algorithm for efficient pathfinding and multi-level environments.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages