Ejemplo n.º 1
0
    private void List_Render(int index, GObject item)
    {
        GButton obj = item.asCom.GetChild("n0").asButton;
        GImage  bg  = item.asCom.GetChild("n1").asImage;

        bg.visible = false;
        Dictionary <string, object> dc = (Dictionary <string, object>)list[index];
        string uid = dc["uid"] + "";

        if (uid.Equals(userModel.uid))
        {
            bg.visible = true;
        }
        string dc1 = (string)(dc["head_use"]);

        Tools.SetLoaderButtonUrl(obj, ModelUser.GetHeadUrl(dc1));
        obj.RemoveEventListeners();
        obj.onClick.Add(() =>
        {
            if (!uid.Equals(userModel.uid))
            {
                this.DispatchGlobalEvent(new MainEvent(MainEvent.SHOW_USER, new object[] {
                    otherInfo ["uid"].ToString(),
                    dc ["uid"].ToString(),
                    roleModel.tab_Role_CurSelect1,
                    roleModel.tab_Role_CurSelect2,
                    roleModel.tab_Role_CurSelect3
                }));
            }
            else
            {
                ViewManager.inst.ShowText(Tools.GetMessageById("13106"));
            }
        });
    }
Ejemplo n.º 2
0
        public void Awake(GObject go)
        {
            if (go == null)
            {
                return;
            }

            GObject = go;

            if (string.IsNullOrWhiteSpace(Name))
            {
                Name = Id.ToString();
            }

            self = (GButton)go;

            self.Add(this);

            var com = go.asCom;

            if (com != null)
            {
                bg = (GImage)com.GetChild("bg");
            }
        }
Ejemplo n.º 3
0
 public void DetectField()
 {
     var config = new TestConfig();
     Commands commands = new Commands(config);
     config.ReadConfig(new string[] {
         "x-offset=10",
         "y-offset=50",
     });
     Script.InitScript(commands);
     GImage img = new GImage("data\\fullfield.png");
     Script s = new Script("test");
     // Грузим исходную картинку, на которой осуществляется поиск
     s.Parse("detectfield");
     s.Parse("fielddetected");
     var nimg = new GImage("data\\nofield.png");
     {
         ScriptState st = new ScriptState(s, nimg);
         Run(s, st);
         Assert.IsFalse(st.Running, "Лишнее поле нашлось");
     }
     {
         ScriptState st = new ScriptState(s, img);
         Run(s, st);
         Assert.IsTrue(st.Running, "Поле не нашлось");
     }
 }
Ejemplo n.º 4
0
        public override void Resume()
        {
            GResource.LoadTextures();

            imgLMD = new GImage(Game);
            imgLMD.SetTexture(GResource.game_fon);
            imgLMD.SetWidth(250);
            imgLMD.SetHeight(200);
            imgLMD.SetX(Game.GetWindowWidth() / 2);
            imgLMD.SetY(Game.GetWindowHeight() / 2 + 100);
            AddElement(imgLMD);

            CircleButton but = new CircleButton(Game);

            but.onClick += ScreenStart_onClick;
            but.SetX(Game.GetWindowWidth() / 2);
            but.SetY(150);
            but.SetRadius(80);
            but.SetImage(GImage.LoadTexture(@"C:\Users\User\Desktop\WarBugs\button_play.png"));

            GameFramewerk.UI.Animations.AnimationScale anim = new GameFramewerk.UI.Animations.AnimationScale();
            anim.Initialize(but.GetWidth(), but.GetHeight(), but.GetWidth() + 20, but.GetHeight() + 20, 4, 4, but);

            AddElement(but);
        }
Ejemplo n.º 5
0
        public void Awake(GObject go)
        {
            if (go == null)
            {
                return;
            }

            GObject = go;

            if (string.IsNullOrWhiteSpace(Name))
            {
                Name = Id.ToString();
            }

            self = (GComponent)go;

            self.Add(this);

            var com = go.asCom;

            if (com != null)
            {
                bg          = (GImage)com.GetChild("bg");
                loadingText = (GTextField)com.GetChild("loadingText");
                loadingBar  = FUILoadingProgressBar.Create(Domain, com.GetChild("loadingBar"));
            }
        }
