Пример #1
0
 public static void SetMany <T>(this IEnumerable <IEnumerable <T> > blocks, ForegroundBlock block) where T : IBlockSettable <ForegroundBlock, BackgroundBlock>
 {
     foreach (var item in blocks)
     {
         item.Set(block);
     }
 }
Пример #2
0
 public static void Set(this IEnumerable <BlocksItem> blocks, ForegroundBlock block)
 {
     foreach (var item in blocks)
     {
         item.Set(block);
     }
 }
Пример #3
0
        private void RaiseForeground(int x, int y, ForegroundBlock newBlock, Player player)
        {
            var oldData = this.World.Foreground[x, y];
            var newData = new BlockData <ForegroundBlock>(player, newBlock);

            this.World.Foreground[x, y] = newData;

            new ForegroundPlaceEvent(x, y, oldData, newData)
            .RaiseIn(this.BotBits);
        }
Пример #4
0
 public void Set(ForegroundBlock block)
 {
     this._blocks.Place(this._x, this._y, block);
 }
Пример #5
0
        internal static BlockDataWorld GetWorld(Message m, int width, int height, uint offset = InitOffset)
        {
            var  world   = new BlockDataWorld(width, height);
            uint pointer = GetStart(m, offset);

            string strValue2;

            while ((strValue2 = m[pointer] as string) == null || strValue2 != "we")
            {
                var    block      = m.GetInteger(pointer++);
                var    l          = (Layer)m.GetInteger(pointer++);
                byte[] byteArrayX = m.GetByteArray(pointer++);
                byte[] byteArrayY = m.GetByteArray(pointer++);

                switch (l)
                {
                case Layer.Background:
                    var bgWorldBlock = new BackgroundBlock((Background.Id)block);
                    foreach (Point pos in GetPos(byteArrayX, byteArrayY))
                    {
                        world.Background[pos.X, pos.Y] = new BlockData <BackgroundBlock>(bgWorldBlock);
                    }
                    break;

                case Layer.Foreground:
                    ForegroundBlock foregroundBlock;
                    BlockArgsType   blockArgsType = WorldUtils.GetBlockArgsType(WorldUtils.GetForegroundType(id: (Foreground.Id)block));

                    switch (blockArgsType)
                    {
                    case BlockArgsType.None:
                        foregroundBlock = new ForegroundBlock((Foreground.Id)block);
                        break;

                    case BlockArgsType.Number:
                        uint i = m.GetUInt(pointer++);
                        foregroundBlock = new ForegroundBlock((Foreground.Id)block, i);
                        break;

                    case BlockArgsType.String:
                        string str = m.GetString(pointer++);
                        foregroundBlock = new ForegroundBlock((Foreground.Id)block, str);
                        break;

                    case BlockArgsType.Portal:
                        var  portalRotation = (Morph.Id)m.GetUInt(pointer++);
                        uint portalId       = m.GetUInt(pointer++);
                        uint portalTarget   = m.GetUInt(pointer++);
                        foregroundBlock = new ForegroundBlock((Foreground.Id)block, portalId, portalTarget, portalRotation);
                        break;

                    case BlockArgsType.Label:
                        string text      = m.GetString(pointer++);
                        string textcolor = m.GetString(pointer++);
                        foregroundBlock = new ForegroundBlock((Foreground.Id)block, text, textcolor);
                        break;

                    default:
                        throw new NotSupportedException("Invalid block.");
                    }

                    var fg = new BlockData <ForegroundBlock>(foregroundBlock);
                    foreach (Point pos in GetPos(byteArrayX, byteArrayY))
                    {
                        world.Foreground[pos.X, pos.Y] = fg;
                    }
                    break;
                }
            }

            return(world);
        }
Пример #6
0
 public void Place(int x, int y, ForegroundBlock block)
 {
     new PlaceSendMessage(Layer.Foreground, x, y, (int)block.Id, block.GetArgs())
     .SendIn(this.BotBits);
 }