Beispiel #1
0
                private void SetImage(IResource resource)
                {
                    if (_resource == resource && ForeColor == _cachedImageForeColor)
                    {
                        return;
                    }

                    _resource             = resource;
                    _cachedImageForeColor = ForeColor;

                    if (Image != null)
                    {
                        EnabledImage.Dispose();
                        EnabledImage = null;

                        DisabledImage.Dispose();
                        DisabledImage = null;

                        OverImage.Dispose();
                        OverImage = null;

                        DownImage.Dispose();
                        DownImage = null;

                        Image.Dispose();
                        Image = null;
                    }

                    EnsureImage();
                }
Beispiel #2
0
        void setValue1()
        {
            //GameObject.Find("Canvas/Parents/Image/Text1").GetComponent<Text>().text = "lili1";
            //GameObject.Find("Canvas/Parents/Image/Text2").GetComponent<Text>().text = "lili2";

            //GameObject.Find("Canvas/Parents/Image2/Text1").GetComponent<Text>().text = "lili221";
            //GameObject.Find("Canvas/Parents/Image2/Text2").GetComponent<Text>().text = "lili22";

            //GameObject.Find("Canvas/Parents/Image3/Text1").GetComponent<Text>().text = "lili1333";
            //GameObject.Find("Canvas/Parents/Image3/Text2").GetComponent<Text>().text = "lili2333";

            //GameObject.Find("Canvas/Parents/Image4/Text1").GetComponent<Text>().text = "lili1444";
            //GameObject.Find("Canvas/Parents/Image4/Text2").GetComponent<Text>().text = "lili2555";

            this.transform.Find("Image/Text1").GetComponent <Text>().text = "lili1";
            this.transform.Find("Image/Text2").GetComponent <Text>().text = "lili1";
            this.transform.Find("Image").GetComponent <DownImage>().LoadImage("http://g.hiphotos.baidu.com/image/pic/item/86d6277f9e2f07084eacbbebe724b899a801f2b4.jpg");

            this.transform.Find("Image2/Text1").GetComponent <Text>().text = "lili12222";
            this.transform.Find("Image2/Text2").GetComponent <Text>().text = "lili12222";
            DownImage dm = this.transform.Find("Image2").GetComponent <DownImage>();

            dm.LoadImage("http://g.hiphotos.baidu.com/image/pic/item/86d6277f9e2f07084eacbbebe724b899a801f2b4.jpg");

            this.transform.Find("Image3/Text1").GetComponent <Text>().text = "lili13333";
            this.transform.Find("Image3/Text2").GetComponent <Text>().text = "lili33331";
            this.transform.Find("Image3").GetComponent <DownImage>().LoadImage("http://g.hiphotos.baidu.com/image/pic/item/86d6277f9e2f07084eacbbebe724b899a801f2b4.jpg");

            this.transform.Find("Image4/Text1").GetComponent <Text>().text = "lili14444";
            this.transform.Find("Image4/Text2").GetComponent <Text>().text = "lili15555";
            this.transform.Find("Image4").GetComponent <DownImage>().LoadImage("http://g.hiphotos.baidu.com/image/pic/item/86d6277f9e2f07084eacbbebe724b899a801f2b4.jpg");

            //print(this.transform.Find("Image/Text1").GetComponent<Text>().text);
        }