Ejemplo n.º 6
0
 public void TM()
 {
     var config = new TestConfig();
     Commands commands = new Commands(config);
     config.ReadConfig(new string[] {
         "x-offset=10",
         "y-offset=50",
     });
     Script.InitScript(commands);
     var img = new GImage(@"data\leofield.jpg");
     Script s = new Script("test");
     // Грузим исходную картинку, на которой осуществляется поиск
     s.Parse("detectfield");
     s.Parse("fielddetected");
     s.Parse("fieldcells");
     {
         ScriptState st = new ScriptState(s, img);
         Run(s, st);
         StringBuilder sb = new StringBuilder(1024);
         for (var y = 0; y < ScriptState.FieldSize.Height; ++y)
         {
             for (var x = 0; x < ScriptState.FieldSize.Width; ++x)
             {
                 var c = st[x, y];
                 var t = c.NotOpened ? '_' : c.Flag ? 'P' : c.Empty ? ' ' : (char)((byte)'0' + c.Number);
                 sb.Append(t);
                 sb.Append(' ');
             }
             sb.Append("\n");
         }
         File.WriteAllText("out.txt", sb.ToString());
     }
 }
Ejemplo n.º 7
0
        public override void ConstructFromXML(XML xml)
        {
            base.ConstructFromXML(xml);

            m_button = this.GetController("button");
            m_n1     = (GImage)this.GetChild("n1");
        }
        public void Awake(GObject go)
        {
            if (go == null)
            {
                return;
            }

            GObject = go;

            if (string.IsNullOrWhiteSpace(Name))
            {
                Name = Id.ToString();
            }

            self = (GProgressBar)go;

            self.Add(this);

            var com = go.asCom;

            if (com != null)
            {
                bar = (GImage)com.GetChildAt(0);
            }
        }
Ejemplo n.º 9
0
    public bool SetListCSS(GObject item, object[] roleRecord, int index)
    {
        bool   isVisible = true;
        GGroup itemObj   = item.asCom.GetChild("item").asGroup;
        GImage itemBg    = item.asCom.GetChild("itemBg").asImage;

        itemBg.visible  = true;
        itemObj.visible = true;
        if (index % 2 == 0)
        {
            itemBg.visible = false;
        }
        if (roleRecord.Length <= listCssNum && roleRecord.Length > 0)
        {
            if (index > roleRecord.Length - 1)
            {
                isVisible       = false;
                itemObj.visible = false;
            }
        }
        if (!isVisible)
        {
            item.touchable = false;
        }
        return(isVisible);
    }
Ejemplo n.º 10
0
        public override void Resume()
        {
            GResource.LoadTextures();

            var imageFon = new GImage(Game);

            imageFon.SetTexture(GResource.game_fon);
            imageFon.SetWidth(Game.GetWindowWidth());
            imageFon.SetHeight(Game.GetWindowHeight());
            imageFon.SetX(Game.GetWindowWidth() / 2);
            imageFon.SetY(Game.GetWindowHeight() / 2);
            AddElement(imageFon);

            tree = new ChristmasTree(Game);
            tree.GenerateDecorations(3);

            train = new Train(Game, GResource.train);
            train.Initialize(Game.GetWindowWidth() / 2, 65, 90, 30);
            train.SetChristmasTree(tree);

            cat = new Cat(Game, Game.GetWindowWidth() / 2, Game.GetWindowHeight() / 2, 50, 50);
            cat.AddTextures(GResource.lcat, Cat.STATE.LEFT);
            cat.AddTextures(GResource.rcat, Cat.STATE.RIGHT);
            cat.Bump();
            cat.SetChristmasTree(tree);
            //	AddElement(imageCat);
        }
