Example #1
0
        static Field()
        {
            _colors    = new Color[Constants.NumberOfColors + 1];
            _colors[0] = Colors.Black;

            for (int i = 1; i <= Constants.NumberOfColors; i++)
            {
                int r, g, b;
                HSVColorConverter.HsvToRgb(360.0 * i / Constants.NumberOfColors, 1, 1, out r, out g, out b);
                _colors[i] = Color.FromRgb((byte)r, (byte)g, (byte)b);
            }
        }
Example #2
0
        public static void HandleChatMessage(Bot bot, ChatClientMultiMessage message)
        {
            if (message.content.StartsWith(".algo submap"))
            {
                bot.Character.ResetCellsHighlight();

                var sw      = Stopwatch.StartNew();
                var submaps = SubMapsManager.Instance.GetMapSubMapsBinder(bot.Character.Map.Id);
                sw.Stop();
                bot.Character.SendMessage(string.Format("{0}ms", sw.ElapsedMilliseconds));

                foreach (var subMap in submaps)
                {
                    var random = new Random();
                    int hue    = random.Next(0, 361);
                    bot.Character.SendMessage(string.Format("[{0} mapid:{1} submap:{2}]", subMap.GlobalId, subMap.MapId, subMap.SubMapId));

                    double step = 1d / subMap.Neighbours.Count;
                    for (int i = 0; i < subMap.Neighbours.Count; i++)
                    {
                        var neighbour = subMap.Neighbours[i];
                        var color     = HSVColorConverter.ColorFromHSV(hue, step * (i + 1), 1);

                        bot.Character.SendMessage(string.Format("[{0}] to [{1}] ({2})",
                                                                subMap.GlobalId, neighbour.GlobalId,
                                                                neighbour.Transition is MovementTransition ? (neighbour.Transition as MovementTransition).MapNeighbour : MapNeighbour.None));
                        if (neighbour.Transition is MovementTransition)
                        {
                            bot.Character.HighlightCells((neighbour.Transition as MovementTransition).Cells, color);
                        }
                    }
                }

                message.BlockNetworkSend();
            }
            if (message.content.StartsWith(".algo los"))
            {
                var canBeSee    = new List <Cell>();
                var cannotBeSee = new List <Cell>();

                Cell currentCell;
                if (bot.Character.IsFighting())
                {
                    currentCell = bot.Character.Fighter.Cell;
                }
                else
                {
                    currentCell = bot.Character.Cell;
                }

                foreach (var cell in bot.Character.Map.Cells.Where(x => x.Walkable))
                {
                    if (bot.Character.Context.CanBeSeen(currentCell, cell, !bot.Character.IsFighting()))
                    {
                        canBeSee.Add(cell);
                    }
                    else
                    {
                        cannotBeSee.Add(cell);
                    }
                }

                bot.Character.ResetCellsHighlight();

                bot.Character.HighlightCells(canBeSee, Color.Green);
                bot.Character.HighlightCells(cannotBeSee, Color.Red);


                message.BlockNetworkSend();
            }
        }