コード例 #1
0
ファイル: Form1.cs プロジェクト: SirJosh3917/SeSet
        void c_OnMessage(object sender, PlayerIOClient.Message e)
        {
            switch (e.Type)
            {
            case "init":
                int width  = e.GetInt(18);
                int height = e.GetInt(19);
                edit = e.GetBoolean(14);
                _w   = width;
                _h   = height;
                x.Send("init2");
                break;

            case "init2":
                //start building
                x.Send("say", "Ready to build!");
                if (edit)
                {
                    Build();
                }
                break;

            case "access":
                Build();
                break;
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: EETomahawk/TagBot
        private void con_OnMessage(object sender, Message m)
        {
            switch (m.Type)
            {
                #region Init
            case "init":
                #region Owner-only
                if (!m.GetBoolean(15))
                {
                    con.Disconnect();
                    MessageBox.Show("For this bot to work, it must be the owner of the world.\n\nDisconnected.", "TagBot");
                    return;
                }
                #endregion
                con.Send("init2");
                players.Add(m.GetInt(5), m.GetString(13));
                lbStatus.Text = "Status: Connected";
                #region Cookie
                if (cbSave.Checked)
                {
                    Properties.Settings.Default.Username = tbUsername.Text;
                    Properties.Settings.Default.Password = tbPassword.Text;
                    Properties.Settings.Default.RoomID   = tbRoomID.Text;
                    Properties.Settings.Default.Save();
                }
                #endregion
                break;

                #endregion
                #region Add/Left
            case "add":
                players.Add(m[0], m.GetString(1));
                teams.Add(m.GetInt(0), m.GetInt(16));
                break;

            case "left":
                players.Remove(m[0]);
                teams.Remove(m.GetInt(0));
                break;

                #endregion
                #region Team
            case "team":
                lastTeam           = teams[m.GetInt(0)];
                teams[m.GetInt(0)] = m.GetInt(1);
                if (lastTeam == cbTeam.SelectedIndex)
                {
                    con.Send("say", $"/reffect {players[m.GetInt(0)]} curse");
                }
                break;

                #endregion
                #region Say
            case "say":
                if (prefixes.Contains(m.GetString(1)[0]))
                {
                    switch (m.GetString(1).Substring(1).ToLower())
                    {
                        #region bot
                    case "bot":
                        con.Send("say", "This is TagBot, created by Tomahawk.");
                        Thread.Sleep(600);
                        break;

                        #endregion
                        #region download
                    case "download":
                        con.Send("say", "TagBot forum thread: https://forums.everybodyedits.com/viewtopic.php?id=42162");
                        Thread.Sleep(600);
                        break;

                        #endregion
                        #region help
                    case "help":
                        con.Send("say", $"Commands: {string.Join("  ", commands)}");
                        Thread.Sleep(600);
                        break;
                        #endregion
                    }
                }
                break;
                #endregion
            }
        }
コード例 #3
0
        void OnMessage(object sender, PlayerIOClient.Message e)
        {
            if (e.Type == "b")
            {
                if (botid != (int)e.GetInt(4) && MainForm.userdata.ignoreplacing)
                {
                    if (e.GetInt(0) == 0)
                    {
                        frames[0].Foreground[e.GetInt(2), e.GetInt(1)]   = e.GetInt(3);
                        remoteFrame.Foreground[e.GetInt(2), e.GetInt(1)] = e.GetInt(3);
                    }
                    else
                    {
                        frames[0].Background[e.GetInt(2), e.GetInt(1)]   = e.GetInt(3);
                        remoteFrame.Background[e.GetInt(2), e.GetInt(1)] = e.GetInt(3);

                        /*frames[0].Foreground[e.GetInt(2), e.GetInt(1)] = 0;
                         * remoteFrame.Foreground[e.GetInt(2), e.GetInt(1)] = 0;
                         */
                    }
                    ++Gcurrent1;
                    restart = true;
                }
                else
                {
                    int layer = e.GetInt(0), x = e.GetInt(1), y = e.GetInt(2), id = e.GetInt(3);
                    if (layer == 0)
                    {
                        remoteFrame.Foreground[y, x] = id;
                    }
                    else
                    {
                        remoteFrame.Background[y, x] = id;
                    }
                    ++Gcurrent;
                    ++Gcurrent1;
                    int value = Gcurrent1;
                    OnStatusChanged("Uploading blocks to level. (Total: " + value + "/" + firstFrame.Count + ")", DateTime.MinValue, false, Gtotal, Gcurrent);
                    if (Convert.ToDouble(Gcurrent1) <= pb.Maximum && Convert.ToDouble(Gcurrent1) >= pb.Minimum)
                    {
                        if (pb.InvokeRequired)
                        {
                            pb.Invoke((MethodInvoker) delegate { pb.Value = Gcurrent1; });
                        }
                        TaskbarProgress.SetValue(afHandle, Gcurrent1, firstFrame.Count);
                    }
                }
            }
            else if (e.Type == "br")
            {
                if (botid != (int)e.GetInt(5) && MainForm.userdata.ignoreplacing)
                {
                    frames[0].Foreground[e.GetInt(1), e.GetInt(0)]   = e.GetInt(2);
                    frames[0].BlockData[e.GetInt(1), e.GetInt(0)]    = e.GetInt(3);
                    remoteFrame.Foreground[e.GetInt(1), e.GetInt(0)] = e.GetInt(2);
                    remoteFrame.BlockData[e.GetInt(1), e.GetInt(0)]  = e.GetInt(3);
                    ++Gcurrent1;
                    restart = true;
                }
                else
                {
                    int x = e.GetInt(0), y = e.GetInt(1);
                    remoteFrame.Foreground[y, x] = e.GetInt(2);
                    remoteFrame.BlockData[y, x]  = e.GetInt(3);
                    ++Gcurrent;
                    ++Gcurrent1;
                    int value = Gcurrent1;
                    OnStatusChanged("Uploading rotatable blocks to level. (Total: " + value + "/" + firstFrame.Count + ")", DateTime.MinValue, false, Gtotal, Gcurrent);
                    if (Convert.ToDouble(Gcurrent1) <= pb.Maximum && Convert.ToDouble(Gcurrent1) >= pb.Minimum)
                    {
                        if (pb.InvokeRequired)
                        {
                            pb.Invoke((MethodInvoker) delegate { pb.Value = Gcurrent1; });
                        }
                        TaskbarProgress.SetValue(afHandle, Gcurrent1, firstFrame.Count);
                    }
                }
            }
            else if (e.Type == "wp")
            {
                if (botid != (int)e.GetInt(4) && MainForm.userdata.ignoreplacing)
                {
                    frames[0].Foreground[e.GetInt(1), e.GetInt(0)]   = e.GetInt(2);
                    frames[0].BlockData3[e.GetInt(1), e.GetInt(0)]   = e.GetString(3);
                    remoteFrame.Foreground[e.GetInt(1), e.GetInt(0)] = e.GetInt(2);
                    remoteFrame.BlockData3[e.GetInt(1), e.GetInt(0)] = e.GetString(3);
                    ++Gcurrent1;
                    restart = true;
                }
                else
                {
                    int x = e.GetInt(0), y = e.GetInt(1);
                    remoteFrame.Foreground[y, x] = e.GetInt(2);
                    remoteFrame.BlockData3[y, x] = e.GetString(3);
                    ++Gcurrent;
                    ++Gcurrent1;
                    int value = Gcurrent1;
                    OnStatusChanged("Uploading world portals to level. (Total: " + value + "/" + firstFrame.Count + ")", DateTime.MinValue, false, Gtotal, Gcurrent);
                    if (Convert.ToDouble(Gcurrent1) <= pb.Maximum && Convert.ToDouble(Gcurrent1) >= pb.Minimum)
                    {
                        if (pb.InvokeRequired)
                        {
                            pb.Invoke((MethodInvoker) delegate { pb.Value = Gcurrent1; });
                        }
                        TaskbarProgress.SetValue(afHandle, Gcurrent1, firstFrame.Count);
                    }
                }
            }
            else if (e.Type == "ts")
            {
                if (botid != (int)e.GetInt(5) && MainForm.userdata.ignoreplacing)
                {
                    frames[0].Foreground[e.GetInt(1), e.GetInt(0)]   = e.GetInt(2);
                    frames[0].BlockData3[e.GetInt(1), e.GetInt(0)]   = e.GetString(3);
                    frames[0].BlockData[e.GetInt(1), e.GetInt(0)]    = e.GetInt(4);
                    remoteFrame.Foreground[e.GetInt(1), e.GetInt(0)] = e.GetInt(2);
                    remoteFrame.BlockData3[e.GetInt(1), e.GetInt(0)] = e.GetString(3);
                    remoteFrame.BlockData[e.GetInt(1), e.GetInt(0)]  = e.GetInt(4);
                    ++Gcurrent1;
                    restart = true;
                }
                else
                {
                    int x = e.GetInt(0), y = e.GetInt(1);
                    remoteFrame.Foreground[y, x] = e.GetInt(2);
                    remoteFrame.BlockData3[y, x] = e.GetString(3);
                    remoteFrame.BlockData[y, x]  = e.GetInt(4);
                    ++Gcurrent;
                    ++Gcurrent1;
                    int value = Gcurrent1;
                    OnStatusChanged("Uploading signs to level. (Total: " + value + "/" + firstFrame.Count + ")", DateTime.MinValue, false, Gtotal, Gcurrent);
                    if (Convert.ToDouble(Gcurrent1) <= pb.Maximum && Convert.ToDouble(Gcurrent1) >= pb.Minimum)
                    {
                        if (pb.InvokeRequired)
                        {
                            pb.Invoke((MethodInvoker) delegate { pb.Value = Gcurrent1; });
                        }
                        TaskbarProgress.SetValue(afHandle, Gcurrent1, firstFrame.Count);
                    }
                }
            }
            else if (e.Type == "bc")
            {
                if (botid != (int)e.GetInt(4) && MainForm.userdata.ignoreplacing)
                {
                    frames[0].Foreground[e.GetInt(1), e.GetInt(0)]   = e.GetInt(2);
                    frames[0].BlockData[e.GetInt(1), e.GetInt(0)]    = e.GetInt(3);
                    remoteFrame.Foreground[e.GetInt(1), e.GetInt(0)] = e.GetInt(2);
                    remoteFrame.BlockData[e.GetInt(1), e.GetInt(0)]  = e.GetInt(3);
                    ++Gcurrent1;
                    restart = true;
                }
                else
                {
                    int x = e.GetInt(0), y = e.GetInt(1);
                    remoteFrame.Foreground[y, x] = e.GetInt(2);
                    remoteFrame.BlockData[y, x]  = e.GetInt(3);
                    ++Gcurrent;
                    ++Gcurrent1;
                    int value = Gcurrent1;
                    OnStatusChanged("Uploading numbered action blocks to level. (Total: " + value + "/" + firstFrame.Count + ")", DateTime.MinValue, false, Gtotal, Gcurrent);
                    if (Convert.ToDouble(Gcurrent1) <= pb.Maximum && Convert.ToDouble(Gcurrent1) >= pb.Minimum)
                    {
                        if (pb.InvokeRequired)
                        {
                            pb.Invoke((MethodInvoker) delegate { pb.Value = Gcurrent1; });
                        }
                        TaskbarProgress.SetValue(afHandle, Gcurrent1, firstFrame.Count);
                    }
                }
            }
            else if (e.Type == "pt")
            {
                if (botid != (int)e.GetInt(6) && MainForm.userdata.ignoreplacing)
                {
                    frames[0].Foreground[e.GetInt(1), e.GetInt(0)]   = e.GetInt(2);
                    frames[0].BlockData[e.GetInt(1), e.GetInt(0)]    = e.GetInt(3);
                    frames[0].BlockData1[e.GetInt(1), e.GetInt(0)]   = e.GetInt(4);
                    frames[0].BlockData2[e.GetInt(1), e.GetInt(0)]   = e.GetInt(5);
                    remoteFrame.Foreground[e.GetInt(1), e.GetInt(0)] = e.GetInt(2);
                    remoteFrame.BlockData[e.GetInt(1), e.GetInt(0)]  = e.GetInt(3);
                    remoteFrame.BlockData1[e.GetInt(1), e.GetInt(0)] = e.GetInt(4);
                    remoteFrame.BlockData2[e.GetInt(1), e.GetInt(0)] = e.GetInt(5);
                    ++Gcurrent1;
                    restart = true;
                }
                else
                {
                    int x = e.GetInt(0);
                    int y = e.GetInt(1);
                    remoteFrame.Foreground[y, x] = e.GetInt(2);
                    remoteFrame.BlockData[y, x]  = e.GetInt(3);
                    remoteFrame.BlockData1[y, x] = e.GetInt(4);
                    remoteFrame.BlockData2[y, x] = e.GetInt(5);
                    ++Gcurrent;
                    ++Gcurrent1;
                    int value = Gcurrent1;
                    OnStatusChanged("Uploading portals to level. (Total: " + value + "/" + firstFrame.Count + ")", DateTime.MinValue, false, Gtotal, Gcurrent);
                    if (Convert.ToDouble(Gcurrent1) <= pb.Maximum && Convert.ToDouble(Gcurrent1) >= pb.Minimum)
                    {
                        if (pb.InvokeRequired)
                        {
                            pb.Invoke((MethodInvoker) delegate { pb.Value = Gcurrent1; });
                        }
                        TaskbarProgress.SetValue(afHandle, Gcurrent1, firstFrame.Count);
                    }
                }
            }
            else if (e.Type == "bs")
            {
                if (botid != (int)e.GetInt(4) && MainForm.userdata.ignoreplacing)
                {
                    frames[0].Foreground[e.GetInt(1), e.GetInt(0)]   = e.GetInt(2);
                    frames[0].BlockData[e.GetInt(1), e.GetInt(0)]    = e.GetInt(3);
                    remoteFrame.Foreground[e.GetInt(1), e.GetInt(0)] = e.GetInt(2);
                    remoteFrame.BlockData[e.GetInt(1), e.GetInt(0)]  = e.GetInt(3);
                    ++Gcurrent1;
                    restart = true;
                }
                else
                {
                    int x = e.GetInt(0);
                    int y = e.GetInt(1);
                    remoteFrame.Foreground[y, x] = e.GetInt(2);
                    remoteFrame.BlockData[y, x]  = e.GetInt(3);
                    ++Gcurrent;
                    ++Gcurrent1;
                    int value = Gcurrent1;
                    OnStatusChanged("Uploading noteblocks to level. (Total: " + value + "/" + firstFrame.Count + ")", DateTime.MinValue, false, Gtotal, Gcurrent);
                    if (Convert.ToDouble(Gcurrent1) <= pb.Maximum && Convert.ToDouble(Gcurrent1) >= pb.Minimum)
                    {
                        if (pb.InvokeRequired)
                        {
                            pb.Invoke((MethodInvoker) delegate { pb.Value = Gcurrent1; });
                        }
                        TaskbarProgress.SetValue(afHandle, Gcurrent1, firstFrame.Count);
                    }
                }
            }
            else if (e.Type == "access")
            {
                passTimer.Dispose();
                locker.Release();
            }
            else if (e.Type == "init")
            {
                botid = e.GetInt(5);
                AnimateForm.editRights = false;
                AnimateForm.saveRights = false;
                AnimateForm.crewEdit   = false;
                AnimateForm.crewWorld  = false;
                remoteFrame            = Frame.FromMessage(e, false);
                conn.Send("init2");
                OnStatusChanged("Connected to the world.", DateTime.MinValue, false, Gtotal, Gcurrent);
                if (frames[0].Width <= remoteFrame.Width && frames[0].Height <= remoteFrame.Height)
                {
                }
                else
                {
                    Gtotal = Gcurrent = pb.Maximum = pb.Value = 1;
                    ModifyProgressBarColor.SetState(pb, 2);
                    TaskbarProgress.SetValue(afHandle, Gcurrent, Gtotal);
                    TaskbarProgress.SetState(afHandle, TaskbarProgress.TaskbarStates.Error);
                    OnStatusChanged("Wrong level size. Please create a level with the size of " + remoteFrame.Width + "x" + remoteFrame.Height + ".", DateTime.MinValue, true, Gtotal, Gcurrent);
                    return;
                }
                if (e.GetBoolean(34))
                {
                    AnimateForm.crewWorld = true;
                    if (e.GetBoolean(14))
                    {
                        AnimateForm.crewEdit = true;
                        if (e.GetBoolean(31))
                        {
                            AnimateForm.saveRights = true;
                            if (MainForm.userdata.useColor)
                            {
                                if (MainForm.userdata.thisColor != Color.Transparent)
                                {
                                    var hex = ColorTranslator.ToHtml(MainForm.userdata.thisColor);
                                    conn.Send("say", "/bgcolor " + hex);
                                }
                                else
                                {
                                    conn.Send("say", "/bgcolor none");
                                }
                            }
                            else
                            {
                                conn.Send("say", "/bgcolor none");
                            }
                        }
                        locker.Release();
                    }
                    else
                    {
                        OnStatusChanged("Crew: You doesn't have edit rights in this world", DateTime.MinValue, true, Gtotal, Gcurrent);
                        return;
                    }
                }

                else if (e.GetString(0) != e.GetString(13))
                {
                    owner = false;
                    if (MainForm.userdata.level.StartsWith("OW") && levelPassword.Length == 0)
                    {
                        if (e.GetBoolean(14))
                        {
                            MainForm.OpenWorld     = true;
                            MainForm.OpenWorldCode = false;
                            locker.Release();
                        }
                        else
                        {
                            MainForm.OpenWorld     = false;
                            MainForm.OpenWorldCode = false;
                            OnStatusChanged("You need a password for this world", DateTime.MinValue, true, Gtotal, Gcurrent);
                            return;
                        }
                    }
                    else if (MainForm.userdata.level.StartsWith("OW") && levelPassword.Length > 0)
                    {
                        if (!e.GetBoolean(14))
                        {
                            MainForm.OpenWorld     = true;
                            MainForm.OpenWorldCode = true;
                            conn.Send("access", levelPassword);
                            passTimer = new System.Threading.Timer(x => OnStatusChanged("Wrong level code. Please enter the right one and retry.", DateTime.MinValue, true, Gtotal, Gcurrent), null, 5000, Timeout.Infinite);
                        }
                        else
                        {
                            MainForm.OpenWorld     = true;
                            MainForm.OpenWorldCode = false;
                            OnStatusChanged("This world isn't password protected", DateTime.MinValue, true, Gtotal, Gcurrent);
                            return;
                        }
                    }
                    else
                    {
                        if (MainForm.userdata.saveWorldCrew)
                        {
                            OnStatusChanged("You are not the owner of this world. You can't save.", DateTime.MinValue, true, Gtotal, Gcurrent);
                            return;
                        }
                        else
                        {
                            if (levelPassword.Length > 0)
                            {
                                Gtotal = Gcurrent = pb.Maximum = pb.Value = 1;
                                ModifyProgressBarColor.SetState(pb, 3);
                                TaskbarProgress.SetValue(afHandle, Gcurrent, Gtotal);
                                TaskbarProgress.SetState(afHandle, TaskbarProgress.TaskbarStates.Paused);
                                conn.Send("access", levelPassword);
                                passTimer = new System.Threading.Timer(x => OnStatusChanged("Wrong level code. Please enter the right one and retry.", DateTime.MinValue, true, Gtotal, Gcurrent), null, 5000, Timeout.Infinite);
                            }
                            else if (e.GetBoolean(14))
                            {
                                AnimateForm.editRights = true;
                                locker.Release();
                            }
                            else
                            {
                                passTimer = new System.Threading.Timer(x => OnStatusChanged("Didn't get edit. Timer stopped.", DateTime.MinValue, true, Gtotal, Gcurrent), null, 20000, Timeout.Infinite);
                            }
                        }
                    }
                }
                else if (e.GetString(0) == e.GetString(13))
                {
                    if (MainForm.userdata.useColor)
                    {
                        if (MainForm.userdata.thisColor != Color.Transparent)
                        {
                            var hex = ColorTranslator.ToHtml(MainForm.userdata.thisColor);
                            conn.Send("say", "/bgcolor " + hex);
                        }
                        else
                        {
                            conn.Send("say", "/bgcolor none");
                        }
                    }
                    else
                    {
                        conn.Send("say", "/bgcolor none");
                    }
                    AnimateForm.editRights = true;
                    AnimateForm.saveRights = true;
                    owner = true;
                    locker.Release();
                }
            }
            else
            {
                switch (e.Type)
                {
                case "info":
                    switch (e[0].ToString())
                    {
                    case "Limit reached":
                        MessageBox.Show(e.GetString(1), e.GetString(0), MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break;
                    }
                    break;
                }
            }
        }
コード例 #4
0
        protected virtual void OnMessage(object sender, PlayerIOClient.Message m)
        {
            switch (m.Type)
            {
            case "add":
            {
                int ID = m.GetInt(0);
                if (!playerList.ContainsKey(ID))
                {
                    Player temp = new Player((Bot)this, ID, m.GetString(1), m.GetInt(2), m.GetFloat(3), m.GetFloat(4), m.GetBoolean(5), m.GetBoolean(6), m.GetBoolean(7), m.GetInt(8), m.GetBoolean(10), m.GetBoolean(9), m.GetInt(11));
                    temp.x = m.GetDouble(3);
                    temp.y = m.GetDouble(4);
                    lock (playerList)
                    {
                        playerList.Add(ID, temp);
                    }
                    if (nameList.ContainsKey(temp.name))
                    {
                        nameList.Remove(temp.name);
                    }
                    nameList.Add(temp.name, ID);
                }
            }
            break;

            case "left":
            {
                int tempKey = m.GetInt(0);
                if (playerList.ContainsKey(tempKey))
                {
                    nameList.Remove(playerList[tempKey].name);
                    lock (playerList)
                    {
                        playerList.Remove(tempKey);
                    }
                }
            }
            break;

            case "m":
            {
                int   playerID     = int.Parse(m[0].ToString());
                float playerXPos   = float.Parse(m[1].ToString());
                float playerYPos   = float.Parse(m[2].ToString());
                float playerXSpeed = float.Parse(m[3].ToString());
                float playerYSpeed = float.Parse(m[4].ToString());
                float modifierX    = float.Parse(m[5].ToString());
                float modifierY    = float.Parse(m[6].ToString());
                int   xDir         = int.Parse(m[7].ToString());
                int   yDir         = int.Parse(m[8].ToString());
                if (playerList.ContainsKey(playerID))
                {
                    lock (playerList)
                    {
                        Player player = playerList[playerID];
                        player.x             = playerXPos;
                        player.y             = playerYPos;
                        player.speedX        = playerXSpeed;
                        player.speedY        = playerYSpeed;
                        player.modifierX     = modifierX;
                        player.modifierY     = modifierY;
                        player.horizontal    = xDir;
                        player.vertical      = yDir;
                        playerList[playerID] = player;
                    }
                }
            }
            break;

            case "god":
            {
                int tempKey = m.GetInt(0);
                if (playerList.ContainsKey(tempKey))
                {
                    Player player = playerList[tempKey];
                    player.isgod = m.GetBoolean(1);
                    lock (playerList)
                    {
                        playerList[tempKey] = player;
                    }
                }
            }
            break;

            case "face":
            {
                int tempKey = m.GetInt(0);
                if (playerList.ContainsKey(tempKey))
                {
                    Player player = playerList[tempKey];
                    player.frame(m.GetInt(1));
                    lock (playerList)
                    {
                        playerList[tempKey] = player;
                    }
                }
            }
            break;

            case "k":     //player got crown
            {
                int userId = m.GetInt(0);
                if (playerList.ContainsKey(userId))
                {
                    lock (playerList)
                    {
                        foreach (Player p in playerList.Values)
                        {
                            p.hascrown = false;
                        }
                        playerList[userId].hascrown = true;
                    }
                }
            }
            break;

            case "ks":     //player got silver crown
            {
                int userId = m.GetInt(0);
                if (playerList.ContainsKey(userId))
                {
                    lock (playerList)
                        playerList[userId].hascrownsilver = true;
                }
            }
            break;

            case "c":     //player took coin
            {
                int userId     = m.GetInt(0);
                int totalCoins = m.GetInt(1);
                if (playerList.ContainsKey(userId))
                {
                    lock (playerList)
                        playerList[userId].coins = totalCoins;
                }
            }
            break;

            case "levelup":
            {
                int userId = m.GetInt(0);
                int level  = m.GetInt(1);
                if (playerList.ContainsKey(userId))
                {
                    lock (playerList)
                        playerList[userId].level = level;
                }
            }
            break;

            case "tele":     //owner used reset/load
            {
                bool resetUsed = m.GetBoolean(0);
                for (int i = 1; i < m.Count; i += 3)
                {
                    int userId    = m.GetInt(1);
                    int spawnPosX = m.GetInt(2);
                    int spawnPosY = m.GetInt(3);
                    if (playerList.ContainsKey(userId))
                    {
                        lock (playerList)
                        {
                            Player p = playerList[userId];
                            p.setPosition(spawnPosX * 16, spawnPosY * 16);
                            playerList[userId] = p;
                        }
                    }
                }
            }
            break;
            }
        }
コード例 #5
0
ファイル: Main.cs プロジェクト: notcarksss/EECM_Artist
 void OnMsg(object sender, PlayerIOClient.Message m)
 {
     if (m.Type == "init")
     {
         key           = getkey(m.GetString(3));
         isOwner       = m.GetBoolean(9);
         worldWidth    = m.GetInt(10);
         worldHeight   = m.GetInt(11);
         nu_xp.Maximum = worldWidth;
         nu_yp.Maximum = worldHeight;
         WD_parser(m, 13);
         con.Send(key + 'f', 1);
         con.Send("access", tb_code.Text);
         return;
     }
     if (m.Type == "access")
     {
         MessageBox.Show("Got Access.");
         return;
     }
     if (m.Type == "lostaccess")
     {
         if (!isOwner)
         {
             running = false;
             MessageBox.Show("Lost Access.");
         }
         return;
     }
     if (m.Type == "clear")
     {
         worldWidth  = m.GetInt(0);
         worldHeight = m.GetInt(1);
         bl          = new int[2][][];
         for (int l = 0; l < 2; l++)
         {
             bl[l] = new int[worldWidth][];
             for (int x = 0; x < worldWidth; x++)
             {
                 bl[l][x] = new int[worldHeight];
             }
         }
         for (int x = 0; x < worldWidth; x++)
         {
             bl[0][x][0] = 9;
             bl[0][x][worldHeight - 1] = 9;
         }
         for (int y = 1; y < worldHeight - 1; y++)
         {
             bl[0][0][y] = 9;
             bl[0][worldWidth - 1][y] = 9;
         }
         return;
     }
     if (m.Type == "reset")
     {
         WD_parser(m, 0);
         return;
     }
     if (bl == null)
     {
         return;
     }
     if (m.Type == "b")
     {
         bl[m.GetInt(0)][m.GetInt(1)][m.GetInt(2)] = m.GetInt(3);
         return;
     }
     if (m.Type == "bc" || m.Type == "bs" || m.Type == "lb" || m.Type == "pt")
     {
         bl[0][m.GetInt(0)][m.GetInt(1)] = m.GetInt(2);
         return;
     }
 }
コード例 #6
0
        private void onMessage(object sender, PlayerIOClient.Message m)
        {
            switch (m.Type)
            {
            case "init":
            {
                if (isBB)
                {
                    owner    = m.GetString(0);
                    title    = m.GetString(1);
                    worldKey = rot13(m[3].ToString());
                    hasCode  = m.GetBoolean(8);
                    isOwner  = m.GetBoolean(9);
                }
                else
                {
                    owner    = m.GetString(0);
                    title    = m.GetString(1);
                    worldKey = rot13(m[5].ToString());
                    hasCode  = m.GetBoolean(10);
                    isOwner  = m.GetBoolean(11);
                }
                hasCode |= isOwner;
                {
                    string roomData = " - " + title + " ¦ by: " + owner;
                    Program.form1.Invoke(new Action(() =>
                                                    Program.form1.Text = Program.form1.Text.Substring(0, 10) + roomData
                                                    ));

                    Program.console.Invoke(new Action(() =>
                                                      Program.console.Text = Program.console.Text.Substring(0, 7) + roomData
                                                      ));
                }

                break;
            }

            case "say":
            {
                Player player = null;
                lock (playerList)
                {
                    if (playerList.ContainsKey(m.GetInt(0)))
                    {
                        Program.form1.say(playerList[m.GetInt(0)].Name, m.GetString(1));
                    }
                }
                int playerId = m.GetInt(0);
                lock (playerList)
                {
                    player = playerList[playerId];
                }
                BotSystemHandler.onCommand(sender, m.GetString(1).Substring(1), playerId, player, this);
                break;
            }

            case "add":
            {
                Player player = new Player(m);
                lock (playerList)
                {
                    if (!playerList.ContainsKey(m.GetInt(0)))
                    {
                        playerList.Add(m.GetInt(0), player);
                    }
                    else
                    {
                        return;
                    }
                }
                lock (nameList)
                {
                    if (nameList.ContainsKey(player.Name))
                    {
                        nameList.Remove(player.Name);
                    }
                    nameList.Add(player.Name, m.GetInt(0));
                    Program.form1.say("System", player.Name + " joined!");
                    lock (Program.form1.lambdaFunctionQueue)
                    {
                        Program.form1.lambdaFunctionQueue.Enqueue((Form1 form1) =>
                            {
                                lock (Program.form1.listBox_PlayerList.Items)
                                    Program.form1.listBox_PlayerList.Items.Add(player.Name);
                            });
                    }
                }
            }
            break;

            case "left":
            {
                int    tempKey = m.GetInt(0);
                Player player;

                lock (playerList)
                {
                    if (playerList.ContainsKey(tempKey))
                    {
                        player = playerList[tempKey];
                    }
                    else
                    {
                        return;
                    }
                }
                string name = player.Name;
                Program.form1.say("System", name + " left!");
                lock (Program.form1.lambdaFunctionQueue)
                {
                    Program.form1.lambdaFunctionQueue.Enqueue((Form1 form1) =>
                        {
                            lock (Program.form1.listBox_PlayerList.Items)
                                Program.form1.listBox_PlayerList.Items.Remove(name);
                            lock (leftPlayerList)
                            {
                                if (leftPlayerList.ContainsKey(tempKey))
                                {
                                    leftPlayerList.Remove(tempKey);
                                }
                                leftPlayerList.Add(tempKey, (Player)player);
                            }
                            lock (leftNameList)
                            {
                                if (leftNameList.ContainsKey(name))
                                {
                                    leftNameList.Remove(name);
                                }
                                leftNameList.Add(name, tempKey);
                            }
                            lock (playerList)
                            {
                                if (playerList.ContainsKey(tempKey))
                                {
                                    playerList.Remove(tempKey);
                                }
                            }
                            lock (nameList)
                            {
                                if (nameList.ContainsKey(name))
                                {
                                    nameList.Remove(name);
                                }
                            }
                        });
                }
            }
            break;

            case "teleport":
            {
                /*_*/
                Player _loc_5   = null;      //BotPlayer _loc_5 = null;
                int    playerId = m.GetInt(0);
                double xPos     = m.GetInt(1);
                double yPos     = m.GetInt(2);

                /*if (param2 == myid)
                 * {
                 *  player.setPosition(param3, param4);
                 * }
                 * else
                 * {*/
                _loc_5 = playerList[playerId];
                //if (_loc_5)
                //{
                /*_*/
                //_loc_5.setPosition(xPos, yPos);
                //}
                //}
                //return;
            }
            break;

            case "tele":
            {
                int playerId = 0;
                int xPos     = 0;
                int yPos     = 0;

                /*_*//*
                 * Player player = null;//BotPlayer player = null;
                 * bool _loc_2 = m.GetBoolean(0);
                 * uint _loc_3 = 1;
                 * while (_loc_3 < m.Count)
                 * {
                 *
                 *  playerId = m.GetInt(_loc_3);
                 *  xPos = m.GetInt((_loc_3 + 1));
                 *  yPos = m.GetInt(_loc_3 + 2);
                 *  if (playerList.ContainsKey(playerId))
                 *  {
                 *      player = playerList[playerId];
                 *      if (player != null)
                 *      {
                 *          player.x = xPos;
                 *          player.y = yPos;
                 *          player.respawn();
                 *          if (_loc_2)
                 *          {
                 *              player.resetCoins();
                 *              player.purple = false;
                 *          }
                 *      }
                 *      /*if (_loc_4 == myid)
                 *      {
                 *          player.x = _loc_5;
                 *          player.y = _loc_6;
                 *          this.x = -_loc_6;
                 *          this.y = -_loc_6;
                 *          player.respawn();
                 *          if (_loc_2)
                 *          {
                 *              player.resetCoins();
                 *              player.purple = false;
                 *              world.hidePurple = false;
                 *              world.resetCoins();
                 *              world.resetSecrets();
                 *          }
                 *      }* /
                 *  }
                 *  _loc_3 += 3;
                 * }*/
            }        // end function
            break;

            case "kill": //error
            {            /*_*//*
                          * BotPlayer _loc_3 = null;
                          * int playerId = m.GetInt(0);
                          *
                          * if (playerList.ContainsKey(playerId))
                          * {
                          *     _loc_3 = playerList[playerId];
                          *     _loc_3.killPlayer();
                          * }*/
            }
            break;

            case "access":
                hasCode = true;
                Program.console.WriteLine("Code Cracked!");
                //connection.Send("say", "I know the code.");
                break;
                /*_*/

                /*case "m":
                 *  {
                 *      BotPlayer player;
                 *      int playerID;
                 *      playerID = int.Parse(m[0].ToString());
                 *      float playerXPos = float.Parse(m[1].ToString());
                 *      float playerYPos = float.Parse(m[2].ToString());
                 *      float playerXSpeed = float.Parse(m[3].ToString());
                 *      float playerYSpeed = float.Parse(m[4].ToString());
                 *      float modifierX = float.Parse(m[5].ToString());
                 *      float modifierY = float.Parse(m[6].ToString());
                 *      int xDir = int.Parse(m[7].ToString());
                 *      int yDir = int.Parse(m[8].ToString());
                 *      lock (playerList)
                 *      {
                 *          if (playerList.ContainsKey(playerID))
                 *          {
                 *              player = playerList[playerID];
                 *              player.x = playerXPos;
                 *              player.y = playerYPos;
                 *              player.speedX = playerXSpeed;
                 *              player.speedY = playerYSpeed;
                 *              player.modifierX = modifierX;
                 *              player.modifierY = modifierY;
                 *              player.horizontal = xDir;
                 *              player.vertical = yDir;
                 *              playerList[playerID] = player;
                 *          }
                 *      }
                 *  }
                 *  break;*/
            }

            BotSystemHandler.onMessage(sender, this, m);// OnMessage(sender, m);
        }
コード例 #7
0
ファイル: Room.cs プロジェクト: ostkaka0/Ostbot2_1
        public override void onMessage(object sender, OstBot ostBot, PlayerIOClient.Message m)
        {
            //try
            //{
            switch (m.Type)
            {
            case "init":
                bool isOwner;
                if (ostBot.isBB)
                {
                    //worldKey = rot13(m[3].ToString());
                    //botPlayerID = m.GetInt(6);
                    width  = m.GetInt(10);
                    height = m.GetInt(11);
                    //hasCode = m.GetBoolean(8);
                    isOwner = m.GetBoolean(9);
                }
                else
                {
                    //worldKey = rot13(m[5].ToString());
                    //botPlayerID = m.GetInt(6);
                    width  = m.GetInt(12);
                    height = m.GetInt(13);
                    //hasCode = m.GetBoolean(10);
                    isOwner = m.GetBoolean(11);
                }


                if (isOwner)
                {
                    BlockDrawer(ostBot);
                }

                lock (blockMap)
                {
                    for (int l = 0; l < 2; l++)
                    {
                        blockMap[l] = new List <Block> [width, height];

                        for (int x = 0; x < width; x++)
                        {
                            for (int y = 0; y < height; y++)
                            {
                                blockMap[l][x, y] = new List <Block>();
                            }
                        }
                    }
                }

                LoadMap(m, 18);
                break;

            case "reset":

                lock (blockMap)
                {
                    for (int l = 0; l < 2; l++)
                    {
                        blockMap[l] = new List <Block> [width, height];

                        for (int x = 0; x < width; x++)
                        {
                            for (int y = 0; y < height; y++)
                            {
                                blockMap[l][x, y] = new List <Block>();
                            }
                        }
                    }
                }
                LoadMap(m, 0);
                break;

            case "access":
                Thread.Sleep(5);
                BlockDrawer(ostBot);
                break;

            case "b":
            {
                Block  block;
                Player placer = null;

                while (blockMap == null)
                {
                    Thread.Sleep(5);
                }

                while (blockMap[m.GetInt(0)] == null)
                {
                    Thread.Sleep(5);
                }

                Block newBlock = new Block(m, ostBot);

                lock (blockMap)
                    blockMap[m.GetInt(0)][m.GetInt(1), m.GetInt(2)].Add(newBlock);

                if (m.Count >= 5)
                {
                    block = Block.CreateBlock(m.GetInt(0), m.GetInt(1), m.GetInt(2), m.GetInt(3), newBlock.placer);
                }
                else
                {
                    block = Block.CreateBlock(m.GetInt(0), m.GetInt(1), m.GetInt(2), m.GetInt(3), null);
                }

                OnBlockDraw(block);
            }
            break;

            case "bc":     // bc, bs, pt, lb, br
            {
                Block block;

                while (blockMap == null)
                {
                    Thread.Sleep(5);
                }

                while (blockMap[0] == null)
                {
                    Thread.Sleep(5);
                }

                block = new Block(m, ostBot);

                lock (blockMap)
                    blockMap[0][m.GetInt(0), m.GetInt(1)].Add(block);

                OnBlockDraw(block);
            }
            break;

            case "bs":
                goto case "bc";

            case "pt":
                goto case "bc";

            case "lb":
                goto case "bc";

            case "br":
                goto case "bc";

            case "clear":
            {
                //Redstone.ClearLists();
                for (int x = 0; x < width; x++)
                {
                    for (int y = 0; y < height; y++)
                    {
                        for (int i = 0; i < blockMap.Length; i++)
                        {
                            blockMap[i][x, y].Add(Block.CreateBlock(0, x, y, 0, null));
                        }
                    }
                }
                DrawBorder();
            }
            break;
            }
            //}
            //catch (Exception e)
            //{
            // ostBot.shutdown();
            //throw e;
            //}
        }