Ejemplo n.º 11
0
        public override void Dispose()
        {
            if (IsDisposed)
            {
                return;
            }

            base.Dispose();

            self.Remove();
            self = null;

            n0             = null;
            n9             = null;
            n10            = null;
            Btn_Login      = null;
            Btn_Registe    = null;
            accountInput   = null;
            passwordInput  = null;
            accountText    = null;
            Tex_LoginInfo  = null;
            ToTestSceneBtn = null;
            passwordText   = null;
            n16            = null;
            t0             = null;
            t1             = null;
        }
Ejemplo n.º 12
0
        public void Awake(GObject go)
        {
            if (go == null)
            {
                return;
            }

            GObject = go;

            if (string.IsNullOrWhiteSpace(Name))
            {
                Name = Id.ToString();
            }

            self = (GComponent)go;

            self.Add(this);

            var com = go.asCom;

            if (com != null)
            {
                bg          = (GImage)com.GetChild("bg");
                enterButton = FGUITitleButton.Create(domain, com.GetChild("enterButton"));
            }
        }
Ejemplo n.º 13
0
        public void Awake(GObject go)
        {
            if (go == null)
            {
                return;
            }

            GObject = go;

            if (string.IsNullOrWhiteSpace(Name))
            {
                Name = Id.ToString();
            }

            self = (GComponent)go;

            self.Add(this);

            var com = go.asCom;

            if (com != null)
            {
                Tex_ValueToFall = (GTextField)com.GetChildAt(0);
                n3           = (GImage)com.GetChildAt(1);
                FallingBleed = com.GetTransitionAt(0);
            }
        }
Ejemplo n.º 14
0
        public override void ConstructFromXML(XML xml)
        {
            base.ConstructFromXML(xml);

            m_n2 = (GMovieClip)this.GetChild("n2");
            m_n3 = (GImage)this.GetChild("n3");
        }
Ejemplo n.º 15
0
    private void FindObject()
    {
        GButton btn = this.GetChild("n66").asButton;

        btn.text = Tools.GetMessageById("21015");
        GButton callBack = this.GetChild("n104").asButton;

        callBack.onClick.Add(CallBack);
        //tab_root_0 = this.GetChild("n3").asButton;
        tab_root_1 = this.GetChild("bar1").asButton;
        tab_root_2 = this.GetChild("bar2").asButton;

        n1 = this.GetChild("n5").asImage;
        //userModel.GetUnlcok(Config.UNLOCK_MAIL_REWARD, tab_root_1);
        //tabC2 = this.GetController("c1");
        AddGlobalListener(MainEvent.RED_UPDATE, RedUpdate);
        RedUpdate(null);

        InitTopBar(new string[] {
            Tools.GetMessageById("21006"),
            Tools.GetMessageById("21007"),
            Tools.GetMessageById("21008")
        });
        tabC2.onChanged.Add(On_Root_Change);
        //tabC1.onChangeTip.Add(On_Root_ChangeTips);
        //      GGroup gift = this.GetChild ("n63").asGroup;
        //GGroup help = this.GetChild ("n62").asGroup;



        //ModelManager.inst.userModel.GetUnlcok (Config.UNLOCK_MAIL_REWARD, gift);
        //ModelManager.inst.userModel.GetUnlcok (Config.UNLOCK_MALL_HELP, help);
        //tabC1.changeObj.Add (gift);
        //tabC1.changeObj.Add (help);
        List <GObject> gs = new List <GObject> ();
        //int[] pos = new int[2]{ 265, 471 };
        //if (gift.visible)
        //	gs.Add (gift);
        //if (help.visible)
        //	gs.Add (help);
        //for (int i = 0; i < gs.Count; i++)
        //	gs [i].x = pos [i];
        Dictionary <string, string> locks = new Dictionary <string, string>();

        locks.Add("bar1", "true");
        locks.Add("bar2", "true");
        //
        //Check_UnlockBar(locks);
        Check_TabLock(locks, null);

        if (roleModel.tab_Select1 != -1 && roleModel.tab_Select1 != 0)
        {
            tabC1.selectedIndex   = roleModel.tab_Select1;
            roleModel.tab_Select1 = -1;
        }
        else
        {
            this.On_Root_Change();
        }
    }
