示例#1
0
 public void Edit(ResData data)
 {
     if (DataReader.GetBit(data.bitMask, 1)) // Слой
     {
         sr.sortingOrder = data.layer;
     }
     if (DataReader.GetBit(data.bitMask, 7)) // X позиция
     {
         tr.position = new Vector3(data.x, tr.position.y);
     }
     if (DataReader.GetBit(data.bitMask, 8)) // Y позиция
     {
         tr.position = new Vector3(tr.position.x, data.y);
     }
     if (DataReader.GetBit(data.bitMask, 15)) // Видимость
     {
         objectSprite.SetActive(data.visible);
     }
     if (DataReader.GetBit(data.bitMask, 9)) // Видимость
     {
         tr.localScale = new Vector3(data.scale, data.scale);
     }
     if (DataReader.GetBit(data.bitMask, 18)) // src
     {
         sr.sprite = Resources.Load <UnityEngine.Sprite>("Scenario/Textures/" + data.src);
     }
     if (DataReader.GetBit(data.bitMask, 10)) // Угол поворота
     {
         tr.rotation = Quaternion.AngleAxis(data.angle, new Vector3(0f, 0f, 1f));
     }
 }
示例#2
0
        public Sprite(ResData data, GameObject pre, Transform sceneParent)
        {
            canvastr          = sceneParent.GetComponentInChildren <Canvas>().gameObject.transform;
            objectSprite      = GameObject.Instantiate(pre, canvastr);
            objectSprite.name = data.id;
            objectSprite.SetActive(data.visible);

            tr            = objectSprite.GetComponent <Transform>();
            tr.position   = new Vector3(data.x, data.y);
            tr.localScale = new Vector3(data.scale, data.scale);
            tr.rotation   = Quaternion.AngleAxis(data.angle, new Vector3(0f, 0f, 1f));

            sr              = objectSprite.GetComponent <SpriteRenderer>();
            sr.sprite       = Resources.Load <UnityEngine.Sprite>("Scenario/Textures/" + data.src);
            sr.sortingOrder = data.layer;
        }
示例#3
0
        public SortedDictionary <string, IDisplayable> objects; // Dictionary с объектами
        //public SortedDictionary<string, Sound> sounds;                // Dictionary с звуков
        //public SortedDictionary<string, Music> musics;                // Dictionary с музыкой

        public void CreateObject(int type, ResData data, Transform sceneParent)
        {
            orderLayer += 1;
            data.layer += orderLayer;
            switch (type)
            {
            case 1:
                objects[data.id] = new Sprite(data, ResourceManager.GetPrefab("spritePrefab"), sceneParent);
                break;

            /*case 2:
             *  objects[data.id] = new AnimateSprite(data, ResourceManager.GetPrefab("spritePrefab"), sceneParent);
             *  break;*/
            case 3:
                objects[data.id] = new Video(data, ResourceManager.GetPrefab("spritePrefab"), sceneParent);
                break;

            case 4:
                objects[data.id] = new Text(data, ResourceManager.GetPrefab("spritePrefab"), sceneParent);
                break;
            }
        }
