示例#1
0
        public void StopMusic()
        {
            if (playbackThread != null)
            {
                //Stop the music.
                //abortMusic = true;
                //stopResetEvent.Reset();
                //stopResetEvent.WaitOne();

                if (loadedStream != IntPtr.Zero)
                {
                    currentSong = null;
                    lock (audioDataCache) {
                        for (int i = 0; i < audioDataCache.Count; i++)
                        {
                            if (audioDataCache.ValueByIndex(i).AudioStreamPointer == loadedStream)
                            {
                                audioDataCache.ValueByIndex(i).AudioStreamPointer = IntPtr.Zero;
                            }
                        }
                    }
                    Bass.BASS_StreamFree(loadedStream);
                    Bass.BASS_ChannelStop(loadedStream);
                    loadedStream = IntPtr.Zero;
                }
                if (playbackThread != null)
                {
                    playbackThread.Abort();
                    playbackThread = null;
                }
            }
        }
示例#2
0
        public GnpClient GetGnpClient(TClientID clientID)
        {
            int index = clients.IndexOfKey(clientID);

            if (index > -1)
            {
                return(clients.ValueByIndex(index));
            }
            else
            {
                return(null);
            }
        }
示例#3
0
        private IEnumerable <IMap> GetBorderingMaps(ListPair <IMap, Object[]> borderingMapCollection, IMap centralMap)
        {
            int mapIndex = borderingMapCollection.IndexOfKey(centralMap);

            if (mapIndex > -1)
            {
                Object[] maps = borderingMapCollection.ValueByIndex(mapIndex);
                foreach (IMap map in maps)
                {
                    if (map != null)
                    {
                        yield return(map);
                    }
                }
            }
            else
            {
                Object[] maps = new object[9];
                for (int borderingMapID = 0; borderingMapID < 9; borderingMapID++)
                {
                    if (MapManager.IsBorderingMapLoaded(centralMap, (Enums.MapID)borderingMapID))
                    {
                        IMap borderingMap = MapManager.RetrieveBorderingMap(centralMap, (Enums.MapID)borderingMapID, true);
                        if (borderingMap != null)
                        {
                            maps[borderingMapID] = borderingMap;
                            yield return(borderingMap);
                        }
                    }
                }
                borderingMapCollection.Add(centralMap, maps);
            }
        }
示例#4
0
文件: Inventory.cs 项目: pzaps/Server
 public Inventory(ListPair<int, DataManager.Characters.InventoryItem> loadedInventory)
 {
     items = new ListPair<int, InventoryItem>();
     for (int i = 0; i < loadedInventory.Count; i++) {
         items.Add(loadedInventory.KeyByIndex(i), new InventoryItem(loadedInventory.ValueByIndex(i)));
     }
 }
示例#5
0
 public Inventory(ListPair <int, DataManager.Characters.InventoryItem> loadedInventory)
 {
     items = new ListPair <int, InventoryItem>();
     for (int i = 0; i < loadedInventory.Count; i++)
     {
         items.Add(loadedInventory.KeyByIndex(i), new InventoryItem(loadedInventory.ValueByIndex(i)));
     }
 }
示例#6
0
        public static Party FindParty(string partyID)
        {
            Party party = null;

            rwLock.EnterReadLock();
            try {
                int partyIndex = parties.IndexOfKey(partyID);
                if (partyIndex > -1)
                {
                    party = parties.ValueByIndex(partyIndex);
                }
            } finally {
                rwLock.ExitReadLock();
            }
            return(party);
        }
示例#7
0
 /// <summary>
 /// Finds a connected players index based on their player id
 /// </summary>
 /// <param name="playerID">The id of the player to find</param>
 /// <returns>The players index if found; otherwise, returns -1</returns>
 public static TcpClientIdentifier FindTcpID(string playerID)
 {
     rwLock.EnterReadLock();
     try {
         int index = playerIDToTcpIDList.IndexOfKey(playerID);
         if (index > -1)
         {
             return(playerIDToTcpIDList.ValueByIndex(index));
         }
         else
         {
             return(null);
         }
     } finally {
         rwLock.ExitReadLock();
     }
 }
