示例#1
0
        public Boolean Collides(OrientedBoundingBox box)
        {
            try
            {
                GridBlockCollection gridBlockCollection = GridBlocks.GetBlocksNearBoundingBox(box);
                if (gridBlockCollection == null)
                {
                    return(true);
                }

                if (gridBlockCollection.Any(gridBlock => box.Collides(gridBlock.LowBox) || box.Collides(gridBlock.MidBox) || (box.Collides(gridBlock.HighBox) && !gridBlock.HasSkybox)))
                {
                    return(true);
                }

                if (gridBlockCollection.Where(gridBlock => gridBlock.LowBoxTile != null).Any(gridBlock => gridBlock.LowBoxTile.TileBlocks.Where(tileBlock => tileBlock.BottomBoundingBox != null).Any(tileBlock => box.Collides(tileBlock.BottomBoundingBox))))
                {
                    return(true);
                }

                if (Triggers.Where(t => t.TriggerType == TriggerType.Elevator).Where(t => (Int32)System.Math.Floor(box.Origin.X / 64) == t.X1 && (Int32)System.Math.Floor(box.Origin.Y / 64) == t.Y1).Any(t => box.Origin.Z > t.OffHeight && box.Origin.Z < t.Position.Z))
                {
                    return(true);
                }
            }
            catch (Exception)
            {
                return(true);
            }

            return(false);
        }
示例#2
0
        public Sign(Int16 objectId, ArenaPlayer owner, Spell spell, Vector3 location, Single direction, Byte[] rawData)
        {
            if (spell == SpellManager.CTFOrbSpell)
            {
                IsCTFOrb = true;
            }

            RawData     = rawData;
            RawData[13] = 0;

            ObjectId    = objectId;
            Owner       = owner;
            Team        = spell.NoTeam ? Team.None : owner.ActiveTeam;
            Spell       = spell;
            Location    = new Vector3(location.X, location.Y, location.Z);
            Direction   = direction;
            Location.X += (Single)(-spell.CastDistance * Math.Sin(Direction)) - (spell.Width * 0.5f);
            Location.Y += (Single)(spell.CastDistance * Math.Cos(Direction)) - (spell.Width * 0.5f);
            Location.Z  = (Location.Z + spell.Elevation) - (spell.Tall * 0.25f);
            BoundingBox = new OrientedBoundingBox(Location, new Vector3(spell.Width, spell.Width, spell.Tall), Direction);

            Duration = new Interval(Spell.DurationTimer, false);

            OwnerDistance = Vector3.Distance(BoundingBox.Origin, Owner.BoundingBox.Origin);

            if (IsAura)
            {
                AuraBoundingSphere = new BoundingSphere(BoundingBox.Origin, (Spell.EffectRadius * 2) + (owner.BoundingBox.ExtentSphere.Radius * 3));
                AuraEffectSphere   = new BoundingSphere(BoundingBox.Origin, Spell.EffectRadius);

                AuraPulse  = new Interval(Spell.AuraPulseTimer, true);
                AuraHealth = Spell.AuraHealth;
            }
        }
 public GridBlockCollection GetBlocksNearBoundingBox(OrientedBoundingBox boundingBox)
 {
     return(new GridBlockCollection(false)
     {
         GetBlockByLocation(boundingBox.Origin.X, boundingBox.Origin.Y),
         GetBlockByLocation(boundingBox.Corners[0].X, boundingBox.Corners[0].Y),
         GetBlockByLocation(boundingBox.Corners[1].X, boundingBox.Corners[1].Y),
         GetBlockByLocation(boundingBox.Corners[2].X, boundingBox.Corners[2].Y),
         GetBlockByLocation(boundingBox.Corners[3].X, boundingBox.Corners[3].Y)
     });
 }