示例#4
0
        // Загрузка и создание объектов по ноде.
        public void LoadNode(XmlNode node)
        {
            if (node == null)
            {
                goto NullNode;
            }
            else
            {
                foreach (XmlNode childnode in node.ChildNodes) // Сделать отдельные классы [TO DO]
                {
                    ResData data = DataReader.GetData(childnode);
                    switch (childnode.Name)
                    {
                    case "SPRITE":
                        if (scene.objects.ContainsKey(data.id))
                        {
                            Debug.Log("Изменяем SPRITE");
                            scene.EditObject(data);
                        }
                        else
                        {
                            Debug.Log(string.Format("<b>Создаю объект <color=teal>спрайта</color></b> ({0}, {1})", data.id, data.src));
                            scene.CreateObject(1, data, sceneParent);
                            continue;
                        }
                        break;

                    /*case "ANIMATESPRITE":
                     *  if (scene.objects.ContainsKey(data.id))
                     *  {
                     *      Debug.Log("Изменяем ANIMATESPRITE");
                     *      scene.objects[data.id].Edit(data);
                     *  }
                     *  else
                     *  {
                     *      Debug.Log("<b>Создаю объект <color=teal>анимированного спрайта</color> " + data.id + "</b>");
                     *      scene.CreateObject(2, data, sceneParent);
                     *      continue;
                     *  }
                     *  break;*/
                    case "VIDEO":
                        if (scene.objects.ContainsKey(data.id))
                        {
                            Debug.Log("Изменяем VIDEO");
                            scene.EditObject(data);
                        }
                        else
                        {
                            Debug.Log("<b>Создаю объект <color=teal>видео</color> " + data.id + "</b>");
                            scene.CreateObject(3, data, sceneParent);
                            continue;
                        }
                        break;

                    case "TEXT":
                        if (scene.objects.ContainsKey(data.id))
                        {
                            Debug.Log("Изменяем TEXT");
                            scene.EditObject(data);
                        }
                        else
                        {
                            Debug.Log("<b>Создаю объект <color=teal>текста</color> " + data.id + "</b>");
                            scene.CreateObject(4, data, sceneParent);
                            continue;
                        }
                        break;

                        /*case "MUSIC":
                         *  if (scene.musics.ContainsKey(data.id))
                         *  {
                         *      Debug.Log("Изменяем MUSIC");
                         *      scene.musics[data.id].Edit(data);
                         *  }
                         *  else
                         *  {
                         *      Debug.Log(string.Format("<b>Создаю объект <color=teal>музыки</color></b> ({0}, {1})", data.id, data.src));
                         *      scene.musics[data.id] = new Music(data);
                         *      continue;
                         *  }
                         *  break;
                         * case "SOUND":
                         *  if (scene.sounds.ContainsKey(data.id))
                         *  {
                         *      Debug.Log("Изменяем SOUND");
                         *      scene.sounds[data.id].Edit(data);
                         *  }
                         *  else
                         *  {
                         *      Debug.Log(string.Format("<b>Создаю объект <color=teal>звука</color></b> ({0}, {1})", data.id, data.src));
                         *      scene.sounds[data.id] = new Sound(data);
                         *      continue;
                         *  }
                         *  break;*/
                    }
                }
            }
NullNode:
            Debug.Log("Нода отсутствует");
        }
