public void addSkills(Demo.Mob mb) { foreach (Skill sk in mb.skillList) { MenuItem skmi = new MenuItem(sk.name, null, Demo.OnKeyDown_SelectSkill, Demo.HighlightSkill); allScreens["Attack"].menu.Add(skmi); allMenuItems.Add(skmi); } }
public Demo.Mob checkPos(int checkX, int checkY) { Demo.Mob ret = null; entities.TryGetValue(new Point() { X = checkX, Y = checkY }, out ret); return(ret); }
public Demo.Mob checkPos(int checkX, int checkY, int checkTile) { Demo.Mob ret = null; entities.TryGetValue(new Point() { X = checkX, Y = checkY }, out ret); if (ret != null && ret.tile != checkTile) { ret = null; } return(ret); }
public Demo.Mob Spawn(int tileNo, int width, int height) { int rx = rnd.Next(width); int ry = rnd.Next(height); if (map[ry, rx] == DungeonMap.gr && enemyBlockedCells.Contains(new Point(rx, ry)) == false) { Demo.Mob nt = new Demo.Mob(tileNo, rx, ry, false, floor); if (checkPos(nt.x, nt.y) != null) { return(Spawn(tileNo, width, height)); } nt.skillList.Add(new Skill("Basic Attack", rnd.Next(3, 7), 1, 1, SkillAreaKind.SingleTarget, 0, true)); nt.currentSkill = nt.skillList[0]; //nt.ui.addSkills(nt); entities[nt.pos] = nt; o_entities[nt.o_pos] = nt; return(nt); } return(Spawn(tileNo, width, height)); }
public Vision(Demo.Mob viewer) { this.viewer = viewer; //sightSet = new HashSet<Point>() { this.viewer.pos }; }
public Intellect(Demo.Mob thinker) { this.thinker = thinker; this.activity = MentalState.Hunting; goals = new double[thinker.dlevel.map.GetLength(0), thinker.dlevel.map.GetLength(0)]; }
public Demo.Mob Spawn(int tileNo, int width, int height) { int rx = rnd.Next(width); int ry = rnd.Next(height); if (map[ry, rx] == DungeonMap.gr && enemyBlockedCells.Contains(new Point(rx, ry)) == false) { Demo.Mob nt = new Demo.Mob(tileNo, rx, ry, false, floor); if (checkPos(nt.x, nt.y) != null) return Spawn(tileNo, width, height); nt.skillList.Add(new Skill("Basic Attack", rnd.Next(3, 7), 1, 1, SkillAreaKind.SingleTarget, 0, true)); nt.currentSkill = nt.skillList[0]; //nt.ui.addSkills(nt); entities[nt.pos] = nt; o_entities[nt.o_pos] = nt; return nt; } return Spawn(tileNo, width, height); }
public static void ShowMobInfo(Demo.Mob mb) { Dictionary <char, char> mandrillDict = SimpleUI.mandrillDict; string tx = mandrillDict['┌'].ToString(); tx = tx.PadRight(maxWidth - 1, mandrillDict['─']); tx += mandrillDict['┐']; // for (int i = 1; i < maxWidth - 1; i++) // tx += mandrillDict['─']; int currentLine = 1; mb.ui.font.DrawText(renderX, renderY + (mb.ui.font.FontHeight * currentLine), tx); currentLine++; mb.ui.font.DrawText(renderX, renderY + (mb.ui.font.FontHeight * currentLine), mandrillDict['│'] + (mb.name + ((mb.friendly == true) ? " (Ally)" : "")).PadRight(maxWidth - 2, ' ') + mandrillDict['│']); tx = mandrillDict['╞'].ToString(); tx = tx.PadRight(maxWidth - 1, mandrillDict['═']); tx += mandrillDict['╡']; currentLine++; mb.ui.font.DrawText(renderX, renderY + (mb.ui.font.FontHeight * currentLine), tx); currentLine++; mb.ui.font.DrawText(renderX, renderY + (mb.ui.font.FontHeight * currentLine), mandrillDict['│'] + (mb.health + "/" + mb.maxHP + " HP").PadRight(maxWidth - 2, ' ') + mandrillDict['│']); tx = mandrillDict['├'].ToString(); tx = tx.PadRight(maxWidth - 1, mandrillDict['─']); tx += mandrillDict['┤']; currentLine++; mb.ui.font.DrawText(renderX, renderY + (mb.ui.font.FontHeight * currentLine), tx); int counter = 0; if (mb.skillList.Count > 4) { counter = (int)(sw.TotalMilliseconds / 5000); } List <Skill> shownSkills = new List <Skill>(); for (int i = counter % mb.skillList.Count, t = 0; t < 4 && t < mb.skillList.Count; i = (i + 1) % mb.skillList.Count, t++) { shownSkills.Add(mb.skillList[i]); } /* * * if (counter + 4 > mb.skillList.Count) * { * counter = 0; * sw.Reset(); * } */ for (int i = 0; i < shownSkills.Count; i++) { currentLine++; mb.ui.font.DrawText(renderX, renderY + (mb.ui.font.FontHeight * currentLine), "" + mandrillDict['│']); mb.ui.font.DrawText(renderX + 6.0, renderY + (mb.ui.font.FontHeight * (currentLine)), shownSkills[i].name.PadRight(maxWidth - 2, ' ')); mb.ui.font.DrawText(renderX + 6.0 * (maxWidth - 1), renderY + (mb.ui.font.FontHeight * currentLine), "" + mandrillDict['│']); currentLine++; mb.ui.font.DrawText(renderX, renderY + (mb.ui.font.FontHeight * currentLine), "" + mandrillDict['│']); mb.ui.font.DrawText(renderX + 6.0, renderY + (mb.ui.font.FontHeight * (currentLine)), ("Damage: " + shownSkills[i].damage).PadRight(maxWidth - 2, ' ')); mb.ui.font.DrawText(renderX + 6.0 * (maxWidth - 1), renderY + (mb.ui.font.FontHeight * currentLine), "" + mandrillDict['│']); currentLine++; mb.ui.font.DrawText(renderX, renderY + (mb.ui.font.FontHeight * currentLine), "" + mandrillDict['│']); mb.ui.font.DrawText(renderX + 6.0, renderY + (mb.ui.font.FontHeight * (currentLine)), (SkillView.RangeToString(shownSkills[i])).PadRight(maxWidth - 2, ' ')); mb.ui.font.DrawText(renderX + 6.0 * (maxWidth - 1), renderY + (mb.ui.font.FontHeight * currentLine), "" + mandrillDict['│']); } tx = mandrillDict['└'].ToString(); tx = tx.PadRight(maxWidth - 1, mandrillDict['─']); tx += mandrillDict['┘']; currentLine++; mb.ui.font.DrawText(renderX, renderY + (mb.ui.font.FontHeight * currentLine), tx); }
public SkillResult ApplySkill(Demo.Mob user) { switch (areaKind) { case SkillAreaKind.Ring: { Dictionary <Point, int> damages = new Dictionary <Point, int>(); Dictionary <Point, bool> kills = new Dictionary <Point, bool>(); //assuming targetSquare of 10, 11 and radius 1: int minX = targetSquare.X - radius; // 9 if (minX < 0) { minX = 0; } int minY = targetSquare.Y - radius; // 10 if (minY < 0) { minY = 0; } int maxX = targetSquare.X + radius; // 11 if (maxX > Demo.currentLevel.map.GetUpperBound(1)) { maxX = Demo.currentLevel.map.GetUpperBound(1); } int maxY = targetSquare.Y + radius; // 12 if (maxY > Demo.currentLevel.map.GetUpperBound(0)) { maxY = Demo.currentLevel.map.GetUpperBound(0); } for (int i = minX; i <= maxX; i++) { for (int j = minY; j <= maxY; j++) { if (j - targetSquare.Y > i - targetSquare.X + radius || // 10 - 10 > 10 - 11 + 1 j - targetSquare.Y > -1 * (i - targetSquare.X) + radius || // 10 - 10 > -10 + 11 + 1 j - targetSquare.Y < i - targetSquare.X - radius || // 10 - 10 < 10 - 11 - 1 j - targetSquare.Y < -1 * (i - targetSquare.X) - radius || // 10 - 10 < -10 + 11 - 1 (i == targetSquare.X && j == targetSquare.Y)) { continue; } Demo.Mob tgt = Demo.currentLevel.checkPos(i, j); if (tgt != null && user.fov.sight[j, i] > 0) { if (hitsAllies == false && tgt.friendly == user.friendly) { continue; } Point o_tgt = new Point(tgt.o_pos.X, tgt.o_pos.Y); Point tgt_pos = new Point(tgt.pos.X, tgt.pos.Y); tgt.health = tgt.health - this.damage; bool didKill = false; if (!Demo.currentLevel.o_entities.ContainsKey(o_tgt)) { didKill = true; } damages.Add(tgt_pos, this.damage); kills.Add(tgt_pos, didKill); } } } return(new SkillResult(damages, kills)); } /*{ * Dictionary<Cell, int> damages = new Dictionary<Cell, int>(); * Dictionary<Cell, bool> kills = new Dictionary<Cell, bool>(); * Demo.Mob tgt = Demo.checkPos(targetSquare.x - radius, targetSquare.y); * if (tgt != null) * { * Cell o_tgt = new Cell(tgt.o_pos.x, tgt.o_pos.y); * Cell tgt_pos = new Cell(tgt.pos.x, tgt.pos.y); * tgt.health = tgt.health - this.damage; * bool didKill = false; * if (!Demo.o_entities.ContainsKey(o_tgt)) * didKill = true; * damages.Add(tgt_pos, this.damage); * kills.Add(tgt_pos, didKill); * } * tgt = Demo.checkPos(targetSquare.x + radius, targetSquare.y); * if (tgt != null) * { * Cell o_tgt = new Cell(tgt.o_pos.x, tgt.o_pos.y); * Cell tgt_pos = new Cell(tgt.pos.x, tgt.pos.y); * tgt.health = tgt.health - this.damage; * bool didKill = false; * if (!Demo.o_entities.ContainsKey(o_tgt)) * didKill = true; * damages.Add(tgt_pos, this.damage); * kills.Add(tgt_pos, didKill); * } * tgt = Demo.checkPos(targetSquare.x, targetSquare.y - radius); * if (tgt != null) * { * Cell o_tgt = new Cell(tgt.o_pos.x, tgt.o_pos.y); * Cell tgt_pos = new Cell(tgt.pos.x, tgt.pos.y); * tgt.health = tgt.health - this.damage; * bool didKill = false; * if (!Demo.o_entities.ContainsKey(o_tgt)) * didKill = true; * damages.Add(tgt_pos, this.damage); * kills.Add(tgt_pos, didKill); * } * tgt = Demo.checkPos(targetSquare.x, targetSquare.y + radius); * if (tgt != null) * { * Cell o_tgt = new Cell(tgt.o_pos.x, tgt.o_pos.y); * Cell tgt_pos = new Cell(tgt.pos.x, tgt.pos.y); * tgt.health = tgt.health - this.damage; * bool didKill = false; * if (!Demo.o_entities.ContainsKey(o_tgt)) * didKill = true; * damages.Add(tgt_pos, this.damage); * kills.Add(tgt_pos, didKill); * } * return new SkillResult(damages, kills); * }*/ case SkillAreaKind.Burst: { Dictionary <Point, int> damages = new Dictionary <Point, int>(); Dictionary <Point, bool> kills = new Dictionary <Point, bool>(); //assuming targetSquare of 10, 11 and radius 1: int minX = targetSquare.X - radius; // 9 if (minX < 0) { minX = 0; } int minY = targetSquare.Y - radius; // 10 if (minY < 0) { minY = 0; } int maxX = targetSquare.X + radius; // 11 if (maxX > Demo.currentLevel.map.GetUpperBound(1)) { maxX = Demo.currentLevel.map.GetUpperBound(1); } int maxY = targetSquare.Y + radius; // 12 if (maxY > Demo.currentLevel.map.GetUpperBound(0)) { maxY = Demo.currentLevel.map.GetUpperBound(0); } for (int i = minX; i <= maxX; i++) { for (int j = minY; j <= maxY; j++) { if (j - targetSquare.Y > i - targetSquare.X + radius || // 10 - 10 > 10 - 11 + 1 j - targetSquare.Y > -1 * (i - targetSquare.X) + radius || // 10 - 10 > -10 + 11 + 1 j - targetSquare.Y < i - targetSquare.X - radius || // 10 - 10 < 10 - 11 - 1 j - targetSquare.Y < -1 * (i - targetSquare.X) - radius) // 10 - 10 < -10 + 11 - 1 { continue; } Demo.Mob tgt = Demo.currentLevel.checkPos(i, j); if (tgt != null && user.fov.sight[j, i] > 0) { if (hitsAllies == false && tgt.friendly == user.friendly) { continue; } Point o_tgt = new Point(tgt.o_pos.X, tgt.o_pos.Y); Point tgt_pos = new Point(tgt.pos.X, tgt.pos.Y); tgt.health = tgt.health - this.damage; bool didKill = false; if (!Demo.currentLevel.o_entities.ContainsKey(o_tgt)) { didKill = true; } damages.Add(tgt_pos, this.damage); kills.Add(tgt_pos, didKill); } } } return(new SkillResult(damages, kills)); } case SkillAreaKind.Spray: { Dictionary <Point, int> damages = new Dictionary <Point, int>(); Dictionary <Point, bool> kills = new Dictionary <Point, bool>(); //assuming targetSquare of 10, 11 and radius 2: int minX = targetSquare.X - (radius - 1); // 8 if (minX < 0) { minX = 0; } int minY = targetSquare.Y - (radius - 1); // 9 if (minY < 0) { minY = 0; } int maxX = targetSquare.X + (radius - 1); // 12 if (maxX > Demo.currentLevel.map.GetUpperBound(1)) { maxX = Demo.currentLevel.map.GetUpperBound(1); } int maxY = targetSquare.Y + (radius - 1); // 13 if (maxY > Demo.currentLevel.map.GetUpperBound(0)) { maxY = Demo.currentLevel.map.GetUpperBound(0); } if (targetSquare.Y == user.y && targetSquare.X == user.x) { minY++; maxY++; } for (int i = minX; i <= maxX; i++) { for (int j = minY; j <= maxY; j++) { if (targetSquare.Y == user.y && targetSquare.X == user.x) { if (j - targetSquare.Y > radius + 1 || j - targetSquare.Y < i - targetSquare.X + 1 || j - targetSquare.Y < -1 * (i - targetSquare.X) + 1 || (i == targetSquare.X && j == targetSquare.Y)) { continue; } } else if (targetSquare.Y - user.y >= user.x - targetSquare.X && targetSquare.Y - user.y >= targetSquare.X - user.x) { if (j - targetSquare.Y > radius || j - targetSquare.Y < i - targetSquare.X || j - targetSquare.Y < -1 * (i - targetSquare.X)) //|| //+ 1 // (i == targetSquare.x && j == targetSquare.y)) { continue; } } else if (user.y - targetSquare.Y >= user.x - targetSquare.X && user.y - targetSquare.Y >= targetSquare.X - user.x) { if (j - targetSquare.Y < -1 * radius || j - targetSquare.Y > i - targetSquare.X || j - targetSquare.Y > -1 * (i - targetSquare.X)) //|| //- 1 // (i == targetSquare.x && j == targetSquare.y)) { continue; } } else if (targetSquare.X - user.x > user.y - targetSquare.Y && targetSquare.X - user.x > targetSquare.Y - user.y) { if (i - targetSquare.X > radius || i - targetSquare.X < j - targetSquare.Y || i - targetSquare.X < -1 * (j - targetSquare.Y)) //|| //+ 1 // (i == targetSquare.x && j == targetSquare.y)) { continue; } } else if (user.x - targetSquare.X > user.y - targetSquare.Y && user.x - targetSquare.X > targetSquare.Y - user.y) { if (i - targetSquare.X < -1 * radius || i - targetSquare.X > j - targetSquare.Y || i - targetSquare.X > -1 * (j - targetSquare.Y)) //- 1 // (i == targetSquare.x && j == targetSquare.y)) { continue; } } Demo.Mob tgt = Demo.currentLevel.checkPos(i, j); if (tgt != null && user.fov.sight[j, i] > 0) { if (hitsAllies == false && tgt.friendly == user.friendly) { continue; } Point o_tgt = new Point(tgt.o_pos.X, tgt.o_pos.Y); Point tgt_pos = new Point(tgt.pos.X, tgt.pos.Y); tgt.health = tgt.health - this.damage; bool didKill = false; if (!Demo.currentLevel.o_entities.ContainsKey(o_tgt)) { didKill = true; } damages.Add(tgt_pos, this.damage); kills.Add(tgt_pos, didKill); } } } return(new SkillResult(damages, kills)); } case SkillAreaKind.SingleTarget: default: { Demo.Mob tgt = Demo.currentLevel.checkPos(targetSquare.X, targetSquare.Y); if (tgt == null) { return(new SkillResult()); } if (hitsAllies == false && tgt.friendly == user.friendly) { return(new SkillResult()); } if (user.fov.sight[tgt.y, tgt.x] <= 0) { return(new SkillResult()); } Point o_tgt = new Point(tgt.o_pos.X, tgt.o_pos.Y); Point tgt_pos = new Point(tgt.pos.X, tgt.pos.Y); tgt.health = tgt.health - this.damage; bool didKill = false; if (!Demo.currentLevel.o_entities.ContainsKey(o_tgt)) { didKill = true; } return(new SkillResult(new Dictionary <Point, int>() { { tgt_pos, this.damage } }, new Dictionary <Point, bool>() { { tgt_pos, didKill } })); } } }