Ejemplo n.º 16
0
        public void PrintBubble(string text, GameObject parent)
        {    //对话气泡
            GameObject Bubble = GameObjectManager.Instance.Create("bubbleandtext");

            Bubble.transform.parent   = parent.transform;
            Bubble.transform.position = new Vector3(parent.transform.position.x - 3.46f + bubblepos.x, parent.transform.position.y + 6.84f + bubblepos.y, parent.transform.position.z + bubblepos.y);
            var        ui        = Bubble.GetComponent <UIPanel>().ui;
            GImage     Bubbleimg = ui.GetChild("n0").asImage;
            GTextField textui    = ui.GetChild("bubbletext").asTextField;

            textui.text = text;
            textTE      = new TypingEffect(textui);
            textTE.Start();
            //Timers.inst.StartCoroutine(textTE.Print(0.500f));
            //textui.text = text;
            int dfd = text.Length;

            //char[] gfdg=text.ToCharArray();

            Timers.inst.StartCoroutine(textTE.Print(TypingEffecttime));
            DelayFunc("waitTypingEffect", () =>
            {
                ui.DOFade(0, 1f).OnComplete(() =>
                {
                    Tools.Destroy(Bubble);
                });
            }, waitTypingEffecttime);
        }
Ejemplo n.º 17
0
 public void ScriptTestMethod()
 {
     var config = new TestConfig();
     Commands commands = new Commands(config);
     config.ReadConfig(new string[] {
         "x-offset=10",
         "y-offset=50",
         "image=firstpic:data\\hint.png"
     });
     Script.InitScript(commands);
     GImage img = new GImage("data\\testsource.png");
     Script s = new Script("test");
     // Грузим исходную картинку, на которой осуществляется поиск
     s.Parse("match firstpic");
     {
         ScriptState st = new ScriptState(s, img);
         Run(s, st);
         Assert.IsTrue(st.Rectangle.Equals(new Rectangle(1238, 853, 196, 37)), "Не найден прямоугольник");
     }
     s = new Script("test");
     s.Parse("setmode first");
     s.Parse("mode first");
     {
         ScriptState st = new ScriptState(s, img);
         Run(s, st);
         Assert.IsTrue(st.Running, "Тест не продолжился");
     }
     s.Parse("mode nfirst");
     {
         ScriptState st = new ScriptState(s, img);
         Run(s, st);
         Assert.IsFalse(st.Running, "Тест продолжился ошибочно");
     }
 }
        public override void ConstructFromXML(XML xml)
        {
            base.ConstructFromXML(xml);

            n0  = (GImage)GetChildAt(0);
            bar = (GImage)GetChildAt(1);
        }
Ejemplo n.º 19
0
        public override void Dispose()
        {
            if (IsDisposed)
            {
                return;
            }

            base.Dispose();

            self.Remove();
            self = null;

            Gro_ShowVersionInfo = null;
            n0                     = null;
            n9                     = null;
            n10                    = null;
            Btn_Login              = null;
            Btn_Registe            = null;
            accountInput           = null;
            passwordInput          = null;
            accountText            = null;
            Tex_LoginInfo          = null;
            ToTestSceneBtn         = null;
            passwordText           = null;
            Gro_LoginInfo          = null;
            Gros_Detail_BackGround = null;
            n26                    = null;
            Gro_Detail             = null;
            Btn_VersionInfo        = null;
            Gro_VersionInfo        = null;
            t0                     = null;
            t1                     = null;
            Anim_VersionHide       = null;
            Anim_VersionShow       = null;
        }
Ejemplo n.º 20
0
        public override void ConstructFromXML(XML xml)
        {
            base.ConstructFromXML(xml);

            m_BackGround  = (GImage)this.GetChildAt(0);
            m_TextContent = (GTextField)this.GetChildAt(1);
        }
