Esempio n. 1
0
        private void changeGameStateTo(GameState state)
        {
            if (current_state == state)
                return;

            if (stateChangedEvent != null)
                stateChangedEvent(this, new GameStateChangedEventArgs(current_state, state));

            current_state = state;
        }
Esempio n. 2
0
        public int readGoldFromInventory(String module_name, GameState gamestate)
        {
            try
            {
                if (!gamestate.ingame_flags.isinventoryOpen)
                {
                    main.getInstance().writeToLog(module_name, "Can't read gold. Inventory not open!");
                    return -1;
                }

                LockedFastImage d3Shot = new LockedFastImage(Tools.D3ScreenShot());

                List<GoldHelpClass> list = new List<GoldHelpClass>();
                int number_fail = 10;
                //read 0
                List<Point> p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_0.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot);
                foreach (Point tmp in p)
                    list.Add(new GoldHelpClass(tmp, 0));

                //read 1
                p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_1.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot);
                foreach (Point tmp in p)
                    list.Add(new GoldHelpClass(tmp, 1));

                //read 2
                p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_2.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot);
                foreach (Point tmp in p)
                    list.Add(new GoldHelpClass(tmp, 2));

                //read 3
                p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_3.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot);
                foreach (Point tmp in p)
                    list.Add(new GoldHelpClass(tmp, 3));

                //read 4
                p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_4.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot);
                foreach (Point tmp in p)
                    list.Add(new GoldHelpClass(tmp, 4));

                //read 5
                p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_5.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot);
                foreach (Point tmp in p)
                    list.Add(new GoldHelpClass(tmp, 5));

                //read 6
                p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_6.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot);
                foreach (Point tmp in p)
                    list.Add(new GoldHelpClass(tmp, 6));

                //read 7
                p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_7.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot);
                foreach (Point tmp in p)
                    list.Add(new GoldHelpClass(tmp, 7));

                //read 8
                p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_8.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot);
                foreach (Point tmp in p)
                    list.Add(new GoldHelpClass(tmp, 8));

                //read 9
                p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_9.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot);
                foreach (Point tmp in p)
                    list.Add(new GoldHelpClass(tmp, 9));

                return convertGoldHelpClassListToInt(list);
            }
            catch { return -1; }
        }
Esempio n. 3
0
 public GameStateChangedEventArgs(GameState old_state, GameState new_state)
 {
     this.old_state = old_state;
     this.new_state = new_state;
 }
Esempio n. 4
0
        public GameState openInventory()
        {
            GameState game_state;
            if ((game_state = GameStateChecker.getInstance().current_game_state).ingame_flags.isinventoryOpen)
                return game_state;

            if (GameStateChecker.getInstance().current_game_state.game_state != GameState.GameStates.InGame)
            {
                game_state.game_state = GameState.GameStates.Unknown;
                return game_state;
            }

            Tools.clickInventory();

            DateTime start = DateTime.Now;
            for (; !((game_state = new GameState()).ingame_flags.isinventoryOpen); )
            {
                
                System.Threading.Thread.Sleep(50);

                if ((DateTime.Now - start).TotalMilliseconds >= 2000)
                {
                    game_state.game_state = GameState.GameStates.Unknown;
                    return game_state;
                }
            }

            return game_state;
        }