コード例 #1
0
ファイル: SceneModeFile.cs プロジェクト: BXZR/GAL
    public static void activeScene(int endIndex)
    {
        //print ("check: "+endIndex);
        //防止初始化出现问题
        if (isStarted == false)
        {
            InitValues();
        }
        bool   isActiveOne = false;
        scenes theSceneGet = new scenes("-", 1, 2, 3, false);    //测试用的scene

        //用尾巴标记进行激活
        //有一些不用激活的在初始化的时候直接标记为true就可以了
        for (int i = 0; i < theSceneList1.Count; i++)
        {
            if (theSceneList1 [i].endIndex == endIndex)
            {
                isActiveOne = true;
                theSceneList1 [i].isOpened = true;
                theSceneGet = theSceneList1 [i];
            }
        }
        for (int i = 0; i < theSceneList2.Count; i++)
        {
            //print ("G2 -> "+theSceneList2 [i].endIndex);

            if (theSceneList2 [i].endIndex == endIndex)
            {
                isActiveOne = true;
                theSceneList2 [i].isOpened = true;
                theSceneGet = theSceneList2 [i];
            }
        }

        for (int i = 0; i < theSceneList3.Count; i++)
        {
            if (theSceneList3 [i].endIndex == endIndex)
            {
                isActiveOne = true;
                theSceneList3 [i].isOpened = true;
                theSceneGet = theSceneList3 [i];
            }
        }
        //if (isActiveOne)
        //{
        //	print ("场景激活: "+ theSceneGet.sceneName);
        //}
        //如果有激活就保存到文件里面
        //if(isActiveOne)
        //saveSceneFile();
    }
コード例 #2
0
ファイル: Program.cs プロジェクト: zanzo420/SteamBot
 private static void OnLoggedOn(SteamUser.LoggedOnCallback obj)
 {
     if (obj.Result != EResult.OK)
     {
         ConsoleStatus(statusConsole.ERROR, $"Unable to logon to Steam: {obj.Result}/{obj.ExtendedResult}");
         botIsRunning = false;
         return;
     }
     Console.ForegroundColor = ConsoleColor.Green;
     Console.WriteLine($"BOT {bot.name} Successfully logged on!");
     steamFriends.SetPersonaName(memory_[0]);
     Console.ResetColor();
     currentStatus = scenes.Running;
 }
コード例 #3
0
ファイル: SceneModeFile.cs プロジェクト: BXZR/GAL
    //从存档里面加载出来相关内容
    private static void loadFromFile()
    {
        //读取数据
        string theSceneFilePath = Application.persistentDataPath + "/Scene.txt";

        print(theSceneFilePath);
        string informationRead = "";
        //读取数据
        FileStream   aFile = new FileStream(theSceneFilePath, FileMode.OpenOrCreate);
        StreamReader sw    = new StreamReader(aFile);

        informationRead = sw.ReadToEnd();
        sw.Close();
        sw.Dispose();
        //分析数据
        //同样地,大项目用“;”,小项目用','
        string [] theGroups = informationRead.Split(';');

        theSceneList1 = new List <scenes> ();
        theSceneList2 = new List <scenes> ();
        theSceneList3 = new List <scenes> ();
        //这种写法的功能应该与CGFile模块是一样的
        //功能一样,代码也好看一点,但是做出了额外的计算
        //很难权衡啊,所以分别用了
        for (int item = 0; item < theGroups.Length; item++)
        {
            string[] SP = theGroups [item].Split(',');
            for (int i = 0; i < SP.Length; i += 5)
            {
                scenes theScene = new scenes(SP [i], Convert.ToInt32(SP [i + 1]), Convert.ToInt32(SP [i + 2]), Convert.ToInt32(SP [i + 3]), Convert.ToBoolean(SP [i + 4]));
                if (item == 0)
                {
                    theSceneList1.Add(theScene);
                }
                else if (item == 1)
                {
                    theSceneList2.Add(theScene);
                }
                else if (item == 2)
                {
                    theSceneList3.Add(theScene);
                }
            }
        }
    }
コード例 #4
0
 private void BtnPlay_Click(object sender, EventArgs e)
 {
     sceneActuelle = scenes.prison;
     btnMenu       = false;
 }
