public static void smethod_20(Session session_0, ClientMessage clientMessage_0)
        {
            uint          itemId            = clientMessage_0.ReadUnsignedInteger();
            SpaceInstance instanceBySpaceId = SpaceManager.GetInstanceBySpaceId(session_0.CurrentSpaceId);

            if (instanceBySpaceId != null)
            {
                SpaceActor actorByReferenceId = instanceBySpaceId.GetActorByReferenceId(session_0.CharacterId, SpaceActorType.UserCharacter);
                if (actorByReferenceId != null)
                {
                    CharacterInfo referenceObject = (CharacterInfo)actorByReferenceId.ReferenceObject;
                    try
                    {
                        ContestItem item = instanceBySpaceId.Items[itemId];
                        if ((item != null) && item.IsActive)
                        {
                            using (SqlDatabaseClient client = SqlDatabaseManager.GetClient())
                            {
                                item.CatchItem(client, (int)session_0.CharacterId);
                                string definitionName = item.DefinitionName;
                                if (definitionName != null)
                                {
                                    if (definitionName != "cofre_oro")
                                    {
                                        if (!(definitionName == "cofre_plata"))
                                        {
                                            if (definitionName == "")
                                            {
                                                instanceBySpaceId.BroadcastChatMessage(actorByReferenceId, actorByReferenceId.Name + " ha cogido un diamante.", false, 3);
                                                instanceBySpaceId.BroadcastChatMessage(actorByReferenceId, actorByReferenceId.Name + " has caught a diamond", false, 3);
                                            }
                                            else
                                            {
                                                instanceBySpaceId.BroadcastChatMessage(actorByReferenceId, string.Concat(new object[] { actorByReferenceId.Name, " ha atrapado un cofre y obtiene: ", item.SilverCredits, " monedas de plata." }), false, 3);
                                                instanceBySpaceId.BroadcastChatMessage(actorByReferenceId, string.Concat(new object[] { actorByReferenceId.Name, " has caught a chest and obtained: ", item.GoldCredits, " silver credits." }), false, 3);
                                                referenceObject.UpdateSilverCreditsBalance(client, (int)item.SilverCredits);
                                                session_0.SendData(CharacterCoinsComposer.AddSilverCompose(item.SilverCredits), false);
                                            }
                                        }
                                        else
                                        {
                                            instanceBySpaceId.BroadcastChatMessage(actorByReferenceId, string.Concat(new object[] { actorByReferenceId.Name, " ha atrapado un cofre y obtiene: ", item.GoldCredits, " monedas de oro." }), false, 3);
                                            instanceBySpaceId.BroadcastChatMessage(actorByReferenceId, string.Concat(new object[] { actorByReferenceId.Name, " has caught a chest and obtained: ", item.GoldCredits, " gold credits." }), false, 3);
                                            referenceObject.UpdateGoldCreditsBalance(client, (int)item.GoldCredits);
                                            session_0.SendData(CharacterCoinsComposer.AddGoldCompose(item.GoldCredits), false);
                                        }
                                    }
                                }
                                instanceBySpaceId.BroadcastMessage(SpaceCatchItemComposer.Compose(itemId), 0, false);
                                instanceBySpaceId.BroadcastMessage(SpaceRemoveItemComposer.Compose(itemId), 0, false);
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }
Beispiel #2
0
 private ContestItem GetNext(ContestItem curr, GlobalConfig config)
 {
     return(config.Random
         ? config.Items[_random.Next(config.Items.Count)]
         : config.Items
            .SkipWhile(x => x != curr)
            .Skip(1)
            .DefaultIfEmpty(config.Items[0])
            .FirstOrDefault());
 }
        public static ServerMessage Compose(ContestItem Item)
        {
            ServerMessage message = new ServerMessage(FlagcodesOut.SPACE_ITEM, ItemcodesOut.SPACE_ITEM_ADD, false);

            message.AppendParameter(Item.UInt32_0, false);
            message.AppendParameter(Item.SpaceId, false);
            message.AppendParameter(Item.Position.Int32_0, false);
            message.AppendParameter(Item.Position.Int32_1, false);
            message.AppendParameter(Item.DefinitionId, false);
            message.AppendParameter(Item.CatchType, false);
            message.AppendParameter(Item.FallType, false);
            return(message);
        }
Beispiel #4
0
        private void StartRunner()
        {
            if (_queue.Count == 0)
            {
                GenerateReport();
                Close();
                return;
            }

            _curr = _queue.Dequeue();
            if (_curr.Type == ContentItemType.Image && File.Exists(_curr.ImagePath))
            {
                ContestImage.Image     = Image.FromFile(_curr.ImagePath);
                ContestImage.BackColor = BackColor;
            }
            else if (_curr.Type == ContentItemType.Text)
            {
                ContestImage.BackColor = _curr.Color;
                ContestImage.Image     = new Bitmap(ContestImage.Width, ContestImage.Height);
                var g = Graphics.FromImage(ContestImage.Image);

                var text        = "+";
                var contestFont = new Font("Symbol", 96);

                var textSize       = g.MeasureString(text, contestFont);
                var locationToDraw = new PointF
                {
                    X = (ContestImage.Width / 2) - (textSize.Width / 2),
                    Y = (ContestImage.Height / 2) - (textSize.Height / 2)
                };


                g.DrawString(text, contestFont, Brushes.White, locationToDraw);
                g.Dispose();
            }
            else
            {
                ContestImage.Image     = new Bitmap(1, 1);
                ContestImage.BackColor = _curr.Color;
            }


            _timer.Interval = (int)_curr.Delay;
            _timer.Start();
            _swt.Reset();
            _swt.Start();
        }
Beispiel #5
0
        public void Load()
        {
            _log.Info("Загрузка настроек...");
            if (_config.GetSection("framesSettings") is FramesConfigSection frames)
            {
                if (frames.FrameItems.Count == 0)
                {
                    _log.Warn("Не обнаружены настройки для фреймов, используются стандартные настройки");
                    LoadDefaults();
                    return;
                }

                _globalConfig = new GlobalConfig();


                SetProp(out var title, nameof(_globalConfig.Title), s => s, _defaultConfig.Title);
                _globalConfig.Title = title;

                SetProp(out var count, nameof(_globalConfig.Count), uint.Parse, _defaultConfig.Count);
                _globalConfig.Count = count;

                SetProp(out var closeKey, nameof(_globalConfig.CloseKey), s => (Keys)Enum.Parse(typeof(Keys), s),
                        _defaultConfig.CloseKey);
                _globalConfig.CloseKey = closeKey;

                SetProp(out var defdelay, nameof(_globalConfig.DefaultDelay), uint.Parse, _defaultConfig.DefaultDelay);
                _globalConfig.DefaultDelay = defdelay;

                _globalConfig.FrameSize = new FrameSize();
                if (_config.GetSection("framesize") is FrameSizeConfigSection frameSizeConfigSection)
                {
                    _globalConfig.FrameSize.Type   = frameSizeConfigSection.FrameSize.Type;
                    _globalConfig.FrameSize.Width  = frameSizeConfigSection.FrameSize.Width;
                    _globalConfig.FrameSize.Height = frameSizeConfigSection.FrameSize.Height;
                }
                else
                {
                    _globalConfig.FrameSize.Type   = _defaultConfig.FrameSize.Type;
                    _globalConfig.FrameSize.Width  = _defaultConfig.FrameSize.Width;
                    _globalConfig.FrameSize.Height = _defaultConfig.FrameSize.Height;
                }

                SetProp(out var random, nameof(_globalConfig.Random), Convert.ToBoolean, _defaultConfig.Random);
                _globalConfig.Random = random;

                SetProp(out var hideCursor, nameof(_globalConfig.HideCursor), Convert.ToBoolean,
                        _defaultConfig.HideCursor);
                _globalConfig.HideCursor = hideCursor;

                SetProp(out var blscreen, nameof(_globalConfig.Blackscreen), Convert.ToBoolean,
                        _defaultConfig.Blackscreen);
                _globalConfig.Blackscreen = blscreen;

                SetProp(out var contestDebug, nameof(_globalConfig.ContestDebug), Convert.ToBoolean,
                        _defaultConfig.ContestDebug);
                _globalConfig.ContestDebug = contestDebug;

                _globalConfig.Items = new ObservableCollection <ContestItem>();
                foreach (FrameElement frameItem in frames.FrameItems)
                {
                    if (string.Equals(frameItem.Name, "Blackscreen"))
                    {
                        _globalConfig.BlackscreenItem = new ContestItem
                        {
                            Name      = frameItem.Name,
                            Color     = frameItem.Color,
                            Delay     = frameItem.Delay,
                            Key       = frameItem.Key,
                            Type      = frameItem.Type,
                            ImagePath = frameItem.ImagePath
                        };

                        _log.Trace(
                            $"BlackscreenItem.{nameof(frameItem.Color)}='{_globalConfig.BlackscreenItem.Color}'");
                        _log.Trace(
                            $"BlackscreenItem.{nameof(frameItem.Delay)}='{_globalConfig.BlackscreenItem.Delay}'");
                        _log.Trace(
                            $"BlackscreenItem.{nameof(frameItem.Key)}='{_globalConfig.BlackscreenItem.Key}'");
                        _log.Trace(
                            $"BlackscreenItem.{nameof(frameItem.Type)}='{_globalConfig.BlackscreenItem.Type}'");
                        _log.Trace(
                            $"BlackscreenItem.{nameof(frameItem.ImagePath)}='{_globalConfig.BlackscreenItem.ImagePath}'");

                        continue;
                    }

                    var tmpItem = new ContestItem
                    {
                        Name      = frameItem.Name,
                        Color     = frameItem.Color,
                        Delay     = frameItem.Delay,
                        Key       = frameItem.Key,
                        Type      = frameItem.Type,
                        ImagePath = frameItem.ImagePath
                    };
                    _globalConfig.Items.Add(tmpItem);

                    var last = _globalConfig.Items.Last();
                    _log.Trace($"Items.{last.Name}.{nameof(last.Color)}='{last.Color}'");
                    _log.Trace($"Items.{last.Name}.{nameof(last.Delay)}='{last.Delay}'");
                    _log.Trace($"Items.{last.Name}.{nameof(last.Key)}='{last.Key}'");
                    _log.Trace($"Items.{last.Name}.{nameof(last.Type)}='{last.Type}'");
                    _log.Trace($"Items.{last.Name}.{nameof(last.ImagePath)}='{last.ImagePath}'");
                }

                if (_loadBroken)
                {
                    Save();
                }
            }
            else
            {
                _log.Warn("Не обнаружены настройки для фреймов, используются стандартные настройки");
                LoadDefaults();
            }

            _log.Info("Загрузка настроек завершена");
        }
Beispiel #6
0
 private void method_1()
 {
     try
     {
         while (!this.bool_0)
         {
             Dictionary <uint, ContestItem> dictionary = new Dictionary <uint, ContestItem>();
             lock (this.dictionary_1)
             {
                 foreach (KeyValuePair <uint, ContestItem> pair in this.dictionary_1)
                 {
                     dictionary.Add(pair.Key, pair.Value);
                 }
             }
             List <uint> list = new List <uint>();
             foreach (ContestItem item in dictionary.Values)
             {
                 if (!item.IsActive)
                 {
                     list.Add(item.UInt32_0);
                 }
                 else
                 {
                     lock (this.dictionary_1)
                     {
                         foreach (uint num in list)
                         {
                             if (this.dictionary_1.ContainsKey(num))
                             {
                                 this.dictionary_1.Remove(num);
                                 Output.WriteLine("[SpaceMgr] Erased ContestItem #" + num + ".", OutputLevel.DebugInformation);
                             }
                         }
                     }
                 }
             }
             lock (this.dictionary_1)
             {
                 uint[] numArray = new uint[this.dictionary_0.Count];
                 int    index    = 0;
                 foreach (KeyValuePair <uint, ContestItem> pair2 in this.dictionary_0)
                 {
                     if ((pair2.Value.SpaceId == this.spaceInfo_0.UInt32_0) || (pair2.Value.SpaceId == 0))
                     {
                         numArray[index] = pair2.Value.UInt32_0;
                         index++;
                     }
                 }
                 Vector2[] vectorArray = new Vector2[this.spaceModel_0.Heightmap.TileStates.Length];
                 for (int i = 0; i < this.spaceModel_0.Heightmap.OpenTiles.Length; i++)
                 {
                     vectorArray[i] = this.spaceModel_0.Heightmap.OpenTiles[i];
                 }
                 Vector2 position = null;
                 while (position == null)
                 {
                     int num4 = new Random().Next(0, vectorArray.Length - 1);
                     if (vectorArray[num4] != null)
                     {
                         position = vectorArray[num4];
                     }
                 }
                 ContestItem item2 = null;
                 while (item2 == null)
                 {
                     int num5 = new Random().Next(0, numArray.Length - 1);
                     if ((num5 == 1) || (num5 != this.int_2))
                     {
                         if (num5 == 1)
                         {
                             this.int_3++;
                         }
                         this.int_2 = num5;
                         if (this.int_3 < 3)
                         {
                             item2 = this.dictionary_0[numArray[num5]];
                         }
                         else
                         {
                             this.int_3 = 0;
                         }
                     }
                 }
                 if ((item2 != null) && (position != null))
                 {
                     ContestItem item3 = new ContestItem(this.method_0(), this.uint_0, item2.DefinitionId, item2.RankingId, position, item2.GoldCredits, item2.SilverCredits, item2.ObjectId, item2.DefinitionName, item2.ShowName, item2.FallType, item2.CatchType);
                     this.dictionary_1.Add(item3.UInt32_0, item3);
                     this.BroadcastMessage(SpaceFallingItemComposer.Compose(item3), 0, false);
                 }
             }
             int millisecondsTimeout = new Random().Next(0xafc8, 0x249f0);
             Output.WriteLine(string.Concat(new object[] { "[ContestMgr] Item will fall on Instance #", this.uint_0, " in ", millisecondsTimeout, " MilliSeconds." }), OutputLevel.DebugInformation);
             Thread.Sleep(millisecondsTimeout);
         }
     }
     catch (ThreadAbortException)
     {
     }
     catch (ThreadInterruptedException)
     {
     }
     catch (Exception)
     {
         this.method_2();
     }
 }
Beispiel #7
0
        private void TimerOnTick(object sender, EventArgs e)
        {
            _swt.Stop();
            _timer.Enabled = false;
            _timer.Stop();

            if (!_curr.Name.StartsWith(@"Blackscreen") && !_fl)
            {
                _result.Results.Add(new ContestResultItem
                {
                    Elapsed = _swt.ElapsedMilliseconds,
                    Item    = _curr,
                    Success = _curr.Key == Keys.None,
                });
                _swt.Reset();
            }

            if (_queue.Count == 0)
            {
                GenerateReport();
                Close();
                return;
            }

            _curr = _queue.Dequeue();

            if (_curr.Type == ContentItemType.Image && File.Exists(_curr.ImagePath))
            {
                ContestImage.Image     = Image.FromFile(_curr.ImagePath);
                ContestImage.BackColor = BackColor;
            }
            else if (_curr.Type == ContentItemType.Text)
            {
                ContestImage.BackColor = _curr.Color;
                ContestImage.Image     = new Bitmap(ContestImage.Width, ContestImage.Height);
                var g = Graphics.FromImage(ContestImage.Image);

                var text        = "+";
                var contestFont = new Font("Symbol", 96);

                var textSize       = g.MeasureString(text, contestFont);
                var locationToDraw = new PointF
                {
                    X = (ContestImage.Width / 2) - (textSize.Width / 2),
                    Y = (ContestImage.Height / 2) - (textSize.Height / 2)
                };


                g.DrawString(text, contestFont, Brushes.White, locationToDraw);
                g.Dispose();
            }
            else
            {
                ContestImage.Image     = new Bitmap(1, 1);
                ContestImage.BackColor = _curr.Color;
            }

            _timer.Interval = (int)_curr.Delay;
            _swt.Reset();
            _timer.Enabled = true;
            _timer.Start();
            _swt.Start();
            _fl = false;
        }