コード例 #1
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            type = p.bindings[type];

            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);

            p.SendBlockchange(x, y, z, b);

            CatchPos cpos = (CatchPos)p.blockchangeObject;

            ushort cur;

            if (x == cpos.x && z == cpos.z)
            {
                Player.SendMessage(p, "No direction was selected"); return;
            }

            if (Math.Abs(cpos.x - x) > Math.Abs(cpos.z - z))
            {
                cur = cpos.x;
                if (x > cpos.x)
                {
                    foreach (char c in cpos.givenMessage)
                    {
                        cur = FindReference.writeLetter(p, c, cur, cpos.y, cpos.z, type, 0);
                    }
                }
                else
                {
                    foreach (char c in cpos.givenMessage)
                    {
                        cur = FindReference.writeLetter(p, c, cur, cpos.y, cpos.z, type, 1);
                    }
                }
            }
            else
            {
                cur = cpos.z;
                if (z > cpos.z)
                {
                    foreach (char c in cpos.givenMessage)
                    {
                        cur = FindReference.writeLetter(p, c, cpos.x, cpos.y, cur, type, 2);
                    }
                }
                else
                {
                    foreach (char c in cpos.givenMessage)
                    {
                        cur = FindReference.writeLetter(p, c, cpos.x, cpos.y, cur, type, 3);
                    }
                }
            }

            if (p.staticCommands)
            {
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
            }
        }
コード例 #2
0
ファイル: CmdWrite.cs プロジェクト: blha303/MCDawn
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            type = p.bindings[type];

            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);

            p.SendBlockchange(x, y, z, b);

            CatchPos cpos = (CatchPos)p.blockchangeObject;

            ushort cur;

            if (x == cpos.x && z == cpos.z)
            {
                Player.SendMessage(p, "No direction was selected"); return;
            }

            ushort msgLength = 0; int breaksmade = 0;

            if (Math.Abs(cpos.x - x) > Math.Abs(cpos.z - z))
            {
                cur = cpos.x;
                if (x > cpos.x)
                {
                    foreach (char c in cpos.givenMessage)
                    {
                        msgLength += (ushort)(FindReference.charWidth(c) + 1);
                        if ((ushort)(cpos.x + msgLength) >= p.level.width)
                        {
                            cpos.y = (ushort)(cpos.y - 6);
                            cur    = FindReference.writeLetter(p, c, (ushort)(x - 1), cpos.y, cpos.z, type, 0);
                            breaksmade++;
                            msgLength = 0;
                        }
                        else
                        {
                            cur = FindReference.writeLetter(p, c, cur, cpos.y, cpos.z, type, 0);
                        }
                    }
                }
                else
                {
                    foreach (char c in cpos.givenMessage)
                    {
                        msgLength += (ushort)(FindReference.charWidth(c) + 1);
                        if ((ushort)(cpos.x - msgLength) <= 0)
                        {
                            cpos.y = (ushort)(cpos.y - 6);
                            cur    = FindReference.writeLetter(p, c, (ushort)(x + 1), cpos.y, cpos.z, type, 0);
                            breaksmade++;
                            msgLength = 0;
                        }
                        else
                        {
                            cur = FindReference.writeLetter(p, c, cur, cpos.y, cpos.z, type, 1);
                        }
                    }
                }
            }
            else
            {
                cur = cpos.z;
                if (z > cpos.z)
                {
                    foreach (char c in cpos.givenMessage)
                    {
                        msgLength += (ushort)(FindReference.charWidth(c) + 1);
                        if ((ushort)(cpos.z + msgLength) >= p.level.width)
                        {
                            cpos.y = (ushort)(cpos.y - 6);
                            cur    = FindReference.writeLetter(p, c, cpos.x, cpos.y, (ushort)(z - 1), type, 2);
                            breaksmade++;
                            msgLength = 0;
                        }
                        else
                        {
                            cur = FindReference.writeLetter(p, c, cpos.x, cpos.y, cur, type, 2);
                        }
                    }
                }
                else
                {
                    foreach (char c in cpos.givenMessage)
                    {
                        msgLength += (ushort)(FindReference.charWidth(c) + 1);
                        if ((ushort)(cpos.z - msgLength) <= 0)
                        {
                            cpos.y = (ushort)(cpos.y - 6);
                            cur    = FindReference.writeLetter(p, c, cpos.x, cpos.y, (ushort)(z + 1), type, 3);
                            breaksmade++;
                            msgLength = 0;
                        }
                        else
                        {
                            cur = FindReference.writeLetter(p, c, cpos.x, cpos.y, cur, type, 3);
                        }
                    }
                }
            }

            if (breaksmade > 0)
            {
                Player.SendMessage(p, breaksmade + " line breaks were added.");
            }

            if (p.staticCommands)
            {
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
            }
        }