Ejemplo n.º 21
0
        public void Awake(GObject go)
        {
            if (go == null)
            {
                return;
            }

            GObject = go;

            if (string.IsNullOrWhiteSpace(Name))
            {
                Name = Id.ToString();
            }

            self = (GComponent)go;

            self.Add(this);

            var com = go.asCom;

            if (com != null)
            {
                cost_bg    = (GImage)com.GetChildAt(3);
                cost_txt   = (GTextField)com.GetChildAt(4);
                effect_txt = (GRichTextField)com.GetChildAt(5);
                attack_txt = (GTextField)com.GetChildAt(6);
                hp_txt     = (GTextField)com.GetChildAt(7);
                size_bg    = (GImage)com.GetChildAt(8);
                size_txt   = (GTextField)com.GetChildAt(9);
            }
        }
Ejemplo n.º 22
0
        public override void Dispose()
        {
            if (IsDisposed)
            {
                return;
            }

            base.Dispose();

            self.Remove();
            self = null;

            m_Gro_ShowVersionInfo = null;
            m_n0  = null;
            m_n9  = null;
            m_n10 = null;
            m_Btn_Login.Dispose();
            m_Btn_Login = null;
            m_Btn_Registe.Dispose();
            m_Btn_Registe   = null;
            m_accountInput  = null;
            m_passwordInput = null;
            m_accountText   = null;
            m_Tex_LoginInfo = null;
            m_ToTestSceneBtn.Dispose();
            m_ToTestSceneBtn = null;
            m_passwordText   = null;
            m_Gro_LoginInfo  = null;
            m_t0             = null;
            m_t1             = null;
        }
Ejemplo n.º 23
0
        public void Awake(GObject go)
        {
            if (go == null)
            {
                return;
            }

            GObject = go;

            if (string.IsNullOrWhiteSpace(Name))
            {
                Name = Id.ToString();
            }

            self = (GComponent)go;

            self.Add(this);

            var com = go.asCom;

            if (com != null)
            {
                n16            = (GImage)com.GetChildAt(0);
                Tex_Level      = (GTextField)com.GetChildAt(1);
                Tex_PlayerName = (GTextField)com.GetChildAt(2);
                n15            = (GImage)com.GetChildAt(3);
                Bar_HP         = Bar_HP.Create(com.GetChildAt(4));
                HPGapList      = (GList)com.GetChildAt(5);
                Bar_MP         = Bar_MP.Create(com.GetChildAt(6));
            }
        }
Ejemplo n.º 24
0
        public override void ConstructFromXML(XML xml)
        {
            base.ConstructFromXML(xml);

            grayed = this.GetController("grayed");
            bg     = (GImage)this.GetChild("bg");
        }
Ejemplo n.º 25
0
        public override void ConstructFromXML(XML xml)
        {
            base.ConstructFromXML(xml);

            m_n2  = (GImage)this.GetChild("n2");
            m_bar = (GImage)this.GetChild("bar");
        }
Ejemplo n.º 26
0
        public void Awake(GObject go)
        {
            if (go == null)
            {
                return;
            }

            GObject = go;

            if (string.IsNullOrWhiteSpace(Name))
            {
                Name = Id.ToString();
            }

            self = (GComponent)go;

            self.Add(this);

            var com = go.asCom;

            if (com != null)
            {
                bg            = (GImage)com.GetChild("bg");
                contentBG     = (GImage)com.GetChild("contentBG");
                accountBg     = (GImage)com.GetChild("accountBg");
                accountInput  = (GTextInput)com.GetChild("accountInput");
                passwordBg    = (GImage)com.GetChild("passwordBg");
                passwordInput = (GTextInput)com.GetChild("passwordInput");
                loginButton   = FGUITitleButton.Create(domain, com.GetChild("loginButton"));
                registButton  = FGUITitleButton.Create(domain, com.GetChild("registButton"));
                content       = (GGroup)com.GetChild("content");
            }
        }
