public CircleSweepHitbox(Character user, Alignment targetAlignments, bool hitTiles, bool burstOnWall, Loc startPoint, AnimData anim, FiniteEmitter tileEmitter, AttachPointEmitter emitter, int speed, int delay, Dir8 dir, int maxDistance, bool boomerang, string item) : base(user, startPoint * GraphicsManager.TileSize + dir.GetLoc() * GraphicsManager.TileSize / 2, tileEmitter, delay) { TargetAlignments = targetAlignments; HitTiles = hitTiles; BurstOnWall = burstOnWall; StartPoint = startPoint; Dir = dir; DistanceTraveled = GraphicsManager.TileSize / 2; MaxDistance = maxDistance; Boomerang = boomerang; Speed = (speed > 0) ? speed : Math.Max(1, (int)Math.Ceiling((double)(MaxDistance - 0.5 + (Boomerang ? MaxDistance : 0)) * GraphicsManager.MAX_FPS)); ItemAnim = item; reverse = 1; Anim = new AnimData(anim); Emitter = (AttachPointEmitter)emitter.Clone(); Emitter.SetupEmit(User, MapLoc, User.MapLoc, user.CharDir, LocHeight); }
protected override BattleContext CreateContext(GameEventOwner owner, Character ownerChar, BattleContext context) { Character target = (AffectTarget ? context.Target : context.User); int damage = context.GetContextStateInt <DamageDealt>(0); if (damage > 0 && ownerChar != context.User) { //the attack needs to face the foe, and *auto-target* Dir8 attackDir = DirExt.GetDir(ownerChar.CharLoc, target.CharLoc); ownerChar.CharDir = attackDir; Loc frontLoc = ownerChar.CharLoc + attackDir.GetLoc() * FrontOffset; SkillData entry = DataManager.Instance.GetSkill(InvokedMove); DungeonScene.Instance.LogMsg(String.Format(Msg.ToLocal(), ownerChar.GetDisplayName(false), context.User.GetDisplayName(false))); BattleContext newContext = new BattleContext(BattleActionType.Skill); newContext.User = ownerChar; newContext.UsageSlot = BattleContext.FORCED_SLOT; newContext.StartDir = newContext.User.CharDir; //fill effects newContext.Data = new BattleData(entry.Data); newContext.Data.ID = InvokedMove; newContext.Explosion = new ExplosionData(entry.Explosion); newContext.HitboxAction = entry.HitboxAction.Clone(); //make the attack *autotarget*; set the offset to the space between the front loc and the target newContext.HitboxAction.HitOffset = target.CharLoc - frontLoc; newContext.Strikes = entry.Strikes; newContext.Item = new InvItem(); //don't set move message, just directly give the message of what the move turned into //add a tag that will allow the moves themselves to switch to their offensive versions newContext.ContextStates.Set(new FollowUp()); return(newContext); } return(null); }
public void DrawBeam(SpriteBatch spriteBatch, Vector2 pos, int frame, Dir8 dir, int offset, int length, Color color) { Loc dirLoc = dir.GetLoc(); Loc diff = dirLoc * (length + offset); Rectangle body = getBeamFrame(BeamFrame.Body, frame); Draw(spriteBatch, new Vector2(pos.X + diff.X, pos.Y + diff.Y), body, new Vector2(body.Width / 2, body.Height), color, new Vector2(1, dir.IsDiagonal() ? (float)(length * 1.4142136 + 1) : length), (float)((int)dir * Math.PI / 4)); diff = dirLoc * offset; Rectangle tail = getBeamFrame(BeamFrame.Tail, frame); Draw(spriteBatch, new Vector2(pos.X + diff.X, pos.Y + diff.Y), tail, color, new Vector2(1), (float)((int)dir * Math.PI / 4)); diff = dirLoc * (length + offset - 1); Rectangle head = getBeamFrame(BeamFrame.Head, frame); Draw(spriteBatch, new Vector2(pos.X + diff.X, pos.Y + diff.Y), head, color, new Vector2(1), (float)((int)dir * Math.PI / 4)); }
private bool IsLooseBlocked(QueryMethod queryMethod, int[][] mainTextureArray, Loc rectStart, int x, int y, Dir8 dir) { Loc loc = new Loc(x, y) + dir.GetLoc(); return(queryMethod(loc.X, loc.Y) && mainTextureArray[loc.X - rectStart.X + 1][loc.Y - rectStart.Y + 1] == -1); }
public static bool IsInSquareHitbox(Loc loc, Loc origin, int squareRadius, AreaLimit limit, Dir8 dir) { if (loc.X < origin.X - squareRadius || loc.X > origin.X + squareRadius) { return(false); } if (loc.Y < origin.Y - squareRadius || loc.Y > origin.Y + squareRadius) { return(false); } if (limit == AreaLimit.Cone) { //check if it's inside the cone //get line diff Loc diff = loc - origin; //get cone vectors Dir8 cone1 = DirExt.AddAngles(dir, Dir8.DownRight); Dir8 cone2 = DirExt.AddAngles(dir, Dir8.DownLeft); //get vector orthogonal1 to first cone line (aka, -second cone line) Loc ortho1 = cone2.GetLoc() * -1; //get vector orthogonal2 to second cone line ( aka, first cone line) Loc ortho2 = cone1.GetLoc(); //get dot product of diff to orthogonal1; must be less than or equal to 0 int dot1 = Loc.Dot(diff, ortho1); //get dot product of diff to orthogonal2; must be greater than or equal to 0 int dot2 = Loc.Dot(diff, ortho2); if (dot1 > 0 || dot2 < 0) { return(false); } } else if (limit == AreaLimit.Sides) { Loc diff = loc - origin; if (dir.IsDiagonal()) { //get cone vectors Dir8 cone1 = DirExt.AddAngles(dir.Reverse(), Dir8.DownRight); Dir8 cone2 = DirExt.AddAngles(dir.Reverse(), Dir8.DownLeft); //get vector orthogonal1 to first cone line (aka, -second cone line) Loc ortho1 = cone2.GetLoc() * -1; //get vector orthogonal2 to second cone line ( aka, first cone line) Loc ortho2 = cone1.GetLoc(); //get dot product of diff to orthogonal1; must be less than or equal to 0 int dot1 = Loc.Dot(diff, ortho1); //get dot product of diff to orthogonal2; must be greater than or equal to 0 int dot2 = Loc.Dot(diff, ortho2); if (dot1 > 0 || dot2 < 0) { return(false); } //additionally, both dot products cannot be a nonzero if (dot1 != 0 && dot2 != 0) { return(false); } } else { //check if it's inside the sides int dot = Loc.Dot(diff, dir.GetLoc()); //check if the other point is EXACTLY perpendicular if (dot != 0) { return(false); } } } return(true); }
/// <summary> /// chooses and caegorizes the tile to be sealed /// </summary> /// <param name="map"></param> /// <param name="sealList"></param> /// <param name="plan"></param> /// <param name="loc"></param> /// <param name="dir"></param> /// <returns>Whether it affected the tile outwards or not</returns> private bool sealBorderRay(T map, Dictionary <Loc, SealType> sealList, IFloorRoomPlan plan, LocRay8 locRay, Dir8 side1, Dir8 side2) { Loc forthLoc = locRay.Loc + locRay.Dir.GetLoc(); bool hasAdjacent = false; bool hasCondition = false; for (int ii = 0; ii < plan.Adjacents.Count; ii++) { IFloorRoomPlan adjacentPlan = map.RoomPlan.GetRoomHall(plan.Adjacents[ii]); if (Collision.InBounds(adjacentPlan.RoomGen.Draw, forthLoc)) { hasAdjacent = true; if (BaseRoomFilter.PassesAllFilters(adjacentPlan, this.Filters)) { hasCondition = true; break; } } } if (!hasAdjacent) { //in the case where the extending tile is within no adjacents // all normal walls shall be turned into impassables // everything else is saved into the lock list sealBorderTile(map, sealList, SealType.Locked, forthLoc); return(true); } else if (!hasCondition) { //in the case where the extending tile is within an adjacent and that adjacent DOESNT pass filter // all normal walls for the INWARD border shall be turned into impassables // everything else for the INWARD border shall be saved into a key list if (map.Tiles[forthLoc.X][forthLoc.Y].TileEquivalent(map.RoomTerrain)) { sealBorderTile(map, sealList, SealType.Key, locRay.Loc); } else { sealBorderTile(map, sealList, SealType.Locked, locRay.Loc); } //when transitioning between inward and outward //-when transitioning from outward to inward, the previous outward tile needs an inward check //-when transitioning from inward to outward, the current outward tile needs a inward check //in the interest of trading redundancy for simplicity, an inward block will just block the tiles to the sides //regardless of if they've already been blocked //redundancy will be handled by hashsets if (side1 != Dir8.None) { Loc sideLoc = locRay.Loc + side1.GetLoc(); sealBorderTile(map, sealList, SealType.Locked, sideLoc); } if (side2 != Dir8.None) { Loc sideLoc = locRay.Loc + side2.GetLoc(); sealBorderTile(map, sealList, SealType.Locked, sideLoc); } return(false); } else { //in the case where the extending tile is within an adjacent and that adjacent passes filter // do nothing and skip these tiles return(true); } }
protected bool IsBlocked(QueryMethod queryMethod, int x, int y, Dir8 dir) { Loc loc = new Loc(x, y) + dir.GetLoc(); return(queryMethod(loc.X, loc.Y)); }