Esempio n. 1
0
 static extern void native_host_broadcast(ENetHost *host, byte channelID, ENetPacket *packet);
Esempio n. 2
0
        private const double REFRESH_RATE = 16.666; // 60 fps

        public bool initialize(ENetAddress address, string baseKey)
        {
            if (enet_initialize() < 0)
                return false;

            _server = enet_host_create(&address, new IntPtr(32), new IntPtr(32), 0, 0);
            if (_server == null)
                return false;

            var key = System.Convert.FromBase64String(baseKey);

            if (key.Length <= 0)
                return false;

            fixed (byte* s = key)
            {
                _blowfish = BlowFishCS.BlowFishCS.BlowFishCreate(s, new IntPtr(16));
            }

            PacketHandlerManager.getInstace().InitHandlers(this);

            map = new SummonersRift(this);

            PacketNotifier.setMap(map);
            //TODO: better lua implementation

            var id = 1;
            foreach (var p in Config.players)
            {
                var player = new ClientInfo(p.Value.rank, ((p.Value.team.ToLower() == "blue") ? TeamId.TEAM_BLUE : TeamId.TEAM_PURPLE), p.Value.ribbon, p.Value.icon);

                player.setName(p.Value.name);

                player.setSkinNo(p.Value.skin);
                player.userId = id; // same as StartClient.bat
                id++;

                player.setSummoners(strToId(p.Value.summoner1), strToId(p.Value.summoner2));

                Champion c = ChampionFactory.getChampionFromType(p.Value.champion, map, GetNewNetID(), (int)player.userId);
                var pos = c.getRespawnPosition();

                c.setPosition(pos.Item1, pos.Item2);
                c.setTeam((p.Value.team.ToLower() == "blue") ? TeamId.TEAM_BLUE : TeamId.TEAM_PURPLE);
                c.levelUp();

                player.setChampion(c);
                var pair = new Pair<uint, ClientInfo>();
                pair.Item2 = player;
                players.Add(pair);
            }

            // Uncomment the following to get 2-players
            /*ClientInfo* player2 = new ClientInfo("GOLD", TEAM_PURPLE);
            player2->setName("tseT");
            Champion* c2 = ChampionFactory::getChampionFromType("Ezreal", map, GetNewNetID());
            c2->setPosition(100.f, 273.55f);
            c2->setTeam(1);
            map->addObject(c2);
            player2->setChampion(c2);
            player2->setSkinNo(4);
            player2->userId = 2; // same as StartClient.bat
            player2->setSummoners(SPL_Ignite, SPL_Flash);

            players.push_back(player2);*/

            return _isAlive = true;
        }
Esempio n. 3
0
 public override int host_service(ENetHost *host, out ENetEvent @event, uint timeout)
 {
     return(native_host_service(host, out @event, timeout));
 }
Esempio n. 4
0
 static extern void native_host_bandwidth_limit(ENetHost *host, uint incomingBandwidth, uint outgoingBandwidth);
Esempio n. 5
0
 public override void host_destroy(ENetHost *host)
 {
     native_host_destroy(host);
 }
Esempio n. 6
0
 public override void host_flush(ENetHost *host)
 {
     native_host_flush(host);
 }
Esempio n. 7
0
 public override ENetPeer *host_connect(ENetHost *host, ref ENetAddress address, IntPtr channelCount, uint data)
 {
     return(native_host_connect(host, ref address, channelCount, data));
 }
Esempio n. 8
0
 public override int host_compress_with_range_encoder(ENetHost *host)
 {
     return(native_host_compress_with_range_encoder(host));
 }
Esempio n. 9
0
 public override void host_compress(ENetHost *host, ENetCompressor *compressor)
 {
     native_host_compress(host, compressor);
 }
Esempio n. 10
0
 public override int host_check_events(ENetHost *host, out ENetEvent @event)
 {
     return(native_host_check_events(host, out @event));
 }
Esempio n. 11
0
 public override void host_channel_limit(ENetHost *host, IntPtr channelLimit)
 {
     native_host_channel_limit(host, channelLimit);
 }