コード例 #5
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(_backgroundcolor);

            _spriteBatch.Begin();



            // -- Affichage scene actuelle --
            if (sceneActuelle == scenes.accueil)
            {
                Afficher_Menu(gameTime);
            }
            else if (sceneActuelle == scenes.prison)
            {
                // appel classe prison
                prisonRigidGO[0].Draw(_spriteBatch);
                prisonRigidGO[1].Draw(_spriteBatch);

                playerLvl1.Draw(_spriteBatch);

                if (Keyboard.GetState().IsKeyDown(Keys.B))
                {
                    sceneActuelle = scenes.labo;
                }
            }
            else if (sceneActuelle == scenes.couloir)
            {
                // appel classe couloir
            }
            else // sceneActuelle == scenes.labo
            {
                // appel classe labo
                laboRigidGO[0].Draw(_spriteBatch);
                laboRigidGO[1].Draw(_spriteBatch);
                laboRigidGO[2].Draw(_spriteBatch);
                laboRigidGO[3].Draw(_spriteBatch);
                laboRigidGO[4].Draw(_spriteBatch);

                playerLvl3.Draw(_spriteBatch);
            }



            // -- Affichage Menu --
            _menuComponents[0].Draw(gameTime, _spriteBatch); // Afficher button menu

            // Si le menu est ouvert
            if (btnMenu)
            {
                // Afficher buttons quitter, fleche droite, et fleche gauche
                _menuComponents[1].Draw(gameTime, _spriteBatch);
                _menuComponents[2].Draw(gameTime, _spriteBatch);
                _menuComponents[3].Draw(gameTime, _spriteBatch);

                // Afficher volume ou symbole "noSound"
                if (noSound)
                {
                    MediaPlayer.Volume = 0.0f;
                    _menuComponents[6].Draw(gameTime, _spriteBatch);
                }
                else
                {
                    MediaPlayer.Volume = volume;
                    _spriteBatch.DrawString(Content.Load <SpriteFont>("Fonts/File"), sound.ToString(), new Vector2(PositionSound, 75), Color.White);
                }
                _menuComponents[4].Draw(gameTime, _spriteBatch);


                if (changeMusic)
                {
                    switch (music)
                    {
                    case 1:
                        song = Content.Load <Song>("Music/Danger Escape");
                        MediaPlayer.IsRepeating        = true;
                        MediaPlayer.MediaStateChanged += MediaPlayer_MediaStateChanged;
                        MediaPlayer.Play(song);
                        break;

                    case 2:
                        song = Content.Load <Song>("Music/Firescape");
                        MediaPlayer.IsRepeating        = true;
                        MediaPlayer.MediaStateChanged += MediaPlayer_MediaStateChanged;
                        MediaPlayer.Play(song);
                        break;
                    }
                    changeMusic = false;
                }
            }

            _spriteBatch.End();

            base.Draw(gameTime);
        }
コード例 #6
0
 public static void LoadScene(scenes pScene)
 {
     instance.StartCoroutine(instance.loading(pScene.ToString()));
 }
