Esempio n. 1
0
 public static bool IsOppositeTile(int x, int y, ushort w, ushort h, TileType areaType, 
     ClientMap map)
 {
     if (x < 0 || x >= w || y < 0 || y >= h)
     {
         return true;
     }
     Tile* tile;
     return (tile = map[(ushort) x, (ushort) y]) != null && (*tile).Type != areaType;
 }
Esempio n. 2
0
        public static int ScanAndSetBorders(ushort x, ushort y, TileType areaType, 
            ClientMap map)
        {
            ushort w = map.Width, h = map.Height;

            byte borders = 0;

            if (!IsOppositeTile(x, y, w, h, areaType, map))
            {
                if (IsOppositeTile(x - 1, y, w, h, areaType, map)) borders |= 2;
                if (IsOppositeTile(x + 1, y, w, h, areaType, map)) borders |= 4;
                if (IsOppositeTile(x, y - 1, w, h, areaType, map)) borders |= 8;
                if (IsOppositeTile(x, y + 1, w, h, areaType, map)) borders |= 16;
            }

            if (borders == 0) borders = 1;

            map.FlagSetBorders(x, y, borders);

            return borders;
        }
Esempio n. 3
0
        private void InitializeEnvironment()
        {
            _map = new ClientMap();

            _syncScroll = new object();

            _fpsCounterData = new byte[10];
            _fpsFontBrush = new SolidBrush(Color.White);

            _playersData = new Dictionary<int, PlayerDataEx>();

            _threadWorld = new Thread(WorldProcessingProc);
            _threadWorld.IsBackground = true;
            _threadWorld.Start();

            _threadObjectChanged = new Thread(ObjectChangedProc);
            _threadObjectChanged.IsBackground = true;
            _threadObjectChanged.Start();

            TCPClientSettings settings = new TCPClientSettings
                (
                ushort.MaxValue, "127.0.0.1", 15051, true
                );
            _tcpClient = new TCPClient(settings);
            _tcpClient.Connected += TCPConnected;
            _tcpClient.DataReceived += TCPDataReceived;
            _tcpClient.Disconnected += TCPDisconnected;
        }