示例#8
0
        private IEnumerable <Client> GetMapClients(ListPair <IMap, List <Client> > clientCollection, IMap map)
        {
            int mapIndex = clientCollection.IndexOfKey(map);

            if (mapIndex > -1)
            {
                List <Client> clients = clientCollection.ValueByIndex(mapIndex);
                foreach (Client client in clients)
                {
                    yield return(client);
                }
            }
            else
            {
                List <Client> clients = new List <Client>();
                foreach (Client client in map.GetClients())
                {
                    clients.Add(client);
                    yield return(client);
                }
                clientCollection.Add(map, clients);
            }
        }
示例#9
0
 private IEnumerable<Client> GetMapClients(ListPair<IMap, List<Client>> clientCollection, IMap map)
 {
     int mapIndex = clientCollection.IndexOfKey(map);
     if (mapIndex > -1) {
         List<Client> clients = clientCollection.ValueByIndex(mapIndex);
         foreach (Client client in clients) {
             yield return client;
         }
     } else {
         List<Client> clients = new List<Client>();
         foreach (Client client in map.GetClients()) {
             clients.Add(client);
             yield return client;
         }
         clientCollection.Add(map, clients);
     }
 }
示例#10
0
 private IEnumerable<IMap> GetBorderingMaps(ListPair<IMap, Object[]> borderingMapCollection, IMap centralMap)
 {
     int mapIndex = borderingMapCollection.IndexOfKey(centralMap);
     if (mapIndex > -1) {
         Object[] maps = borderingMapCollection.ValueByIndex(mapIndex);
         foreach (IMap map in maps) {
             if (map != null) {
                 yield return map;
             }
         }
     } else {
         Object[] maps = new object[9];
         for (int borderingMapID = 0; borderingMapID < 9; borderingMapID++) {
             if (MapManager.IsBorderingMapLoaded(centralMap, (Enums.MapID)borderingMapID)) {
                 IMap borderingMap = MapManager.RetrieveBorderingMap(centralMap, (Enums.MapID)borderingMapID, true);
                 if (borderingMap != null) {
                     maps[borderingMapID] = borderingMap;
                     yield return borderingMap;
                 }
             }
         }
         borderingMapCollection.Add(centralMap, maps);
     }
 }
 public static void SavePlayerInventoryUpdates(MySql database, string charID, ListPair<int, Characters.InventoryItem> updateList)
 {
     for (int i = 0; i < updateList.Count; i++) {
         Characters.InventoryItem invItem = updateList.ValueByIndex(i);
         database.UpdateOrInsert("inventory", new IDataColumn[] {
             database.CreateColumn(false, "CharID", charID),
             database.CreateColumn(false, "ItemSlot", updateList.KeyByIndex(i).ToString()),
             database.CreateColumn(false, "ItemNum", invItem.Num.ToString()),
             database.CreateColumn(false, "Amount", invItem.Amount.ToString()),
             database.CreateColumn(false, "Sticky", invItem.Sticky.ToIntString()),
             database.CreateColumn(false, "Tag", invItem.Tag)
         });
     }
 }
        public static void SavePlayerBankUpdates(MySql database, string charID, ListPair<int, Characters.InventoryItem> updateList)
        {
            MultiRowInsert multiRowInsert = new MultiRowInsert(database, "bank", "CharID", "ItemSlot", "ItemNum",
                "Amount", "Sticky", "Tag");

            for (int i = 0; i < updateList.Count; i++) {
                Characters.InventoryItem invItem = updateList.ValueByIndex(i);

                multiRowInsert.AddRowOpening();

                multiRowInsert.AddColumnData(charID);
                multiRowInsert.AddColumnData(updateList.KeyByIndex(i), invItem.Num, invItem.Amount);
                multiRowInsert.AddColumnData(invItem.Sticky.ToIntString(), invItem.Tag);

                multiRowInsert.AddRowClosing();
            }

            database.ExecuteNonQuery(multiRowInsert.GetSqlQuery());
        }
示例#13
0
 public Tournament this[int index]
 {
     get { return(tournaments.ValueByIndex(index)); }
 }