コード例 #7
0
ファイル: Program.cs プロジェクト: zanzo420/SteamBot
        static void Main(string[] args)
        {
            foreach (var memoria in MemoriaData)
            {
                string response = String.Empty;
                if (memoria[0] == '#')
                {
                    response             = memoria.Replace("#", String.Empty);
                    AnswerAndQuestion[0] = response;
                }
                else if (memoria[0] == '-')
                {
                    response             = memoria.Replace("-", String.Empty);
                    AnswerAndQuestion[1] = response;
                }
                if (!String.IsNullOrWhiteSpace(AnswerAndQuestion[0]) && !String.IsNullOrWhiteSpace(AnswerAndQuestion[1]))
                {
                    try
                    {
                        bManager.brainData.Add(AnswerAndQuestion[0], AnswerAndQuestion[1]);
                    }
                    catch
                    { //ignore same key
                    }
                    AnswerAndQuestion[0] = String.Empty;
                    AnswerAndQuestion[1] = String.Empty;
                }
            }



            System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
            //Commands
            ; try
            {
                CreateCommand("@braintwo", new Action(delegate()
                {
                    bw.Interpreter("$0x", Argument[0]);
                }));
                CreateCommand("@brainfuck", new Action(delegate()
                {
                    BrainfuckClient = new Brainfuck(Argument[0]);
                    BrainfuckClient.RunCommand(Argument[0]);
                }));
                CreateCommand("@xvideos", new Action(delegate()
                {
                    steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, "calma ae xo ve");
                    restart:
                    try
                    {
                        List <string> commentsList = new List <string>();

                        string comment_(string a)
                        {
                            bool count    = true;
                            string result = String.Empty;
                            for (int i = 0; i < a.Length; i++)
                            {
                                if (count)
                                {
                                    if (a[i] != ',')
                                    {
                                        result = result + a[i];
                                    }
                                    else
                                    {
                                        count = false;
                                    }
                                }
                            }
                            return(result.Replace("\"", String.Empty).Replace(": ", String.Empty));
                        }
                        WebClient web           = new WebClient();
                        int numb                = random.Next(1, 37);
                        string link             = $"https://www.xvideos.com/lang/portugues/{numb}";
                        string html             = web.DownloadString(link);
                        var id                  = Regex.Match(html, @"xv\.thumbs\.prepareVideo\(([0-9]+)\);").Groups[1].Value;
                        string apicomment       = $"https://www.xvideos.com/threads/video-comments/get-posts/top/{id}/0/0";
                        List <string> namesList = new List <string>();
                        using (WebClient wc = new WebClient())
                        {
                            var json     = wc.DownloadString(apicomment);
                            JObject obj  = JObject.Parse(json);
                            var comments = obj["posts"]["posts"];
                            foreach (var key in comments)
                            {
                                string[] lName = key.ToString().Split(new string[] { "profile" }, StringSplitOptions.None);
                                string[] l     = key.ToString().Split(new string[] { "message" }, StringSplitOptions.None);
                                commentsList.Add(comment_(l[1]));
                                namesList.Add(comment_(lName[1]));
                            }
                            steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, $"{namesList[random.Next(0, namesList.Count)]} falou: {commentsList[random.Next(0, commentsList.Count)].Replace("&", String.Empty).Replace("<", String.Empty).Replace(";", String.Empty).Replace(">", String.Empty)}");
                            commentsList.Clear();
                            namesList.Clear();
                        }
                    }
                    catch { goto restart; }
                }));
                CreateCommand("@friends", new Action(delegate()
                {
                    for (int i = 0; i < listFriendsSteamID.Count; i++)
                    {
                        Thread.Sleep(15);
                        steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, steamFriends.GetFriendPersonaName(listFriendsSteamID[i]));
                    }
                }));
                CreateCommand("@rpg", new Action(delegate()
                {
                    Check:
                    var account = dbConnection.Query("SELECT * from rpg_users WHERE id=@myid", new { myid = steamIDMemory.AccountID }).FirstOrDefault();
                    if (account != null)
                    {
                        steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, $"Name: {account.UName}");
                        steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, $"Class: {account.Class}");
                        steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, $"Level: {account.Level}");
                        steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, $"Exp: {account.Exp_}/15");
                    }
                    else
                    {
                        try
                        {
                            var CreateAccount = dbConnection.Query(
                                "INSERT INTO rpg_users(ID,Level,Exp_,Class,UName) VALUES (@id,@level,@exp,@class_,@uname)",
                                new
                            {
                                id     = steamIDMemory.AccountID,
                                level  = 0,
                                exp    = 0,
                                class_ = "Archer",
                                uname  = steamFriends.GetFriendPersonaName(steamIDMemory)
                            });
                            Thread.Sleep(30);
                            goto Check;
                        }
                        catch { steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, $"Error to create your account."); }
                    }

                    steamIDMemory = null;
                }));
                CreateCommand("@temp", new Action(delegate()
                {
                    using (WebClient wc = new WebClient())
                    {
                        try
                        {
                            var json    = wc.DownloadString($@"https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22{Argument[0]}%22)%20and%20u%3D%22c%22&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys");
                            JObject obj = JObject.Parse(json);
                            var obj_    = obj["query"]["results"]["channel"]["item"].Select(x => new
                            {
                                temp  = float.Parse(obj["query"]["results"]["channel"]["item"]["condition"]["temp"].ToString()),
                                title = obj["query"]["results"]["channel"]["item"]["title"]
                            }).ToArray();
                            steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, $"{obj_[0].title}");
                            steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, $"Temperature: {obj_[0].temp} ºC");
                        }
                        catch
                        {
                            steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, $"Error to get temperature from this local.");
                        }
                    }
                }));
                CreateCommand("@bitcoin", new Action(delegate()
                {
                    using (WebClient wc = new WebClient())
                    {
                        try
                        {
                            var json    = wc.DownloadString("https://blockchain.info/pt/ticker");
                            JObject obj = JObject.Parse(json);
                            var price   = obj[Argument[0]]["15m"];
                            var symbol  = obj[Argument[0]]["symbol"];
                            steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, $"Price Bitcoin from {Argument[0]}: {price} {symbol}");
                        }
                        catch { steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, $"Error to get price bitcoin from {Argument[0]}"); }
                    }
                }));
                CreateCommand("@math", new Action(delegate()
                {
                    using (WebClient wc = new WebClient())
                    {
                        try
                        {
                            var json    = wc.DownloadString($"https://newton.now.sh/simplify/{Argument[0]}");
                            JObject obj = JObject.Parse(json);
                            var obj_    = obj["result"];
                            steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, $"{obj_}");
                        }
                        catch { steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, $"Error to expression {Argument[0]}"); }
                    };
                }));
                CreateCommand("@qrcode", new Action(delegate()
                {
                    steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, $"https://api.qrserver.com/v1/create-qr-code/?size=150x150&data={Argument[0]}");
                }));
                CreateCommand("@help", new Action(delegate()
                {
                    var KeysCommands = Commands.Keys.ToArray();
                    steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, "==============================");
                    for (int i = 0; i < KeysCommands.Length; i++)
                    {
                        steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, KeysCommands[i]);
                    }
                    steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, "==============================");
                }));
                CreateCommand("@room", new Action(delegate()
                {
                    try
                    {
                        if (Argument[0] == "create")
                        {
                            RoomBehaviour room_ = new RoomBehaviour()
                            {
                                OwnerRoom = steamIDMemory, RoomID = steamIDMemory.GetHashCode(), CodeRoom = Argument[1]
                            };
                            room_.UsersRoom.Add(steamIDMemory);
                            Rooms_dic.Add(steamIDMemory.GetHashCode().ToString(), int.Parse(Argument[1]));
                            Rooms.Add(room_);
                            steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, $"Sucess to create room! id: {Argument[1]}");
                        }
                        if (Argument[0] == "list")
                        {
                            for (int i = 0; i < Rooms.Count; i++)
                            {
                                steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, Rooms[i].CodeRoom);
                            }
                        }
                        if (Argument[0] == "join")
                        {
                            if (Rooms_dic.Values.Contains(int.Parse(Argument[1])))
                            {
                                for (int i = 0; i < Rooms.Count; i++)
                                {
                                    if (Rooms[i].CodeRoom == Argument[1])
                                    {
                                        Rooms[i].UsersRoom.Add(steamIDMemory);
                                        steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, "Sucess to join in room!");
                                    }
                                }
                            }
                        }

                        if (Argument[0] == "leave")
                        {
                            for (int i = 0; i < Rooms.Count; i++)
                            {
                                if (Rooms[i].UsersRoom.Contains(steamIDMemory))
                                {
                                    Rooms[i].UsersRoom.Remove(steamIDMemory);
                                    steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, "Sucess leave to room!");
                                }
                            }
                        }

                        if (Argument[0] == "remove")
                        {
                            if (Rooms_dic.Values.Contains(int.Parse(Argument[1])))
                            {
                                for (int i = 0; i < Rooms.Count; i++)
                                {
                                    for (int x = 0; x < Rooms[i].UsersRoom.Count; x++)
                                    {
                                        Rooms[i].UsersRoom.RemoveAt(x);
                                    }

                                    if (Rooms[i].OwnerRoom == steamIDMemory)
                                    {
                                        Rooms_dic.Remove(steamIDMemory.GetHashCode().ToString());
                                        Rooms.RemoveAt(i);
                                        steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, "Sucess to remove room!");
                                    }
                                }
                            }
                            else
                            {
                                steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, "Room not found!");
                            }
                        }
                        if (Argument[0] == "say")
                        {
                            string msg = String.Empty;
                            for (int i = 0; i < Rooms.Count; i++)
                            {
                                if (Rooms[i].UsersRoom.Contains(steamIDMemory))
                                {
                                    for (int a = 0; a < Rooms[i].UsersRoom.Count; a++)
                                    {
                                        for (int c = 1; c < Argument.Length; c++)
                                        {
                                            try
                                            {
                                                if (!String.IsNullOrWhiteSpace(Argument[c]))
                                                {
                                                    msg = msg + " " + Argument[c];
                                                }
                                            }
                                            catch { }
                                        }
                                        steamFriends.SendChatMessage(Rooms[i].UsersRoom[a], EChatEntryType.ChatMsg, $"{steamFriends.GetFriendPersonaName(steamIDMemory)}: {msg}");
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex) { steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, $"Error to execute command in room!"); }
                }));
            }
            catch { } // Invalids Commands Ignore!

            //

            if (currentStatus == scenes.Login)
            {
                using (StreamReader r = new StreamReader("SteamBot.json"))
                {
                    string  json_data = r.ReadToEnd();
                    JObject bot_data  = JObject.Parse(json_data);
                    if (bot_data["bot_data"]["autologin"].ToString() != "true")
                    {
                        Console.Write("Username: "******"Password: "******"bot_data"]["bot_name"].ToString()
                        };
                        memory_[0]    = bot_data["bot_data"]["bot_name"].ToString();
                        currentStatus = scenes.TryingConnect;
                    }
                    else
                    {
                        bot = new BOT()
                        {
                            name        = bot_data["bot_login"]["bot_user"].ToString(),
                            password    = bot_data["bot_login"]["bot_password"].ToString(),
                            personaname = bot_data["bot_data"]["bot_name"].ToString()
                        };
                        memory_[0]    = bot_data["bot_data"]["bot_name"].ToString();
                        currentStatus = scenes.TryingConnect;
                    }
                }
            }
            if (currentStatus == scenes.TryingConnect)
            {
                steamClient     = new SteamClient();
                callbackManager = new CallbackManager(steamClient);
                steamUser       = steamClient.GetHandler <SteamUser>();
                steamFriends    = steamClient.GetHandler <SteamFriends>();

                callbackManager.Subscribe <SteamClient.ConnectedCallback>(onConnected);
                callbackManager.Subscribe <SteamClient.DisconnectedCallback>(OnDisconnected);
                callbackManager.Subscribe <SteamUser.LoggedOnCallback>(OnLoggedOn);
                callbackManager.Subscribe <SteamUser.LoggedOffCallback>(OnLoggedOff);
                callbackManager.Subscribe <SteamUser.AccountInfoCallback>(OnAccountInfo);
                callbackManager.Subscribe <SteamFriends.FriendsListCallback>(OnFriendsList);
                callbackManager.Subscribe <SteamFriends.PersonaStateCallback>(OnPersonaState);
                callbackManager.Subscribe <SteamFriends.FriendMsgCallback>(OnFriendMsg);

                botIsRunning = true;

                Console.Clear();


                Console.WriteLine($"BOT {bot.name} Connecting to Steam...");
                steamClient.Connect();
            }
            while (botIsRunning)
            {
                callbackManager.RunWaitCallbacks(TimeSpan.FromSeconds(1));
                CountToAddExp += 1;
                if (CountToAddExp >= 100)
                {
                    CountToAddExp = 0;
                    for (int i = 0; i < ListPlayingGame.Count; i++)
                    {
                        try
                        {
                            if (ListPlayingGame.Count > 0)
                            {
                                var QueryToAdd = dbConnection.Query("UPDATE rpg_users set Exp_ = Exp_ + 1 WHERE id=@myid",
                                                                    new { myid = ListPlayingGame[i].AccountID });
                                var SelectCheck = dbConnection.Query("SELECT * FROM rpg_users WHERE id=@myid",
                                                                     new { myid = ListPlayingGame[i].AccountID }).FirstOrDefault();

                                if (SelectCheck != null && SelectCheck.Exp_ >= 15)
                                {
                                    var AddLevel = dbConnection.Query(
                                        "UPDATE rpg_users set Level = Level + 1 WHERE id=@myid",
                                        new { myid = ListPlayingGame[i].AccountID });
                                    var RemoveExp = dbConnection.Query("UPDATE rpg_users set Exp_ = 0 WHERE id=@myid",
                                                                       new { myid = ListPlayingGame[i].AccountID });
                                    steamFriends.SendChatMessage(ListPlayingGame[i], EChatEntryType.ChatMsg, "[RPG] You have reached a new Level");
                                }
                            }
                        }
                        catch { }
                    }
                }
            }
            Console.ReadLine();
        }
コード例 #8
0
 public static void LoadScene(scenes s)//Experimental untested
 {
     SceneManager.LoadScene(s.ToString());
 }
コード例 #9
0
ファイル: MenuScreen.cs プロジェクト: nemmons/PacNyan
 void SwitchScene()
 {
     if (currentScene == scenes.NyanChaseLeft) currentScene = scenes.EnemyChaseRight;
     else currentScene++;
     SwitchDirection();
 }