示例#5
0
        public static ResData GetData(XmlNode node)
        {
            XmlAttribute id = node.Attributes["id"];
            XmlAttribute x  = node.Attributes["x"];
            XmlAttribute y  = node.Attributes["y"];
            //XmlAttribute layermotion = node.Attributes["layermotion"];
            XmlAttribute scale = node.Attributes["scale"];
            XmlAttribute angle = node.Attributes["angle"];
            XmlAttribute layer = node.Attributes["layer"];
            //XmlAttribute style = node.Attributes["style"];
            XmlAttribute visible = node.Attributes["visible"];
            //XmlAttribute alpha = node.Attributes["alpha"];
            XmlAttribute src = node.Attributes["src"];
            //XmlAttribute smooth = node.Attributes["smooth"];

            //XmlAttribute width = node.Attributes["width"];
            //XmlAttribute height = node.Attributes["height"];
            //XmlAttribute loop = node.Attributes["loop"];
            //XmlAttribute delay = node.Attributes["delay"];

            //XmlAttribute command = node.Attributes["command"];
            //XmlAttribute time = node.Attributes["time"];
            //XmlAttribute volume = node.Attributes["volume"];
            //XmlAttribute speed = node.Attributes["speed"];

            //XmlAttribute size = node.Attributes["size"];
            //XmlAttribute text = node.InnerText;
            //XmlAttribute fontId = node.Attributes["font"];
            //XmlAttribute color = node.Attributes["color"];

            ResData res = new ResData
            {
                bitMask = 0
            };

            if (id != null)
            {
                res.id = id.Value; res.bitMask = res.bitMask | (1 << 17);
            }
            else
            {
                res.id = "null";
            }
            if (x != null)
            {
                res.x = float.Parse(x.Value); res.bitMask = res.bitMask | (1 << 7);
            }
            else
            {
                res.x = 0;
            }
            if (y != null)
            {
                res.y = float.Parse(y.Value); res.bitMask = res.bitMask | (1 << 8);
            }
            else
            {
                res.y = 0;
            }
            //if (layermotion != null) { res.layermotion = Convtrue(layermotion.Value); res.bitMask = res.bitMask | (1 << 16); } else res.layermotion = true;
            if (scale != null)
            {
                res.scale = float.Parse(scale.Value) * 112.585f; res.bitMask = res.bitMask | (1 << 9);
            }
            else
            {
                res.scale = 112.585f;
            }
            if (angle != null)
            {
                res.angle = float.Parse(angle.Value); res.bitMask = res.bitMask | (1 << 10);
            }
            else
            {
                res.angle = 0;
            }
            if (layer != null)
            {
                res.layer = int.Parse(layer.Value) * Constants.LayerDivision; res.bitMask = res.bitMask | (1 << 1);
            }
            else
            {
                res.layer = 0;
            }
            //if (style != null) { res.style = style.Value; res.bitMask = res.bitMask | (1 << 20); } else res.style = "null";
            if (visible != null)
            {
                res.visible = Convtrue(visible.Value); res.bitMask = res.bitMask | (1 << 15);
            }
            else
            {
                res.visible = true;
            }
            //if (alpha != null) { res.alpha = 255 * int.Parse(alpha.Value) / 100; res.bitMask = res.bitMask | (1 << 4); } else res.alpha = 255; // [!]
            if (src != null)
            {
                res.src = src.Value; res.bitMask = res.bitMask | (1 << 18);
            }
            else
            {
                res.src = "null";
            }
            //if (smooth != null) { res.smooth = Convtrue(smooth.Value); res.bitMask = res.bitMask | (1 << 14); } else res.smooth = true;

            //if (width != null) { res.width = int.Parse(width.Value); res.bitMask = res.bitMask | (1 << 2); } else res.width = 0;
            //if (height != null) { res.height = int.Parse(height.Value); res.bitMask = res.bitMask | (1 << 3); } else res.height = 0;
            //if (loop != null) { res.loop = Convtrue(loop.Value); res.bitMask = res.bitMask | (1 << 13); } else res.loop = false;
            //if (delay != null) { res.delay = int.Parse(delay.Value); res.bitMask = res.bitMask | (1 << 0); } else res.delay = 40;

            //if (command != null) { res.command = command.Value; res.bitMask = res.bitMask | (1 << 23); } else res.command = "null";
            //if (time != null) { res.time = int.Parse(time.Value); res.bitMask = res.bitMask | (1 << 5); } else res.time = 1000;
            //if (volume != null) { res.volume = float.Parse(volume.Value); res.bitMask = res.bitMask | (1 << 11); } else res.volume = 100;
            //if (speed != null) { res.speed = float.Parse(speed.Value); res.bitMask = res.bitMask | (1 << 12); } else res.speed = 1;

            //if (size != null) { res.size = uint.Parse(size.Value); res.bitMask = res.bitMask | (1 << 6); } else res.size = 1;
            //if (text != null) { res.text = text; res.bitMask = res.bitMask | (1 << 19); } else res.text = "NO TEXT";
            //if (fontId != null) { res.fontId = fontId.Value; res.bitMask = res.bitMask | (1 << 22); } else res.fontId = "standart";
            //if (color != null) { res.color = color.Value; res.bitMask = res.bitMask | (1 << 21); } else res.color = "black";

            return(res);
        }
示例#6
0
 public void EditObject(ResData data)
 {
     objects[data.id].Edit(data);
 }
示例#7
0
 public Text(ResData data, GameObject pre, Transform nodeParent)
 {
 }
示例#8
0
 public void Edit(ResData data)
 {
 }
示例#9
0
 public Video(ResData data, GameObject pre, Transform nodeParent)
 {
 }