public override CommandResult Invoke(Entity caster, Cell target) { Line line = Bresenhams.GetLine(caster.Level, caster.Cell, target); Global.Instance.StartCoroutine(Fire(caster, line)); return(CommandResult.Succeeded); }
public override HashSet <Cell> GetTargetedCells(Entity caster, Cell target) { Line line = Bresenhams.GetLine(caster.Level, caster.Cell, target); HashSet <Cell> ret = new HashSet <Cell>(); ret.AddMany(line); return(ret); }
public override HashSet <Cell> GetTargetedCells(Entity caster, Cell target) { Line line = Bresenhams.GetLine(caster.Level, caster.Cell, target); return(new HashSet <Cell> { line.ElementAtOrLast(Range) }); }
private Line[] FindTargets() { Line[] ret = new Line[count]; List <Entity> enemies = Entity.Level.FindBySpiral(Entity.Cell, 11, delegate(Entity e) { if (e == null) { return(false); } if (!e.Cell.Visible) { return(false); } if (!e.TryGetComponent(out ActorComp actor)) { return(false); } if (!Entity.GetComponent <ActorComp>().HostileTo(actor)) { return(false); } return(true); }); if (enemies.Count < 1) { return(null); } for (int i = 0; i < count; i++) { ret[i] = Bresenhams.GetLine( Entity.Level, Entity.Cell, enemies.ElementAtOrLast(i).Cell); } return(ret); }
public override CommandResult Invoke(Entity caster, Cell target) { if (target == null) { throw new NotImplementedException("Target cell needed."); } Cell affected = Bresenhams.GetLine( caster.Level, caster.Cell, target).ElementAtOrLast(Range); Entity enemy = affected.Actor; if (enemy == null) { Locator.Audio.Buffer( Assets.Audio["SFX_Toss"], affected.Position.ToVector3()); Locator.Log.Send( $"{Strings.Subject(caster, true)}" + $" {Verbs.Swing(caster)} at nothing.", Color.grey); return(CommandResult.Succeeded); } if (Accuracy < Random.Range(0, 101)) { Locator.Log.Send( Verbs.Miss(caster, enemy), Color.grey); return(CommandResult.Succeeded); } Locator.Audio.Buffer( Assets.Audio["SFX_Punch"], affected.Position.ToVector3()); Hit hit = new Hit(Damages); Locator.Log.Send(Verbs.Hit(caster, enemy, hit), Color.white); enemy.TakeHit(caster, hit); return(CommandResult.Succeeded); }
public void Draw(GameTime gameTime, Rectangle rect, Rectangle region, int visibleRadius) { if (region.Width <= 0 || region.Height <= 0) { return; } var tileWidth = rect.Width / region.Width; var tileHeight = rect.Height / region.Height; var tileSize = new Point(tileWidth, tileHeight); for (int x = region.Left; x < region.Left + region.Width; x++) { if (x < 0 || x >= _width) { continue; } for (int y = region.Top; y < region.Top + region.Height; y++) { if (y < 0 || y >= _height) { continue; } if (Helpers.Distance(region.Center.X, region.Center.Y, x, y) > visibleRadius && !(_tiles[x, y]?.Revealed ?? false)) { continue; } var tile = _tiles[x, y]; if (tile == null) { continue; } bool draw = false; Bresenhams.Line(region.Center.X, region.Center.Y, x, y, (tx, ty) => { if (tx > 0 && tx < _width && ty > 0 && ty < _height) { if (tx == x && ty == y) { draw = true; } else if (tx == region.Center.X && ty == region.Center.Y) { return(true); } if (_tiles[tx, ty]?.Obstacle ?? true) { return(false); // stop } else { return(true); // continue } } else { return(false); } }); if (draw) { tile.Revealed = true; tile.Draw(gameTime, GetScreenCoordinates(new Point(x, y), rect, region)); } else if (tile.Revealed) { tile.Draw(gameTime, GetScreenCoordinates(new Point(x, y), rect, region), false); } } } }