예제 #1
0
        internal static ArgumentException GetMissingArgsErrorMessage(BlockArgsType type, [InvokerParameterName] string paramName)
        {
            switch (type)
            {
            case BlockArgsType.None:
                return(new ArgumentException("That block doesn't accept any extra parameters!", paramName));

            case BlockArgsType.Number:
            case BlockArgsType.SignedNumber:
                return(new ArgumentException("That block needs a number as its parameter.", paramName));

            case BlockArgsType.String:
                return(new ArgumentException("That block needs a string as its parameter.", paramName));

            case BlockArgsType.Sign:
                return(new ArgumentException("Sign blocks need a string followed by a sign morph (Morph.Sign).", paramName));

            case BlockArgsType.Portal:
                return(new ArgumentException("Portal blocks require three parameters in the following order: id (int) target (int) rotation (Morph.Portal).", paramName));

            case BlockArgsType.Label:
                return(new ArgumentException("Label blocks require two parameters in the following order: text (string) hex color (string).", paramName));

            default:
                return(new ArgumentException("Invalid arguments for the given block!", paramName));
            }
        }
예제 #2
0
        private ForegroundBlock(Foreground.Id id, BlockArgsType requiredArgsType)
        {
            this.Id    = id;
            this._args = null;

            var argsType = WorldUtils.GetBlockArgsType(this.Type);

            if (argsType != requiredArgsType)
            {
                throw WorldUtils.GetMissingArgsErrorMessage(argsType, nameof(id));
            }
        }
예제 #3
0
 public ForegroundBlock(uint type, string text, uint signType)
 {
     this.args     = new SignArgs(text, signType);
     this.argsType = BlockArgsType.Sign;
     this.type     = type;
 }
예제 #4
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);
        }
예제 #5
0
 public ForegroundBlock(uint type, string text, string color, uint wrapLength)
 {
     this.args     = new ColorTextArgs(text, color, wrapLength);
     this.argsType = BlockArgsType.ColorText;
     this.type     = type;
 }
예제 #6
0
 public ForegroundBlock(uint type, uint portalId, uint portalTarget, uint portalRotation)
 {
     this.args     = new PortalArgs(portalId, portalTarget, portalRotation);
     this.argsType = BlockArgsType.Portal;
     this.type     = type;
 }
예제 #7
0
 public ForegroundBlock(uint type, string args)
 {
     this.args     = args;
     this.argsType = BlockArgsType.String;
     this.type     = type;
 }
예제 #8
0
 public ForegroundBlock(uint type, uint args)
 {
     this.args     = args;
     this.argsType = BlockArgsType.Number;
     this.type     = type;
 }
예제 #9
0
 public ForegroundBlock(uint type)
 {
     this.args     = null;
     this.argsType = BlockArgsType.None;
     this.type     = type;
 }