Exemplo n.º 1
0
        public GameEntity(GamePoint3D Position, GamePoint2D Size, int Id, GameWorld gameWorld)
        {
            pos          = Position;
            id           = Id;
            spd          = new GamePoint3D();
            frc          = new GamePoint3D(1.2d, 1.2d, 1.01d); //friction system needs to be changed to support different areas, like just going through air
            base_spd     = new GamePoint3D(1d, 0.5d, 0.75d);   //    or walking on something, which have different frictions
            spd_deadzone = new GamePoint3D(0.2d, 0.2d, 0.3d);
            direction    = 0f;
            pitch        = 0f;
            size         = Size;
            precision    = 0.2f; //higher number = chunkier collision checks (faster but crappier)

            BufferStream buff = new BufferStream(1024, 1);

            buff.Write((ushort)4);
            buff.Write(id);
            buff.Write(pos.X);
            buff.Write(pos.Y);
            buff.Write(pos.Z);
            buff.Write(size.X);
            buff.Write(size.Y);
            buff.Write(direction);
            buff.Write(pitch);
            gameWorld.sendToAllClients(buff);
            buff.Deallocate();
        }
Exemplo n.º 2
0
        public static double point_distance(GamePoint2D a, GamePoint2D b)
        {
            double xx = b.X - a.X;
            double yy = b.Y - a.Y;

            return(Math.Sqrt((xx * xx) + (yy * yy)));
        }
Exemplo n.º 3
0
        public GamePoint2D Multiply(GamePoint2D a)
        {
            GamePoint2D tmp = Multiply(this, a);

            X = tmp.X;
            Y = tmp.Y;
            return(this);
        }
Exemplo n.º 4
0
        public GamePoint2D Max(GamePoint2D a)
        {
            GamePoint2D tmp = Max(this, a);

            X = tmp.X;
            Y = tmp.Y;
            return(this);
        }
Exemplo n.º 5
0
        public GamePoint2D Divide(GamePoint2D a)
        {
            GamePoint2D tmp = Divide(this, a);

            X = tmp.X;
            Y = tmp.Y;
            return(this);
        }
Exemplo n.º 6
0
        public GamePoint2D Add(GamePoint2D a)
        {
            GamePoint2D tmp = Add(this, a);

            X = tmp.X;
            Y = tmp.Y;
            return(this);
        }
Exemplo n.º 7
0
        public GamePoint2D Subtract(GamePoint2D a)
        {
            GamePoint2D tmp = Subtract(this, a);

            X = tmp.X;
            Y = tmp.Y;
            return(this);
        }
Exemplo n.º 8
0
        public static bool rectangle_in_rectangle(GamePoint2D s1, GamePoint2D s2, GamePoint2D d1, GamePoint2D d2)
        {
            GamePoint2D a1 = s1.Min(s2);
            GamePoint2D a2 = s2.Max(s1);
            GamePoint2D b1 = d1.Min(d2);
            GamePoint2D b2 = d2.Max(d1);

            return(a1.X < b2.X && a2.X > b1.X && a1.Y < b2.Y && a2.Y > b1.Y);
        }
Exemplo n.º 9
0
        public GamePoint3D Min(GamePoint2D a)
        {
            GamePoint3D tmp = Min(this, a);

            X = tmp.X;
            Y = tmp.Y;
            Z = tmp.Z;
            return(this);
        }
Exemplo n.º 10
0
 public bool createEntity(GamePoint3D position, GamePoint2D size)
 {
     //returns if successful
     if (entityMap.Count < maxEntities)
     {
         for (int i = 0; i < maxEntities; i += 1)
         {
             if (!entityMap.ContainsKey(i))
             {
                 entityMap.Add(i, new GameEntity(position, size, i, this));
                 return(true);
             }
         }
     }
     return(false);
 }
Exemplo n.º 11
0
        public int createPlayer(GamePoint3D position, GamePoint2D size, TcpClientHandler client)
        {
            //this will ignore the max entity limit, however cannot ignore the max connection limit
            //returns if successful
            int i = 0;

            if (clientMap.Count < gameServer.MaxConnections)
            {
                while (entityMap.ContainsKey(i)) //looks to find the lowest open slot to make an entity
                {
                    i += 1;
                }
                entityMap.Add(i, new GameEntity(position, size, i, this));
                clientMap.Add(i, new GameClient(client, i, this));
            }
            return(i);
        }
Exemplo n.º 12
0
 public static GamePoint2D operator /(GamePoint2D left, GamePoint2D right)
 {
     return(GamePoint2D.Divide(left, right));
 }
Exemplo n.º 13
0
 public static double point_direction(GamePoint2D a, GamePoint2D b)
 {
     return(Math.Atan2(b.Y - a.Y, b.X - a.X));
 }
Exemplo n.º 14
0
 public static GamePoint3D Divide(GamePoint3D a, GamePoint2D b)
 {
     return(new GamePoint3D(a.X / b.X, a.Y / b.Y, a.Z));
 }
Exemplo n.º 15
0
 public static GamePoint3D Max(GamePoint3D a, GamePoint2D b)
 {
     return(new GamePoint3D((a.X < b.X) ? b.X : a.X, (a.Y < b.Y) ? b.Y : a.Y, a.Z));
 }
Exemplo n.º 16
0
 public static GamePoint3D Subtract(GamePoint3D a, GamePoint2D b)
 {
     return(new GamePoint3D(a.X - b.X, a.Y - b.Y, a.Z));
 }
Exemplo n.º 17
0
 public static GamePoint3D Multiply(GamePoint3D a, GamePoint2D b)
 {
     return(new GamePoint3D(a.X * b.X, a.Y * b.Y, a.Z));
 }
Exemplo n.º 18
0
 public static GamePoint3D Add(GamePoint3D a, GamePoint2D b)
 {
     return(new GamePoint3D(a.X + b.X, a.Y + b.Y, a.Z));
 }
Exemplo n.º 19
0
 public static GamePoint2D Min(GamePoint2D a, GamePoint2D b)
 {
     return(new GamePoint2D((a.X > b.X) ? b.X : a.X, (a.Y > b.Y) ? b.Y : a.Y));
 }
Exemplo n.º 20
0
 public static GamePoint2D operator +(GamePoint2D left, GamePoint2D right)
 {
     return(GamePoint2D.Add(left, right));
 }
Exemplo n.º 21
0
 public static GamePoint2D operator *(GamePoint2D left, GamePoint2D right)
 {
     return(GamePoint2D.Multiply(left, right));
 }
Exemplo n.º 22
0
 public static GamePoint2D operator -(GamePoint2D left, GamePoint2D right)
 {
     return(GamePoint2D.Subtract(left, right));
 }