Example #1
0
        public void SetupTimeout(ref ConcurrentDictionary <int, Connection> connections, ref IdMap ids)
        {
            refConnections = connections;
            refIds         = ids;

            timeoutTimer           = new Timer(4000);
            timeoutTimer.AutoReset = true;

            timeoutTimer.Elapsed += timeoutEvent;
            timeoutTimer.Start();
        }
Example #2
0
        public Server(short port, int maxPlayers, int maxEntities, int defaultFraction)
        {
            this.defaultFraction = defaultFraction;

            connections   = new ConcurrentDictionary <int, Connection>();
            connectionIds = new IdMap(maxPlayers);

            worldMap = new WorldMap(maxEntities, "map.xml");
            entc     = worldMap.entityContainer;
            socket   = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            socket.Bind(new IPEndPoint(IPAddress.Any, port));
            socket.Listen(maxPlayers);
        }
Example #3
0
        uint entitiesCount; //for id stuff

        public Server(short port, int maxPlayers, int maxEntities, int defaultFraction)
        {
            entitiesCount = 4;
            connections   = new ConcurrentDictionary <int, Connection>();
            connectionIds = new IdMap(maxPlayers);

            socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            socket.Bind(new IPEndPoint(IPAddress.Any, port));
            socket.Listen(maxPlayers);

            game = new Game(ref connections);

            /* Initialize Map */

            Fraction fr1 = new Fraction(ref connections);
            Fraction fr2 = new Fraction(ref connections);
            Fraction fr3 = new Fraction(ref connections);
            Fraction fr4 = new Fraction(ref connections);

            fr1.AddEntity(new Entity(32, 32, 16, 0));
            fr1.AddEntity(new Entity(64, 64, 32, 1));

            fr2.AddEntity(new Entity(608, 32, 16, 2));
            fr2.AddEntity(new Entity(576, 64, 32, 3));

            fr3.AddEntity(new Entity(32, 448, 16, 4));
            fr3.AddEntity(new Entity(64, 416, 32, 5));

            fr4.AddEntity(new Entity(608, 448, 16, 6));
            fr4.AddEntity(new Entity(576, 416, 32, 7));

            game.AddFraction(fr1);
            game.AddFraction(fr2);
            game.AddFraction(fr3);
            game.AddFraction(fr4);

            Thread gameThread = new Thread(game.Run);

            gameThread.Start();
        }
Example #4
0
        // public float xBuffer, yBuffer;
        //   public short sizeBuffer;



        public EntityContainer(int maxEntities)
        {
            entities    = new ConcurrentDictionary <int, Entity>();
            entityIdMap = new IdMap(maxEntities);
        }
Example #5
0
 public void SetupConnection(ref ConcurrentDictionary <int, Connection> connections, ref IdMap ids)
 {
     refConnections = connections;
     refIds         = ids;
 }