Ejemplo n.º 1
0
        public ForBlock() : base("for")
        {
            ForInitializer   = new StatementLine();
            ForCondition     = new ExpressionBlock();
            ForIncrementStep = new ExpressionBlock();

            const int c = ShapeStyle.DefaultFontSize;

            ForInitializer.MyControl.Box.Margins.Left = c;
            ForInitializer.MyControl.Box.Margins.SetTopAndBottom(0);
            ForInitializer.MyControl.Box.MouseSensitivityArea.SetLeftAndRight(c);
            ForInitializer.Draggable = false;
            InitField(ForInitializer);

            ForCondition.MyControl.Box.Margins.Left = c;
            ForCondition.MyControl.Box.MouseSensitivityArea.SetLeftAndRight(c);
            InitField(ForCondition);

            ForIncrementStep.MyControl.Box.Margins.SetLeftAndRight(c);
            ForIncrementStep.MyControl.Box.MouseSensitivityArea.SetLeftAndRight(c);
            InitField(ForIncrementStep);

            LabelBlock firstSep = new LabelBlock(";");

            firstSep.MyControl.Enabled = false;
            LabelBlock secondSep = new LabelBlock(";");

            secondSep.MyControl.Enabled = false;

            this.HMembers.Add(ForInitializer);
            this.HMembers.Add(firstSep);
            this.HMembers.Add(ForCondition);
            this.HMembers.Add(secondSep);
            this.HMembers.Add(ForIncrementStep);
        }
