Пример #1
0
        private void OnEnable()
        {
            this.maxSize = new Vector2(600, 600);

            XmlDocument doc  = new XmlDocument();
            string      path = "Assets/Examples/GUIGames/BWC/Editor/Game_BWC.xml";

            doc.Load(path);
            guiCanvas = new GUICanvas();
            guiCanvas.DeSerialize(doc.DocumentElement);
            WC      = Resources.Load <Texture2D>("bai");
            BC      = Resources.Load <Texture2D>("hei");
            map     = new Map(guiCanvas.Find <Area>("map"));
            wCount  = guiCanvas.Find <Label>("top/count/w/count");
            bCount  = guiCanvas.Find <Label>("top/count/b/count");
            jiesuan = guiCanvas.Find <ImageArea>("jiesuan");


            GameObject go = new GameObject("BG");

            go.hideFlags = HideFlags.DontSave | HideFlags.HideInHierarchy;
            BG           = go.AddComponent <AudioSource>();
            BG.clip      = Resources.Load <AudioClip>("BG");
            BG.Play();
            BG.loop = true;

            go           = new GameObject("sound");
            go.hideFlags = HideFlags.DontSave | HideFlags.HideInHierarchy;
            Sound        = go.AddComponent <AudioSource>();
        }
Пример #2
0
        private void OnEnable()
        {
            XmlDocument doc  = new XmlDocument();
            string      path = "Assets/Examples/GUIGames/2048/Resources/Game_2048.xml";

            doc.Load(path);
            guiCanvas = new GUICanvas();
            guiCanvas.DeSerialize(doc.DocumentElement);
            guiCanvas.Find <Button>("ImageArea/up/up").OnClick      = UpClick;
            guiCanvas.Find <Button>("ImageArea/down/left").OnClick  = LeftClick;
            guiCanvas.Find <Button>("ImageArea/down/down").OnClick  = DownClick;
            guiCanvas.Find <Button>("ImageArea/down/right").OnClick = RigntClick;
            guiCanvas.Find <Button>("btn/reset").OnClick            = Reset;
            Reset();
        }
Пример #3
0
        private void OnGUI()
        {
            float val = (float)EditorApplication.timeSinceStartup % 1f;

            guiCanvas.Find <Horizontal>("top").color = new Color(val, val, val, val);
            guiCanvas.canvasRect = new Rect(Vector2.zero, position.size);
            guiCanvas.OnGUI();
            Repaint();
        }
Пример #4
0
 private void FreshView()
 {
     guiCanvas.Find <Label>("Horizontal/score").text = Score.ToString();
     for (int i = 0; i < size; i++)
     {
         for (int j = 0; j < size; j++)
         {
             int val = arr[i, j];
             if (val != 0)
             {
                 guiCanvas.Find <Label>(string.Format("map/{0}/{1}", i + 1, j + 1)).text = val.ToString();
             }
             else
             {
                 guiCanvas.Find <Label>(string.Format("map/{0}/{1}", i + 1, j + 1)).text = "";
             }
         }
     }
 }
Пример #5
0
        private void OnEnable()
        {
            this.maxSize = new Vector2(600, 500);
            btns.Clear();
            XmlDocument doc  = new XmlDocument();
            string      path = "Assets/Examples/GUIGames/HitMice/Resources/Game_HitMice.xml";

            doc.Load(path);
            guiCanvas = new GUICanvas();
            guiCanvas.DeSerialize(doc.DocumentElement);

            Texture2D hited = guiCanvas.Find <ImageLabel>("hited").image;
            Texture2D Show  = guiCanvas.Find <ImageLabel>("chutou").image;

            score  = 0;
            second = 0;
            guiCanvas.Find <Label>("BG/top/score").text = score.ToString();

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Button btn = guiCanvas.Find <Button>(string.Format("BG/{0}/{1}", i + 1, j + 1));
                    btns.Add(new BtnMice(btns.Count, btn, hited, Show, HitCallBack));
                }
            }
            ImageToggle togEasy     = guiCanvas.Find <ImageToggle>("lev/lev/easy/check");
            ImageToggle togMid      = guiCanvas.Find <ImageToggle>("lev/lev/mid/check");
            ImageToggle togHard     = guiCanvas.Find <ImageToggle>("lev/lev/hard/check");
            ImageToggle togVeryHard = guiCanvas.Find <ImageToggle>("lev/lev/veryHard/check");

            togEasy.value         = true;
            lev                   = 1;
            togEasy.onValueChange = (bo) =>
            {
                if (bo)
                {
                    togVeryHard.value = togMid.value = togHard.value = false;
                    lev = 1;
                }
                else
                {
                    if (!togMid.value && !togHard.value && !togVeryHard.value)
                    {
                        togEasy.value = true;
                    }
                }
            };
            togMid.onValueChange = (bo) =>
            {
                if (bo)
                {
                    togVeryHard.value = togEasy.value = togHard.value = false;
                    lev = 2;
                }
                else
                {
                    if (!togEasy.value && !togHard.value && !togVeryHard.value)
                    {
                        togMid.value = true;
                    }
                }
            };
            togHard.onValueChange = (bo) =>
            {
                if (bo)
                {
                    togVeryHard.value = togMid.value = togEasy.value = false;
                    lev = 3;
                }
                else
                {
                    if (!togMid.value && !togEasy.value && !togVeryHard.value)
                    {
                        togHard.value = true;
                    }
                }
            };
            togVeryHard.onValueChange = (bo) =>
            {
                if (bo)
                {
                    togHard.value = togMid.value = togEasy.value = false;
                    lev           = 6;
                }
                else
                {
                    if (!togMid.value && !togEasy.value && !togHard.value)
                    {
                        togHard.value = true;
                    }
                }
            };

            GameObject go = new GameObject("niganma");

            go.hideFlags = HideFlags.DontSave | HideFlags.HideInHierarchy;
            niganma      = go.AddComponent <AudioSource>();
            niganma.clip = Resources.Load <AudioClip>("niganma");

            go              = new GameObject("jinitaimei");
            go.hideFlags    = HideFlags.DontSave | HideFlags.HideInHierarchy;
            jinitaimei      = go.AddComponent <AudioSource>();
            jinitaimei.clip = Resources.Load <AudioClip>("jinitaimei");
        }
Пример #6
0
 private void HitCallBack()
 {
     guiCanvas.Find <Label>("BG/top/score").text = (++score).ToString();
     niganma.Stop();
     niganma.Play();
 }