Beispiel #3
0
        public void PrepareSources(WhoIs w, Side s)
        {
            if (CurrentType == DecalType.Rock && w == WhoIs.Ground)
            {
                Vector3 v3 = new Vector3();
                switch (s)
                {
                //x и -y указывают на ячейку Sand левый верхний угол
                case Side.Down:

                    //rght h=hor t=top

                    v3.x           = (float)x / 10;
                    v3.y           = (float)-y / 10;
                    v3.z           = 0;
                    DownImage      = (GameObject)MonoBehaviour.Instantiate(prefab, v3, Quaternion.identity);
                    DownImage.name = x + "_" + y + "DecalDownImage_";
                    DownImage.GetComponent <SpriteRenderer>().sprite       = StaticSpriteCache.sprites[29];
                    DownImage.GetComponent <SpriteRenderer>().sortingOrder = 1;

                    break;

                case Side.Left:
                    //rgvl v=vert l=left
                    v3.x           = (float)x / 10;
                    v3.y           = (float)-y / 10;
                    v3.z           = 0;
                    LeftImage      = (GameObject)MonoBehaviour.Instantiate(prefab, v3, Quaternion.identity);
                    LeftImage.name = x + "_" + y + "DecalLeftImage_";

                    LeftImage.GetComponent <SpriteRenderer>().sprite       = StaticSpriteCache.sprites[37];
                    LeftImage.GetComponent <SpriteRenderer>().sortingOrder = 1;
                    break;

                case Side.Right:
                    //rgvr
                    v3.x            = (float)x / 10 + 0.06f;
                    v3.y            = (float)-y / 10;
                    v3.z            = 0;
                    RightImage      = (GameObject)MonoBehaviour.Instantiate(prefab, v3, Quaternion.identity);
                    RightImage.name = x + "_" + y + "DecalRightImage_";
                    RightImage.GetComponent <SpriteRenderer>().sprite       = StaticSpriteCache.sprites[28];
                    RightImage.GetComponent <SpriteRenderer>().sortingOrder = 1;
                    break;

                case Side.Up:
                    //rghd
                    v3.x         = (float)x / 10;
                    v3.y         = (float)-y / 10 - 0.07f;
                    v3.z         = 0;
                    UpImage      = (GameObject)MonoBehaviour.Instantiate(prefab, v3, Quaternion.identity);
                    UpImage.name = x + "_" + y + "DecalUpImage_";
                    UpImage.GetComponent <SpriteRenderer>().sprite       = StaticSpriteCache.sprites[34];
                    UpImage.GetComponent <SpriteRenderer>().sortingOrder = 1;
                    break;
                }
            }
            if (CurrentType == DecalType.Sand && w == WhoIs.Ground)
            {
                Vector3 v3 = new Vector3();
                switch (s)
                {
                //x и -y указывают на ячейку Sand левый верхний угол
                case Side.Down:

                    //gght h=hor t=top

                    v3.x           = (float)x / 10;
                    v3.y           = (float)-y / 10;
                    v3.z           = 0;
                    DownImage      = (GameObject)MonoBehaviour.Instantiate(prefab, v3, Quaternion.identity);
                    DownImage.name = x + "_" + y + "DecalDownImage_";
                    DownImage.GetComponent <SpriteRenderer>().sprite       = StaticSpriteCache.sprites[36];
                    DownImage.GetComponent <SpriteRenderer>().sortingOrder = 1;

                    break;

                case Side.Left:
                    //ggvl v=vert l=left
                    v3.x           = (float)x / 10;
                    v3.y           = (float)-y / 10;
                    v3.z           = 0;
                    LeftImage      = (GameObject)MonoBehaviour.Instantiate(prefab, v3, Quaternion.identity);
                    LeftImage.name = x + "_" + y + "DecalLeftImage_";

                    LeftImage.GetComponent <SpriteRenderer>().sprite       = StaticSpriteCache.sprites[35];
                    LeftImage.GetComponent <SpriteRenderer>().sortingOrder = 1;
                    break;

                case Side.Right:
                    //ggvr
                    v3.x            = (float)x / 10 + 0.06f;
                    v3.y            = (float)-y / 10;
                    v3.z            = 0;
                    RightImage      = (GameObject)MonoBehaviour.Instantiate(prefab, v3, Quaternion.identity);
                    RightImage.name = x + "_" + y + "DecalRightImage_";
                    RightImage.GetComponent <SpriteRenderer>().sprite       = StaticSpriteCache.sprites[25];
                    RightImage.GetComponent <SpriteRenderer>().sortingOrder = 1;
                    break;

                case Side.Up:
                    //gghd
                    v3.x         = (float)x / 10;
                    v3.y         = (float)-y / 10 - 0.07f;
                    v3.z         = 0;
                    UpImage      = (GameObject)MonoBehaviour.Instantiate(prefab, v3, Quaternion.identity);
                    UpImage.name = x + "_" + y + "DecalUpImage_";
                    UpImage.GetComponent <SpriteRenderer>().sprite       = StaticSpriteCache.sprites[26];
                    UpImage.GetComponent <SpriteRenderer>().sortingOrder = 1;
                    break;
                }
            }
            //switch (CurrentType)
            //{
            //    case DecalType.Rock & w == WhoIs.Bomb:
            //        switch (s)
            //        {
            //            case Side.Down:
            //                DownImage.Source = ResCache.Brick(18, 4);
            //                break;
            //            case Side.Left:
            //                LeftImage.Source = ResCache.Brick(18, 5);
            //                break;
            //            case Side.Right:
            //                RightImage.Source = ResCache.Brick(18, 6);
            //                break;
            //            case Side.Up:
            //                UpImage.Source = ResCache.Brick(18, 3);
            //                break;
            //        }
            //        break;
            //    //SetUpImagesRockBlack()
            //    case DecalType.Sand && w == WhoIs.Bomb:
            //        switch (s)
            //        {
            //            case Side.Down:
            //                DownImage.Source = ResCache.Brick(18, 2);
            //                break;
            //            case Side.Left:
            //                LeftImage.Source = ResCache.Brick(17, 10);
            //                break;
            //            case Side.Right:
            //                RightImage.Source = ResCache.Brick(18, 1);
            //                break;
            //            case Side.Up:
            //                UpImage.Source = ResCache.Brick(17, 9);
            //                break;
            //        }
            //        break;
            //    //SetUpImagesSandBlack()
            //    case DecalType.Rock & w == WhoIs.Ground:
            //        switch (s)
            //        {
            //            case Side.Down:
            //                DownImage.Source = ResCache.Brick(17, 5);
            //                break;
            //            case Side.Left:
            //                LeftImage.Source = ResCache.Brick(17, 6);
            //                break;
            //            case Side.Right:
            //                RightImage.Source = ResCache.Brick(17, 7);
            //                break;
            //            case Side.Up:
            //                UpImage.Source = ResCache.Brick(17, 4);
            //                break;
            //        }
            //        break;
            //    //SetUpImagesRock()
            //    case DecalType.Sand & w == WhoIs.Ground:
            //        switch (s)
            //        {
            //            case Side.Down:
            //                DownImage.Source = ResCache.Brick(17, 3);
            //                break;
            //            case Side.Left:
            //                LeftImage.Source = ResCache.Brick(17, 1);
            //                break;
            //            case Side.Right:
            //                RightImage.Source = ResCache.Brick(17, 2);
            //                break;
            //            case Side.Up:
            //                UpImage.Source = ResCache.Brick(17, 0);
            //                break;
            //        }
            //        break;
            //    //SetUpImagesSand()
            //}
        }