public bool Intersects(BoundingCylinder other)
        {
            float maxDistance = Radius + other.Radius;

            Vector3 distance = Point - other.Point;
            distance.Y = 0.0f;

            return Top >= other.Bottom && other.Top >= Bottom && distance.LengthSquared() <= maxDistance * maxDistance;
        }
示例#2
0
        public bool Intersects(BoundingCylinder other)
        {
            float maxDistance = Radius + other.Radius;

            Vector3 distance = Point - other.Point;

            distance.Y = 0.0f;

            return(Top >= other.Bottom && other.Top >= Bottom && distance.LengthSquared() <= maxDistance * maxDistance);
        }
        public bool Contains(BoundingCylinder other)
        {
            float maxDistance = Radius - other.Radius;

            if (maxDistance < 0.0f)
                return false;

            Vector3 distance = Point - other.Point;
            distance.Y = 0.0f;

            return Bottom <= other.Bottom && Top >= other.Top && distance.LengthSquared() <= maxDistance * maxDistance;
        }
示例#4
0
        public bool Contains(BoundingCylinder other)
        {
            float maxDistance = Radius - other.Radius;

            if (maxDistance < 0.0f)
            {
                return(false);
            }

            Vector3 distance = Point - other.Point;

            distance.Y = 0.0f;

            return(Bottom <= other.Bottom && Top >= other.Top && distance.LengthSquared() <= maxDistance * maxDistance);
        }
示例#5
0
        public void Start()
        {
            string ip = ((IPEndPoint)Socket.RemoteEndPoint).Address.ToString();

            Console.WriteLine("Client connected from {0}", ip);

            var packet = new NetworkPacket();

            Vector3 leprechaunPosition = Server.Terrain.GetHeight(Config.PlayerPositions[PlayerId]);

            try
            {
                Send(new NetworkPacketWelcome(PlayerId, Config.PlayerColors[PlayerId], leprechaunPosition, Config.RainbowPositions[PlayerId]));

                Server.ItemsManager.SendAll(this);
                Server.TrapManager.AddPlayer(this);

                const float goldpotRadius = Config.GoldpotCylinderRadius * Config.GoldpotScale;
                const float goldpotHeight = Config.GoldpotCylinderHeight * Config.GoldpotScale;

                Rainbow = new BoundingCylinder(Config.RainbowCylinderRadius, Config.RainbowCylinderHeight, Config.RainbowPositions[PlayerId]);
                Goldpot = new BoundingCylinder(goldpotRadius, goldpotHeight, Config.GoldpotPosition);

                var buffer = new byte[Config.BufferSize];

                while (true)
                {
                    if (Socket.Receive(buffer, 1, SocketFlags.None) == 0)
                        return;

                    packet.Type = buffer[0];

                    if (Socket.Receive(buffer, 1, SocketFlags.None) == 0)
                        return;

                    packet.Size = buffer[0];

                    int received = 0;

                    while (received < packet.Size)
                    {
                        int count;

                        if ((count = Socket.Receive(packet.Data, received, packet.Size - received, SocketFlags.None)) == 0)
                            return;

                        received += count;
                    }

                    ProcessPacket(packet);

                    Server.Send(packet, this);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Console.WriteLine("Client disconnected from {0}", ip);

                Server.OnClientFinish(this);
            }
        }
        private bool CheckPigEscape(BoundingCylinder cylinder, float elapsed, Vector3 velocity)
        {
            BoundingCylinder pigCylinder = Pig.GetBoundingCylinder();

            BoundingCylinder newPigCylinder = pigCylinder;
            newPigCylinder.Point = Pig.Position + velocity * elapsed;

            return cylinder.Contains(pigCylinder) && !cylinder.Contains(newPigCylinder);
        }