Ejemplo n.º 27
0
    private void OnRender(int index, GObject item)
    {
        GTextField title   = item.asCom.GetChild("n1").asTextField;
        GTextField content = item.asCom.GetChild("n2").asTextField;
        GButton    more    = item.asCom.GetChild("n3").asButton;
        GImage     bg      = item.asCom.GetChild("n0").asImage;
        Dictionary <string, object> itemData = (Dictionary <string, object>)noticeData [index];

        if (itemData ["button"].Equals(""))
        {
            more.visible = false;
        }
        else
        {
            more.visible = true;
            more.text    = Tools.GetMessageById((string)itemData["button"]);
            more.onClick.Add(() =>
            {
                Application.OpenURL(Tools.GetMessageById((string)itemData["url"]));
            });
        }

        title.text        = BaseUbbParser.inst.Parse(Tools.GetMessageById((string)itemData["name"]));
        content.text      = BaseUbbParser.inst.Parse(Tools.GetMessageById((string)itemData["content"]));
        item.asCom.height = content.textHeight + content.y + more.height + 30;
        bg.height         = item.asCom.height;
        more.y            = item.asCom.height - more.height - 20;
    }
Ejemplo n.º 28
0
        public void Awake(GObject go)
        {
            if (go == null)
            {
                return;
            }

            GObject = go;

            if (string.IsNullOrWhiteSpace(Name))
            {
                Name = Id.ToString();
            }

            self = (GComponent)go;

            self.Add(this);

            var com = go.asCom;

            if (com != null)
            {
                n0          = (GImage)com.GetChildAt(0);
                Tittle      = (GTextField)com.GetChildAt(1);
                Conten      = (GTextField)com.GetChildAt(2);
                tow_cancel  = tow_cancel.Create(com.GetChildAt(3));
                tow_confirm = one_confirm.Create(com.GetChildAt(4));
                towmode     = (GGroup)com.GetChildAt(5);
                one_confirm = one_confirm.Create(com.GetChildAt(6));
                onemode     = (GGroup)com.GetChildAt(7);
            }
        }
Ejemplo n.º 29
0
        public void Awake(GObject go)
        {
            if (go == null)
            {
                return;
            }

            GObject = go;

            if (string.IsNullOrWhiteSpace(Name))
            {
                Name = Id.ToString();
            }

            self = (GButton)go;

            self.Add(this);

            var com = go.asCom;

            if (com != null)
            {
                m_button = com.GetControllerAt(0);
                m_n0     = (GImage)com.GetChildAt(0);
                m_n1     = (GImage)com.GetChildAt(1);
                m_title  = (GTextField)com.GetChildAt(2);
            }
        }
Ejemplo n.º 30
0
        public void Awake(GObject go)
        {
            if (go == null)
            {
                return;
            }

            GObject = go;

            if (string.IsNullOrWhiteSpace(Name))
            {
                Name = Id.ToString();
            }

            self = (GLabel)go;

            self.Add(this);

            var com = go.asCom;

            if (com != null)
            {
                n0          = (GImage)com.GetChildAt(0);
                title       = (GTextField)com.GetChildAt(1);
                icon        = (GLoader)com.GetChildAt(2);
                dragArea    = (GGraph)com.GetChildAt(3);
                contentArea = (GGraph)com.GetChildAt(4);
            }
        }
Ejemplo n.º 31
0
        public void Awake(GObject go)
        {
            if (go == null)
            {
                return;
            }

            GObject = go;

            if (string.IsNullOrWhiteSpace(Name))
            {
                Name = Id.ToString();
            }

            self = (GComponent)go;

            self.Add(this);

            var com = go.asCom;

            if (com != null)
            {
                greenBg  = (GImage)com.GetChildAt(0);
                WinBg    = (GImage)com.GetChildAt(1);
                SimpleBg = (GImage)com.GetChildAt(2);
                ShowIn   = (GTextField)com.GetChildAt(3);
                n13      = (GGroup)com.GetChildAt(4);
            }
        }