Ejemplo n.º 2
0
        public LabelPlaceSendEvent(Layer layer, int x, int y, LabelBlock block, string text)
        {
            this.Block = block;
            this.X = x;
            this.Y = y;
            this.Layer = BlockUtils.CorrectLayer((Block)block, layer);

            this.Text = text;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Tests if a label block is equal to a block
        /// </summary>
        /// <param name="b">The block</param>
        /// <returns>True if equal in value</returns>
        public bool EqualsBlock(Block b)
        {
            if (b is LabelBlock)
            {
                LabelBlock lB = (LabelBlock)b;
                return(lB.X == X && lB.Y == Y && lB.Layer == Layer && lB.ID == ID && lB.Color == Color);
            }

            return(false);
        }
Ejemplo n.º 4
0
        private void Init()
        {
            LeftBrace  = new LabelBlock(OpeningBrace);
            RightBrace = new LabelBlock(ClosingBrace);
            LeftBrace.MyControl.Enabled  = false;
            RightBrace.MyControl.Enabled = false;

            Children.Add(LeftBrace);
            Children.Add(List);
            Children.Add(RightBrace);

            List.CanBeDeletedByUser = false;
            List.MyTextBox.MinWidth = 2;
            List.MyControl.Box.MouseSensitivityArea.SetLeftAndRight(List.MyTextBox.StringSize(OpeningBrace).X);
        }
Ejemplo n.º 5
0
        public TutorialRootBlock5()
            : base()
        {
            label       = new LabelBlock("Click me");
            mouseCoords = new LabelBlock();
            this.Add(label);
            this.Add(mouseCoords);

            label.MyControl.MouseDown += label_MouseDown;
            this.MyControl.MouseMove  += delegate(MouseWithKeysEventArgs MouseInfo)
            {
                mouseCoords.Text = MouseInfo.X.ToString() + "; " + MouseInfo.Y;
            };

            this.MyControl.Style.FillStyleInfo.Mode = FillMode.HorizontalGradient;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            WorldConnection worldCon = (WorldConnection)connectionBase;
            World           world    = worldCon.World;

            int     x        = message.GetInt(0);
            int     y        = message.GetInt(1);
            BlockID blockId  = (BlockID)message.GetInt(2);
            string  text     = message.GetString(3);
            string  hexColor = message.GetString(4);

            LabelBlock labelBlock = null;

            if (message.Count > 5)
            {
                int userId = message.GetInt(5);

                WorldPlayer player = worldCon.Players.GetPlayer(userId);
                labelBlock = new LabelBlock(worldCon, blockId, x, y, text, hexColor)
                {
                    Placer = player
                };
            }
            else
            {
                labelBlock = new LabelBlock(worldCon, blockId, x, y, text, hexColor);
            }

            if (!handled)
            {
                world.SetBlock(labelBlock);
            }

            worldCon.CheckBlock(labelBlock);
            LabelBlockEvent labelBlockEvent = new LabelBlockEvent()
            {
                Raw        = message,
                LabelBlock = labelBlock
            };

            connectionBase.RaiseServerEvent <LabelBlockEvent>(labelBlockEvent);
        }
Ejemplo n.º 7
0
        internal void SetLabel(LabelBlock block, string text)
        {
            this.BlockType = BlockType.Label;
            this.Block = (Block)block;

            this._data = new BlockData
            {
                Text = text
            };
        }
Ejemplo n.º 8
0
 public UploadRequestEvent GetLabel(int x, int y, LabelBlock block, string text, string textColor)
 {
     var e = new LabelPlaceSendEvent(Layer.Foreground, x, y, block, text, textColor);
     return new UploadRequestEvent(e);
 }
Ejemplo n.º 9
0
 public void UploadLabel(int x, int y, LabelBlock block, string text, string textColor)
 {
     this.Events.Raise(this.GetLabel(x, y, block, text, textColor));
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Deserialize's the world data
        /// </summary>
        /// <param name="message">The message</param>
        internal void Deserialize(Message message)
        {
            // Find the start of the init message's world data
            uint start = 0;

            for (uint i = 0; i < message.Count; i++)
            {
                if (message[i] is string)
                {
                    if (string.Compare(message.GetString(i), "ws", false) == 0)
                    {
                        start = i + 1;
                        break;
                    }
                }
            }

            uint index = start;

            try
            {
                while (index < message.Count)
                {
                    if (message[index] is string)
                    {
                        if (string.Compare(message.GetString(index), "we", false) == 0)
                        {
                            break;
                        }
                    }

                    int blockInt = message.GetInt(index++);
                    int layerInt = message.GetInt(index++);

                    byte[] bytesX = message.GetByteArray(index++);
                    byte[] bytesY = message.GetByteArray(index++);

                    List <FluidPoint> locations = GetLocations(bytesX, bytesY);

                    BlockID blockId = (BlockID)blockInt;
                    Layer   layer   = (Layer)layerInt;

                    switch (blockId)
                    {
                    case BlockID.HazardSpike:
                    case BlockID.DecorSciFi2013BlueSlope:
                    case BlockID.DecorSciFi2013BlueStraight:
                    case BlockID.DecorSciFi2013YellowSlope:
                    case BlockID.DecorSciFi2013YellowStraight:
                    case BlockID.DecorSciFi2013GreenSlope:
                    case BlockID.DecorSciFi2013GreenStraight:
                    case BlockID.OneWayCyan:
                    case BlockID.OneWayPink:
                    case BlockID.OneWayRed:
                    case BlockID.OneWayYellow:
                    {
                        Rotation rotation = (Rotation)message.GetUInt(index++);

                        foreach (FluidPoint p in locations)
                        {
                            RotatableBlock rotatableBlock = new RotatableBlock(blockId, p.X, p.Y, rotation);
                            SetBlock(rotatableBlock);
                        }
                    }
                    break;

                    case BlockID.CoinDoor:
                    case BlockID.BlueCoinDoor:
                    case BlockID.CoinGate:
                    case BlockID.BlueCoinGate:
                    {
                        uint goal = message.GetUInt(index++);

                        foreach (FluidPoint p in locations)
                        {
                            CoinBlock door = new CoinBlock(blockId, p.X, p.Y, goal);
                            SetBlock(door);
                        }
                    }
                    break;

                    case BlockID.MusicDrum:
                    case BlockID.MusicPiano:
                    {
                        uint musicId = message.GetUInt(index++);

                        foreach (FluidPoint p in locations)
                        {
                            MusicBlock musicBlock = new MusicBlock(blockId, p.X, p.Y, musicId);
                            SetBlock(musicBlock);
                        }
                    }
                    break;

                    case BlockID.Portal:
                    case BlockID.InvisiblePortal:
                    {
                        Rotation rotation     = (Rotation)message.GetUInt(index++);
                        uint     portalid     = message.GetUInt(index++);
                        uint     portaltarget = message.GetUInt(index++);

                        foreach (FluidPoint p in locations)
                        {
                            Portal portal = new Portal(blockId, p.X, p.Y, rotation, portalid, portaltarget);
                            SetBlock(portal);
                        }
                    }
                    break;

                    case BlockID.SwitchPurple:
                    case BlockID.PurpleSwitchDoor:
                    case BlockID.PurpleSwitchGate:
                    {
                        uint goal = message.GetUInt(index++);

                        foreach (FluidPoint p in locations)
                        {
                            PurpleBlock purpleBlock = new PurpleBlock(blockId, p.X, p.Y, goal);
                            SetBlock(purpleBlock);
                        }
                    }
                    break;

                    case BlockID.DeathDoor:
                    case BlockID.DeathGate:
                    {
                        uint goal = message.GetUInt(index++);

                        foreach (FluidPoint p in locations)
                        {
                            DeathBlock deathBlock = new DeathBlock(blockId, p.X, p.Y, goal);
                            SetBlock(deathBlock);
                        }
                    }
                    break;

                    case BlockID.WorldPortal:
                    {
                        string targetId = message.GetString(index++);

                        foreach (FluidPoint p in locations)
                        {
                            WorldPortal worldPortal = new WorldPortal(blockId, p.X, p.Y, targetId);
                            SetBlock(worldPortal);
                        }
                    }
                    break;

                    case BlockID.DecorSign:
                    {
                        string text = message.GetString(index++);

                        foreach (FluidPoint p in locations)
                        {
                            TextBlock textBlock = new TextBlock(blockId, p.X, p.Y, text);
                            SetBlock(textBlock);
                        }
                    }
                    break;

                    case BlockID.DecorLabel:
                    {
                        string text     = message.GetString(index++);
                        string hexColor = message.GetString(index++);

                        foreach (FluidPoint p in locations)
                        {
                            LabelBlock labelBlock = new LabelBlock(blockId, p.X, p.Y, text, hexColor);
                            SetBlock(labelBlock);
                        }
                    }
                    break;

                    default:
                        foreach (FluidPoint p in locations)
                        {
                            Block block = new Block(blockId, layer, p.X, p.Y);
                            SetBlock(block);
                        }
                        break;
                    }
                }
            }
            catch
            {
                m_Client.Log.Add(FluidLogCategory.Message, "World init deserializer is out of date. Check for an update.");
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Deserialize's the world data
        /// </summary>
        /// <param name="worldObject">The world data as a database array</param>
        private void Deserialize(DatabaseObject worldObject)
        {
            Owner           = GetValue <string>(worldObject, "owner");
            Width           = GetValue <int>(worldObject, "width", 200);
            Height          = GetValue <int>(worldObject, "height", 200);
            Title           = GetValue <string>(worldObject, "name");
            Plays           = GetValue <int>(worldObject, "plays");
            WorldType       = (WorldType)GetValue <int>(worldObject, "type", 3);
            AllowPotions    = GetValue <bool>(worldObject, "allowpotions", true);
            Woots           = GetValue <int>(worldObject, "woots", 0);
            TotalWoots      = GetValue <int>(worldObject, "totalwoots", 0);
            Visible         = GetValue <bool>(worldObject, "visible", true);
            BackgroundColor = new FluidColor(GetValue <uint>(worldObject, "backgroundColor", 0));

            //Check is worlddata is present
            if (!worldObject.Contains("worlddata"))
            {
                return;
            }

            CreateEmptyWorld();

            DatabaseArray        databaseArray = (DatabaseArray)worldObject["worlddata"];
            IEnumerable <object> databaseEnum  = (IEnumerable <object>)databaseArray;

            using (IEnumerator <object> enumerator = databaseEnum.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    DatabaseObject blockData = (DatabaseObject)enumerator.Current;

                    byte[]  xBytes  = blockData.GetBytes("x");
                    byte[]  yBytes  = blockData.GetBytes("y");
                    BlockID blockId = (BlockID)blockData.GetUInt("type");

                    for (int i = 0; i < xBytes.Length; i += 2)
                    {
                        int x = xBytes[i] << 8 | xBytes[i + 1];
                        int y = yBytes[i] << 8 | yBytes[i + 1];
                        if (blockData.Contains("layer"))
                        {
                            Layer layer = (Layer)blockData.GetInt("layer");

                            switch (blockId)
                            {
                            case BlockID.HazardSpike:
                            case BlockID.DecorSciFi2013BlueSlope:
                            case BlockID.DecorSciFi2013BlueStraight:
                            case BlockID.DecorSciFi2013YellowSlope:
                            case BlockID.DecorSciFi2013YellowStraight:
                            case BlockID.DecorSciFi2013GreenSlope:
                            case BlockID.DecorSciFi2013GreenStraight:
                            case BlockID.OneWayCyan:
                            case BlockID.OneWayPink:
                            case BlockID.OneWayRed:
                            case BlockID.OneWayYellow:
                            {
                                Rotation rotation = (Rotation)blockData.GetUInt("rotation");

                                RotatableBlock rotatableBlock = new RotatableBlock(blockId, x, y, rotation);
                                SetBlock(rotatableBlock);
                            }
                            break;

                            case BlockID.CoinDoor:
                            case BlockID.BlueCoinDoor:
                            case BlockID.CoinGate:
                            case BlockID.BlueCoinGate:
                            {
                                uint goal = blockData.GetUInt("goal");

                                CoinBlock door = new CoinBlock(blockId, x, y, goal);
                                SetBlock(door);
                            }
                            break;

                            case BlockID.MusicDrum:
                            case BlockID.MusicPiano:
                            {
                                uint musicId = blockData.GetUInt("id");

                                MusicBlock musicBlock = new MusicBlock(blockId, x, y, musicId);
                                SetBlock(musicBlock);
                            }
                            break;

                            case BlockID.Portal:
                            case BlockID.InvisiblePortal:
                            {
                                Rotation rotation     = (Rotation)blockData.GetUInt("rotation");
                                uint     portalid     = blockData.GetUInt("id");
                                uint     portaltarget = blockData.GetUInt("target");

                                Portal portal = new Portal(blockId, x, y, rotation, portalid, portaltarget);
                                SetBlock(portal);
                            }
                            break;

                            case BlockID.SwitchPurple:
                            case BlockID.PurpleSwitchDoor:
                            case BlockID.PurpleSwitchGate:
                            {
                                uint goal = 0;
                                if (blockData.Contains("goal"))
                                {
                                    goal = blockData.GetUInt("goal");
                                }

                                PurpleBlock purpleBlock = new PurpleBlock(blockId, x, y, goal);
                                SetBlock(purpleBlock);
                            }
                            break;

                            case BlockID.DeathDoor:
                            case BlockID.DeathGate:
                            {
                                uint goal = blockData.GetUInt("goal");

                                DeathBlock deathBlock = new DeathBlock(blockId, x, y, goal);
                                SetBlock(deathBlock);
                            }
                            break;

                            case BlockID.WorldPortal:
                            {
                                string targetId = blockData.GetString("target");

                                WorldPortal worldPortal = new WorldPortal(blockId, x, y, targetId);
                                SetBlock(worldPortal);
                            }
                            break;

                            case BlockID.DecorSign:
                            {
                                string text = blockData.GetString("text");

                                TextBlock textBlock = new TextBlock(blockId, x, y, text);
                                SetBlock(textBlock);
                            }
                            break;

                            case BlockID.DecorLabel:
                            {
                                string text = blockData.GetString("text");
                                if (blockData.Contains("text_color"))
                                {
                                    string hexColor = blockData.GetString("text_color");

                                    LabelBlock labelBlock = new LabelBlock(blockId, x, y, text, hexColor);
                                    SetBlock(labelBlock);
                                }
                                else
                                {
                                    LabelBlock labelBlock = new LabelBlock(blockId, x, y, text);
                                    SetBlock(labelBlock);
                                }
                            }
                            break;

                            default:
                                Block block = new Block(blockId, layer, x, y);
                                SetBlock(block);
                                break;
                            }
                        }
                    }
                }
            }

            IsLoaded = true;
        }