Exemplo n.º 1
0
        public void AddAvailableCommand(string key, string value)
        {
            string s;

            if (AvailableCommandsDictionary.TryGetValue(key, out s))
            {
                return;
            }

            AvailableCommandsDictionary.TryAdd(key, value);
            ServerDA.AddServerCommand(key, value);
        }
Exemplo n.º 2
0
 private ServerStatusSingleton()
 {
     PendingCommandsToRun        = new ConcurrentQueue <string>();
     CurrentPlayers              = new ConcurrentDictionary <int, Player>();
     AvailableCommandsDictionary = ServerDA.GetServerCommands();
 }
Exemplo n.º 3
0
        public void DrawLocationHistory(Player p, DateTime?oldestTimeStamp)
        {
            if (p == null)
            {
                return;
            }

            //where to save the picture? needs to be a config location, preferably ftp based so we can throw it to a website
            const string plainMapLocation = "C:\\temp\\";
            var          resultLocation   = "C:\\temp\\" + p.Name + "(" + p.GUID + ")";

            Bitmap map = null;

            if (ServerDA.GetCombinedServerMap(plainMapLocation))
            {
                map = new Bitmap(plainMapLocation);
            }

            if (map == null)
            {
                var extents = DetermineImageExtent(p);
                map = new Bitmap((int)Math.Ceiling(extents.Item2.X - extents.Item1.X), (int)Math.Ceiling(extents.Item2.Y - extents.Item1.Y));
            }

            var flagGfx = Graphics.FromImage(map);

            flagGfx.SmoothingMode     = SmoothingMode.AntiAlias;
            flagGfx.InterpolationMode = InterpolationMode.HighQualityBicubic;
            flagGfx.PixelOffsetMode   = PixelOffsetMode.HighQuality;

            var playerLocations = p.GetLocationHistory(oldestTimeStamp);

            if (playerLocations != null && playerLocations.Count > 0)
            {
                int i = 0;
                foreach (var playerLocation in playerLocations)
                {
                    if (i == 0) //for the  most recent location, make it red
                    {
                        flagGfx.FillEllipse(Brushes.Red, (int)playerLocation.X, (int)playerLocation.Y, 5, 5);

                        i++;
                    }
                    else //all subsequent locations should be in pink,
                         //todo it would be cool if each subsequent location was lighter red until the last step which would be barely pink
                         //todo would also be nice if we drew lines between the points to show how the person was moving
                    {
                        flagGfx.FillEllipse(Brushes.Pink, (int)playerLocation.X, (int)playerLocation.Y, 5, 5);
                    }

                    flagGfx.Save();

                    //now put the location
                    flagGfx.DrawString(string.Format("({0},{1}) - 1", playerLocation.X, playerLocation.Y), new Font("Tahoma", 8),
                                       Brushes.Black, (int)playerLocation.X - 5, (int)playerLocation.Y - 5);
                }
            }

            foreach (var currentPlayer in CurrentPlayers)
            {
                if (currentPlayer.Value == null || currentPlayer.Value.Position == null)
                {
                    continue;
                }

                flagGfx.FillEllipse(Brushes.Green, (int)currentPlayer.Value.Position.Value.X, (int)currentPlayer.Value.Position.Value.Y, 5, 5);
            }

            flagGfx.Save();

            using (var fs = new FileStream(resultLocation, FileMode.OpenOrCreate))
            {
                map.Save(fs, ImageFormat.Bmp);
            }
        }
Exemplo n.º 4
0
 private void Refresh()
 {
     ServerDA.GetPendingCommands(ref PendingCommandsToRun, SettingsSingleton.Instance.ServerId);
 }