Ejemplo n.º 32
0
    private void FindeObject()
    {
        Dictionary <string, object> dc = (Dictionary <string, object>)DataManager.inst.systemSimple["picture_config"];

        upload_max             = (int)dc["upload_max"];
        list                   = this.GetChild("n2").asList;
        image_photo_           = this.GetChild("n0");
        image_photo            = image_photo_.asCom.GetChild("n0").asLoader;
        image_photo_.touchable = false;
        content                = this.GetChild("n5").asTextField;
        del         = this.GetChild("n3").asButton;
        del.visible = false;
        image_      = this.GetChild("n4").asImage;
        bg          = this.GetChild("n51").asImage;
        del.onClick.Add(() => {
            if (StatusCurr == 1)
            {
                ViewManager.inst.ShowAlert(Tools.GetMessageById("13161"), DelPhoto, true);
            }
            else
            {
                DelPhoto(1);
            }
        });
        MoveStart();
        image_photo_.onTouchBegin.Add(touchBegin);
        image_photo_.onTouchEnd.Add(touchEnd);
        image_photo_.onRollOut.Add(touchEnd);
    }
Ejemplo n.º 33
0
        public static void LoadTextures()
        {
            game_fon = GImage.LoadTexture(PATH_ASSETS + "fon.png");
            g_1      = GImage.LoadTexture(PATH_ASSETS + "1.png");
            g_1_1    = GImage.LoadTexture(PATH_ASSETS + "1-1.png");
            g_2      = GImage.LoadTexture(PATH_ASSETS + "2.png");
            g_2_2    = GImage.LoadTexture(PATH_ASSETS + "2-2.png");
            g_3      = GImage.LoadTexture(PATH_ASSETS + "3.png");
            g_3_3    = GImage.LoadTexture(PATH_ASSETS + "3-3.png");
            g_4      = GImage.LoadTexture(PATH_ASSETS + "4.png");
            g_4_4    = GImage.LoadTexture(PATH_ASSETS + "4-4.png");
            g_5      = GImage.LoadTexture(PATH_ASSETS + "5.png");
            g_5_5    = GImage.LoadTexture(PATH_ASSETS + "5-5.png");
            train    = GImage.LoadTexture(PATH_ASSETS + "train.png");

            lcat = new uint[16];
            for (int i = 0; i < lcat.Length; i++)
            {
                lcat[i] = GImage.LoadTexture(PATH_ASSETS + @"cat\L\" + (i + 1) + ".png");
            }

            rcat = new uint[16];
            for (int i = 0; i < rcat.Length; i++)
            {
                rcat[i] = GImage.LoadTexture(PATH_ASSETS + @"cat\R\" + (i + 1) + ".png");
            }
        }
Ejemplo n.º 34
0
        public void Action(ScriptState state)
        {
            Shaft[] shafts = new[] {
                                 new Shaft("Леонсио", "leonsio", 13, new Point(-96,169), new Size(450,350)),
                                 new Shaft("Ухта", "uhta", 17, new Point(-88,48), new Size(450,350))
                             };
            foreach (var s in shafts)
            {
                var b = global::kmine.Properties.Resources.ResourceManager.GetObject(s.image) as Bitmap;
                if (b != null)
                {
                    var x = new GImage(b);
                    var u = state.Image.Find(x, new Point());
                    if (!u.IsEmpty)
                    {
                        ScriptState.TotalMines = s.mines;
                        ScriptState.Shaft = s.name;
                        ScriptState.FieldSize = new Size(s.size.Width / 50, s.size.Height / 50);
                        state.ActionDone = true;
                        ///!!! Debug
                        //                        Gray c = new Gray(255);
                        //                        state.Image.Draw(u, c, 1);
                        u = new Rectangle(new Point(u.Left + s.delta.X, u.Top + s.delta.Y), s.size);
                        ScriptState.FieldRectangle = u;
                        //                        state.Image.Draw(u, c, 1);
                        //                        state.Image.Save("2.bmp");
                        break;
                    }
                }
                else Program.log.Error("EdgeDetect: No resource found {0}", s.image);
            }

            // !!! Задать ссылку на угол
            /*var img = new kmine.GImage(global::kmine.Properties.Resources.leonsio);
            if (Check(state, img)) { }
            var tl = state.Image.Find(Top, new Point());
            if (!tl.IsEmpty)
            {

                var TopLeft = new kmine.GImage(global::kmine.Properties.Resources.leonsio);
                tl = state.Image.Find(TopLeft, new Point());
                if (!tl.IsEmpty)
                {
                    var BottomRight = new GImage(global::kmine.Properties.Resources.greenlight);
                    var br = state.Image.Find(BottomRight, new Point());
                    if (!br.IsEmpty)
                    {

                    }
                }
            }*/
        }
Ejemplo n.º 35
0
 public void FlashDetectTest()
 {
     var config = new TestConfig();
     Commands commands = new Commands(config);
     config.ReadConfig(new string[] {
         "max-width=1000",
         "max-height=800"
     });
     var img = new Bitmap("data\\nofield.png");
     GImage.FindFlash(config, true, true, img);
     var r = new GImage(img);
     r.Draw(new Rectangle(config.xOffset, config.yOffset, config.maxWidth, config.maxHeight), new Gray(128), 2);
     //r.Save("0.bmp");
     Assert.AreEqual(832, config.xOffset, "Detect X");
     Assert.AreEqual(130, config.yOffset, "Detect Y");
 }
Ejemplo n.º 36
0
 public bool Parse(string data)
 {
     if (data.StartsWith(@"@"))
     {
         var i = data.Remove(0, 1);
         var o = global::kmine.Properties.Resources.ResourceManager.GetObject(i) as Bitmap;
         if (o != null)
         {
             Img = new GImage(o);
         }
         else
             Program.log.Error("Can't locate image {0}", data);
     }
     else
         if ((Img = Cfg[data]) == null)
             Program.log.Error("Can't locate image {0}", data);
     return true;
 }
Ejemplo n.º 37
0
 /// <summary>
 /// Проверить шахту на картинке
 /// </summary>
 /// <param name="img"></param>
 /// <returns></returns>
 private bool Check(ScriptState state, GImage img)
 {
     var tl = state.Image.Find(img, new Point());
     return false;
 }
Ejemplo n.º 38
0
 public ScriptState(Script script, GImage image)
 {
     Parent = script;
     Running = true;
     Image = image;
     ActionDone = false;
     Rectangle = new Rectangle();
 }
Ejemplo n.º 39
0
 GImage ToGray(GImage src)
 {
     return new GImage(src.InRange(new Emgu.CV.Structure.Gray(0), new Emgu.CV.Structure.Gray(100)).Bitmap);
 }
Ejemplo n.º 40
0
 /// <summary>
 /// Запуск скрипта
 /// </summary>
 /// <param name="img">снятое изображение экрана</param>
 /// <returns>Скрипт выполнил задачу (false - отработал вхолостую)</returns>
 internal bool Run(GImage img)
 {
     Program.log.Info(Name);
     var state = new ScriptState(this, img);
     foreach (var c in commands)
     {
         Program.log.Info(" {0}", c.Name);
         c.Action(state);
         if (!state.Running)
             break;
     }
     return state.ActionDone;
 }
Ejemplo n.º 41
0
        private void tm_Tick(object sender, EventArgs e)
        {
            var wbmp = GImage.Capture(config);
            pb1.Image = wbmp;
            //x.Save("1.bmp");
            if (wbmp != null)
            {
                var bmp = new GImage(wbmp);
                bool ok = false;
                // Сравиваем экран с предыдущим
                if (oldbmp != null)
                {
                    if (bmp.Equals(oldbmp))
                    {
                        ok = true;
                        mode = Mode.Active;
                    }
                    else mode = Mode.Wait;

                }
                // Если ок - смотрим на экшн, если не ок - значит началось и можно взводить ожидание экшна после успокоения
                // !!!! сделать таймер, который взводит экшн даже когда всё оставалось ок
                if (ok)
                {
                    if (action)
                    {
                        // Прогоняем все скрипты
                        foreach (var im in scripts)
                        {
                            if (im.Run(bmp))
                            {
                                action = false;
                                grid.DrawField();
                            }
                        }
                        CMode.Text = ScriptState.Mode;
                    }
                }
                else
                {
                    action = true;
                }
                oldbmp = bmp;
            }
            else Close();
        }