public Tile(int x, int y, TSession session) { Session = session; X = x; Y = y; Heat = new HeatInfo(this); }
public void TrapGoesOff() { this.Speak("Trap: " + (this.Trap.Humanize(LetterCasing.Title)) + "!"); TSession session = this.Session; if (this.Trap == TrapId.Fireball) { this.Fireball(session); foreach (var neighbour in this.Neighbours) { neighbour.Fireball(session); } } else if (this.Trap == TrapId.EmpoweredFireball) { this.Fireball(session); foreach (var neighbour in this.Neighbours) { neighbour.Fireball(session); foreach (var neighbour2 in neighbour.Neighbours) { neighbour2.Fireball(session); } } } this.Trap = TrapId.NotTrapped; }
private static void InitializeOpenSetIfNecessary(TSession map) { int totalSize = map.MapWidth * map.MapHeight; if (mapTotalSize < totalSize) { openSet = new FastPriorityQueue <Tile>(totalSize); mapTotalSize = totalSize; } }
public Character(string name, bool isNpc, Illustration illustration, Vector2 position, TSession session) { Name = name; NPCDescription = "Civilian"; IsNPC = isNpc; HP = 10; MaxHP = 10; Illustration = illustration; Position = position; this.Session = session; }
public void Fireball(TSession session) { Heat.StartHeavyFire(); foreach (var chara in session.Characters) { if (chara.Occupies == this) { chara.TakeDamage(10); } } }
private void SpawnPaladinHereIfAble(List <CharacterSheet> remainingPaladins, TSession session) { if (remainingPaladins.Count > 0) { var paladin = remainingPaladins[0]; remainingPaladins.RemoveAt(0); session.Characters.Add(new Character(paladin.Name, false, paladin.Class == CharacterClass.Warrior ? Illustration.WarriorPaladin : Illustration.WaterPaladin, new Vector2(this.X, this.Y), session) { Sheet = paladin }); } }
public static LinkedList <Tile> AStar(Character who, Tile target, TSession map, PathfindingMode mode) { InitializeOpenSetIfNecessary(map); pathfindingSearchId++; Tile start = who.Occupies; if (target == null) { return(null); } Tile closestToTargetSoFar = start; openSet.Clear(); int initH = Pathfinding.Heuristic(start, target); SetPathfindingInformation(start, pathfindingSearchId, false, 0, initH, null); openSet.Enqueue(start, initH); int closestToTargetHeuristicSoFar = initH; while (openSet.Count > 0) { Tile current = openSet.Dequeue(); if (current == target) { return(ReconstructPrettyPath(start, target)); } current.Pathfinding_Closed = true; foreach (var neighbour in current.Neighbours) // TODO change to traversable neighbours { // Tile neighbour = edge.Destination; if (neighbour.Pathfinding_EncounteredDuringSearch == pathfindingSearchId && neighbour.Pathfinding_Closed) { continue; } if (neighbour.BlocksMovement) { continue; } if (neighbour.Pathfinding_EncounteredDuringSearch < pathfindingSearchId) { SetPathfindingInformation(neighbour, pathfindingSearchId, false, int.MaxValue, int.MaxValue, current); openSet.Enqueue(neighbour, int.MaxValue); } int tentativeGScore = current.Pathfinding_G + (IsDiagonal(current, neighbour) ? 14 : 10); if (tentativeGScore >= neighbour.Pathfinding_G) { continue; } neighbour.Pathfinding_Parent = current; neighbour.Pathfinding_G = tentativeGScore; int heuristic = Heuristic(neighbour, target); neighbour.Pathfinding_F = neighbour.Pathfinding_G + heuristic; openSet.UpdatePriority(neighbour, neighbour.Pathfinding_F); if (heuristic < closestToTargetHeuristicSoFar) { closestToTargetSoFar = neighbour; closestToTargetHeuristicSoFar = heuristic; } } } if (mode == PathfindingMode.FindClosestIfDirectIsImpossible) { return(ReconstructPrettyPath(start, closestToTargetSoFar)); } return(null); }
public void AddIllustration(Illustration illus, TSession session, List <CharacterSheet> remainingPaladins) { switch (illus) { case Illustration.Grass: int r = R.Next(3); switch (r) { case 0: illus = Illustration.Grass2; break; case 1: illus = Illustration.Grass3; break; } break; case Illustration.Chest: case Illustration.Chest2: case Illustration.Cobweb: case Illustration.Grave: case Illustration.Grave2: case Illustration.WoodenGrave: case Illustration.Rock: case Illustration.AutumnTree: case Illustration.Bush: case Illustration.Bag: BlocksMovement = true; break; case Illustration.BrownBrick: case Illustration.BrownDoor: BlocksLineOfSight = true; BlocksMovement = true; break; case Illustration.BlueCivilian: case Illustration.GreenCivilian: case Illustration.PurpleCivilian: session.Characters.Add(new Character("Civilian " + RandomNameGenerator.Generate(), true, illus, new Vector2(this.X, this.Y), session)); illus = Illustration.None; break; case Illustration.Ghoul: session.Characters.Add(new Character("Undead Ghoul", true, illus, new Vector2(this.X, this.Y), session) { Hostile = true, NPCDescription = "Undead abomination", HP = 5, MaxHP = 5 }); illus = Illustration.None; break; case Illustration.WarriorPaladin: illus = Illustration.None; SpawnPaladinHereIfAble(remainingPaladins, session); break; case Illustration.Evac: session.EvacuationTile = this; break; case Illustration.Fire32: illus = Illustration.None; this.Heat.StartHeavyFire(); break; } if (illus != Illustration.None) { this.Illustrations.Add(illus); ResetFuel(); } }