示例#4
0
        public Boolean LineToBoxIsBlocked(Vector3 startPoint, OrientedBoundingBox targetBox)
        {
            try
            {
                if (targetBox.Corners.Any(t => GridBlocks.GetBlocksInLine(startPoint, t).Count > 0))
                {
                    if (GridBlocks.GetBlocksInLine(startPoint, targetBox.Origin).Count > 0)
                    {
                        return(true);
                    }
                }

                GridBlockCollection gridBlockCollection = GridBlocks.GetBlocksAroundLine(startPoint, targetBox.Origin);

                foreach (GridBlock gridBlock in gridBlockCollection)
                {
                    if (gridBlock.LowBoxTile != null)
                    {
                        foreach (TileBlock tileBlock in gridBlock.LowBoxTile.TileBlocks)
                        {
                            if (tileBlock.TopBoundingBox != null)
                            {
                                if (tileBlock.TopBoundingBox.LineInBox(startPoint, targetBox.Origin))
                                {
                                    return(true);
                                }
                            }

                            if (tileBlock.BottomBoundingBox != null)
                            {
                                if (tileBlock.BottomBoundingBox.LineInBox(startPoint, targetBox.Origin))
                                {
                                    return(true);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                return(true);
            }

            return(false);
        }
        public GridBlock GetHighestGravityBlock(OrientedBoundingBox boundingBox)
        {
            GridBlockCollection gridBlockCollection = GetBlocksNearBoundingBox(boundingBox);

            for (Int32 i = gridBlockCollection.Count - 1; i > 0; i--)
            {
                if (gridBlockCollection[i].LowBoxTopZ < gridBlockCollection[i - 1].LowBoxTopZ)
                {
                    gridBlockCollection.RemoveAt(i);
                }
                else
                {
                    gridBlockCollection.RemoveAt(i - 1);
                }
            }

            return(gridBlockCollection[0]);
        }
示例#6
0
        public Wall(Int16 objectId, ArenaPlayer owner, Spell spell, Vector3 location, Single direction, Byte[] rawData)
        {
            RawData     = rawData;
            RawData[13] = 0;

            ObjectId  = objectId;
            Owner     = owner;
            Team      = Owner.ActiveTeam;
            Spell     = spell;
            CurrentHp = spell.HitPoints;
            Location  = new Vector3(location.X, location.Y, location.Z);

            Location.X += (Single)(-(spell.CastDistance + (spell.Thick * 0.5f)) * Math.Sin(direction)) - (spell.Length * 0.5f);
            Location.Y += (Single)((spell.CastDistance + (spell.Thick * 0.5f)) * Math.Cos(direction)) - (spell.Thick * 0.5f);

            Direction = direction;

            BoundingBox = new OrientedBoundingBox(Location, new Vector3(spell.Length, spell.Thick, spell.MaxWallHeight), direction);

            Duration         = new Interval(Spell.DurationTimer, false);
            WeakenedDuration = null;
        }
示例#7
0
        public Boolean TileCollides(OrientedBoundingBox box)
        {
            GridBlockCollection gridBlockCollection = GridBlocks.GetBlocksNearBoundingBox(box);

            if (gridBlockCollection.Count == 0)
            {
                return(false);
            }

            foreach (GridBlock gridBlock in gridBlockCollection)
            {
                if (gridBlock != null && gridBlock.LowBoxTile != null)
                {
                    foreach (TileBlock tileBlock in gridBlock.LowBoxTile.TileBlocks)
                    {
                        if (tileBlock.TopBoundingBox != null)
                        {
                            if (box.Collides(tileBlock.TopBoundingBox))
                            {
                                return(true);
                            }
                        }

                        if (tileBlock.BottomBoundingBox != null)
                        {
                            if (box.Collides(tileBlock.BottomBoundingBox))
                            {
                                return(true);
                            }
                        }
                    }
                }
            }

            return(false);
        }
示例#8
0
        public ArenaPlayer(Player player, Arena arena)
        {
            lock (arena.SyncRoot)
            {
                WorldPlayer = player;
                OwnerArena  = arena;

                lock (OwnerArena.ArenaPlayers.SyncRoot)
                {
                    OwnerArena.ArenaPlayers.ForEach(delegate(ArenaPlayer arenaPlayer)
                    {
                        if (arenaPlayer.WorldPlayer == player)
                        {
                            OwnerArena.PlayerLeft(arenaPlayer);
                        }
                    });
                }

                if ((ArenaPlayerId = OwnerArena.ArenaPlayers.GetAvailablePlayerId()) == 0)
                {
                    return;
                }

                WorldPlayer.PingInitialized = false;
                WorldPlayer.TableId         = 0;
                WorldPlayer.ActiveArena     = arena;
                WorldPlayer.LastArenaId     = arena.ArenaId;

                ActiveTeam      = OwnerArena.Ruleset.Rules.HasFlag(ArenaRuleset.ArenaRule.NoTeams) ? Team.Neutral : WorldPlayer.ActiveTeam;
                ActiveCharacter = player.ActiveCharacter;

                _previousLocation     = new Vector3(0, 0, 0);
                _previousLocationTick = 0;

                Location  = new Vector3(0, 0, 0);
                Direction = 0;

                CurrentGridBlock         = null;
                CurrentGridBlockFlagData = new GridBlockFlagData();

                InCombatTime        = new Interval(7000, false);
                NonFriendlyWallTime = new Interval(1000, false);
                FriendlyWallTime    = new Interval(1000, false);
                ValhallaProtection  = new Interval(2000, false);
                ActiveTime          = new Interval(0, false);
                BoundingBox         = new OrientedBoundingBox(Location, PlayerStandingSize, 0.0f);

                StatusFlags  = StatusFlag.None;
                SpecialFlags = SpecialFlag.None;

                Effects = new Effect[21];

                MoveSpeed          = 0;
                StateReceivedCount = 0;
                LastStateReceived  = NativeMethods.PerformanceCount;

                LastAttacker = null;

                JoinTime = DateTime.Now;

                HasFliedSinceHackDetect = false;

                MaxHp = player.ActiveCharacter.MaxHealth;

                if (ActiveShrine == null)
                {
                    if (ActiveTeam == Team.Neutral)
                    {
                        CurrentHp = MaxHp;
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    if (ActiveShrine.IsDisabled)
                    {
                        Network.Send(WorldPlayer, GamePacket.Outgoing.Player.SendPlayerId(this));

                        Thread.Sleep(500);

                        Network.Send(WorldPlayer, GamePacket.Outgoing.Arena.SuccessfulArenaEntry());

                        Thread.Sleep(100);

                        OwnerArena.ArenaKickPlayer(this);

                        return;
                    }

                    CurrentHp = ActiveShrine.IsDead ? (Int16)0 : MaxHp;
                }

                Network.Send(WorldPlayer, GamePacket.Outgoing.Player.SendPlayerId(this));

                if (!WorldPlayer.Flags.HasFlag(PlayerFlag.Hidden))
                {
                    Network.SendTo(WorldPlayer, GamePacket.Outgoing.World.PlayerLeave(WorldPlayer), Network.SendToType.Tavern, false);
                    Network.SendTo(WorldPlayer, GamePacket.Outgoing.World.PlayerJoin(WorldPlayer), Network.SendToType.Tavern, false);

                    Network.SendToArena(this, GamePacket.Outgoing.Arena.PlayerJoin(this), false);
                }

                if (OwnerArena.ArenaPlayerHistory.FindByCharacterId(WorldPlayer.ActiveCharacter.CharacterId) == null)
                {
                    OwnerArena.ArenaPlayerHistory.Add(this);
                }

                WorldPlayer.ActiveArenaPlayer = this;
                OwnerArena.ArenaPlayers.Add(this);

                OwnerArena.AveragePlayerLevel = OwnerArena.ArenaPlayers.GetAveragePlayerLevel();
            }

            lock (OwnerArena.SyncRoot)
            {
                Network.Send(WorldPlayer, GamePacket.Outgoing.Arena.UpdateShrinePoolState(arena));
            }

            Thread.Sleep(500);

            Network.Send(WorldPlayer, GamePacket.Outgoing.Arena.SuccessfulArenaEntry());

            Thread.Sleep(100);

            lock (OwnerArena.SyncRoot)
            {
                for (Int32 i = 0; i < OwnerArena.Signs.Count; i++)
                {
                    Network.Send(WorldPlayer, GamePacket.Outgoing.Arena.CastSign(this, OwnerArena.Signs[i].RawData));
                }
            }

            Thread.Sleep(100);

            lock (OwnerArena.SyncRoot)
            {
                for (Int32 i = 0; i < OwnerArena.Walls.Count; i++)
                {
                    Network.Send(WorldPlayer, GamePacket.Outgoing.Arena.CastWall(arena.Walls[i].RawData));
                }
            }

            Thread.Sleep(100);

            lock (OwnerArena.SyncRoot)
            {
                for (Int32 i = 0; i < arena.Grid.Triggers.Count; i++)
                {
                    Network.Send(WorldPlayer, GamePacket.Outgoing.Arena.ActivatedTrigger(OwnerArena.Grid.Triggers[i]));
                }
            }

            if (OwnerArena.Ruleset.Mode == ArenaRuleset.ArenaMode.Custom)
            {
                Network.Send(WorldPlayer, GamePacket.Outgoing.System.DirectTextMessage(WorldPlayer, String.Format("This arena has the following rules: {0}.", arena.Ruleset.Rules)));
            }

            if (OwnerArena.Ruleset.Rules.HasFlag(ArenaRuleset.ArenaRule.ExpEvent))
            {
                Network.Send(WorldPlayer, GamePacket.Outgoing.System.DirectTextMessage(WorldPlayer, String.Format("If your team wins this match, you will earn {0:0,0} experience.", (WorldPlayer.Flags.HasFlag(PlayerFlag.MagestormPlus) ? OwnerArena.EventExp * 2f : OwnerArena.EventExp))));
            }

            Network.Send(WorldPlayer, GamePacket.Outgoing.System.DirectTextMessage(WorldPlayer, String.Format("This arena currently has an EXP bonus of {0}%.", ((arena.Grid.ExpBonus + (Properties.Settings.Default.ExpMultiplier - 1.0f) + (WorldPlayer.Flags.HasFlag(PlayerFlag.MagestormPlus) ? 0.2f : 0.0f)) * 100))));
        }