コード例 #1
0
        public static void PlaySkeletonSfxAsync(Transform Parent, AssetUri Uri, Vector2 Position, LiteAction <SkeletonSfx> Callback, bool IsLoop = false, string AnimationName = "", LiteAction Finished = null)
        {
            if (Parent == null || Uri == null)
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(AnimationName))
            {
                AnimationName = Uri.AssetName;
            }

            AssetManager.CreatePrefabAsync(Uri, (Obj) =>
            {
                var Sfx = new SkeletonSfx(Uri.AssetName, Obj.transform);
                SfxList_.Add(Sfx);
                Sfx.SetParent(Parent, false);
                Sfx.Play(AnimationName, IsLoop, Finished);
                Sfx.Position = Position;

                var order = UnityHelper.GetSortingOrderUpper(Parent);
                UnityHelper.AddSortingOrder(Obj, order + 1);

                Callback?.Invoke(Sfx);
            });
        }
コード例 #2
0
        public static SkeletonSfx PlaySkeletonSfx(Transform Parent, AssetUri Uri, bool IsLoop = false, Vector2?Position = null, string AnimationName = "", LiteAction Finished = null)
        {
            if (Parent == null || Uri == null)
            {
                return(null);
            }

            if (string.IsNullOrWhiteSpace(AnimationName))
            {
                AnimationName = Uri.AssetName;
            }

            var Obj = AssetManager.CreatePrefabSync(Uri);
            var Sfx = new SkeletonSfx(Uri.AssetName, Obj.transform);

            SfxList_.Add(Sfx);
            Sfx.SetParent(Parent, false);
            Sfx.Play(AnimationName, IsLoop, Finished);
            Sfx.Position = Position ?? Vector2.zero;

            var order = UnityHelper.GetSortingOrderUpper(Parent);

            UnityHelper.AddSortingOrder(Obj, order + 1);

            return(Sfx);
        }
コード例 #3
0
        public static BaseCfg <T> Parse <T>(AssetUri Uri) where T : IBaseCfgLine, new()
        {
            if (!DataManager.LoadSync(Uri))
            {
                throw new LiteException($"can't get data table : {Uri}");
            }

            return(Parse <T>(Uri.AssetName));
        }
コード例 #4
0
ファイル: AssertUri.cs プロジェクト: xposure/Assets
 public void AssertUriCompare()
 {
     var a = new AssetUri("module:type:name1");
     var b = new AssetUri("module:type:name2");
     Assert.IsTrue(b.CompareTo(a) > 0);
     Assert.IsTrue(a.CompareTo(b) < 0);
     Assert.IsTrue(a.CompareTo(a) == 0);
     Assert.IsTrue(b.CompareTo(b) == 0);
 }
コード例 #5
0
        public static uint PlayMusic(AssetUri Uri, bool IsLoop = true, float Volume = 1.0f, bool IsOnly = true)
        {
            if (IsOnly)
            {
                StopAllMusic();
            }

            return(PlayAudio(AudioType.Music, Root_, Uri, IsLoop, Volume));
        }
コード例 #6
0
ファイル: AssertUri.cs プロジェクト: xposure/Assets
 public void AssetUriIsValid()
 {
     var uri = new AssetUri("module:type:name");
     Assert.AreEqual(true, uri.IsValid);
     Assert.AreEqual("module", uri.Module);
     Assert.AreEqual("type", uri.Type);
     Assert.AreEqual("name", uri.Name);
     Assert.AreEqual("module:type:name", uri.FullName);
     Assert.AreEqual("module:type:name".GetHashCode(), uri.GetHashCode());
 }
コード例 #7
0
        public static void AddClickEvent(Transform Obj, UnityAction Callback, AssetUri AudioUri)
        {
            void OnClick()
            {
                AudioManager.PlaySound(AudioUri);
                Callback?.Invoke();
            }

            AddEvent(Obj, OnClick);
        }
コード例 #8
0
ファイル: AssertUri.cs プロジェクト: xposure/Assets
 public void AssertUriOperators()
 {
     var a = new AssetUri("module:type:name");
     var b = new AssetUri("module:type:name");
     Assert.IsTrue(a == b);
     Assert.IsFalse(a != b);
     Assert.IsTrue(a == "module:type:name");
     Assert.IsTrue("module:type:name" == a);
     Assert.IsTrue(a.Equals(b));
     Assert.IsTrue(a.Equals((object)b));
 }
コード例 #9
0
        private static uint PlayAudio(AudioType Type, Transform Parent, AssetUri Uri, bool IsLoop = false, float Volume = 1.0f)
        {
            if (Uri == null)
            {
                return(0);
            }

            var Entity = new AudioEntity(Type);

            AudioList_.Add(Entity.SerialID, Entity);

            AssetManager.CreateAssetAsync <AudioClip>(Uri, (Clip) =>
            {
                if (Clip == null)
                {
                    LLogger.LWarning($"can't play audio : {Uri}");
                    RemoveList_.Add(Entity);
                    return;
                }

                Entity.LoadAudio(Parent, Clip, IsLoop, Volume, false);

                switch (Type)
                {
                case AudioType.Sound:
                    if (MuteSound)
                    {
                        Entity.Mute(MuteSound);
                    }
                    break;

                case AudioType.Music:
                    if (MuteMusic)
                    {
                        Entity.Mute(MuteMusic);
                    }
                    break;

                default:
                    break;
                }

                Entity.Play();
            });

            return(Entity.SerialID);
        }
コード例 #10
0
        public static void ReplaceSprite(SpriteRenderer Master, AssetUri Uri)
        {
            if (Master == null || Uri == null)
            {
                return;
            }

            AssetManager.CreateAssetAsync <Sprite>(Uri, (Spr) =>
            {
                if (Spr == null)
                {
                    LLogger.LWarning($"can't load {Uri}");
                    return;
                }

                Master.sprite = Spr;
            });
        }
コード例 #11
0
        public static void LoadAsync(AssetUri Uri, LiteAction <bool> Callback)
        {
            if (!DataList_.ContainsKey(Uri.AssetName))
            {
                AssetManager.CreateDataAsync(Uri, Buffer =>
                {
                    var Data      = new DataTable(Uri.AssetName);
                    var Succeeded = Data.Parse(Buffer);

                    if (Succeeded)
                    {
                        DataList_.Add(Uri.AssetName, Data);
                    }

                    Callback?.Invoke(Succeeded);
                });
            }
        }
コード例 #12
0
        public static bool LoadSync(AssetUri Uri)
        {
            if (!DataList_.ContainsKey(Uri.AssetName))
            {
                var Buffer    = AssetManager.CreateDataSync(Uri);
                var Data      = new DataTable(Uri.AssetName);
                var Succeeded = Data.Parse(Buffer);

                if (Succeeded)
                {
                    DataList_.Add(Uri.AssetName, Data);
                }

                return(Succeeded);
            }

            return(true);
        }
コード例 #13
0
        public static void PlayParticleSfxAsync(Transform Parent, AssetUri Uri, Vector2 Position, LiteAction <ParticleSfx> Callback, bool IsLoop = false, LiteAction Finished = null)
        {
            if (Parent == null || Uri == null)
            {
                return;
            }

            AssetManager.CreatePrefabAsync(Uri, (Obj) =>
            {
                var Sfx = new ParticleSfx(Uri.AssetName, Obj.transform);
                SfxList_.Add(Sfx);
                Sfx.SetParent(Parent, false);
                Sfx.Play(string.Empty, IsLoop, Finished);
                Sfx.Position = Position;

                var order = UnityHelper.GetSortingOrderUpper(Parent);
                UnityHelper.AddSortingOrder(Obj, order + 1);

                Callback?.Invoke(Sfx);
            });
        }
コード例 #14
0
        public static ParticleSfx PlayParticleSfx(Transform Parent, AssetUri Uri, bool IsLoop = false, Vector2?Position = null, LiteAction Finished = null)
        {
            if (Parent == null || Uri == null)
            {
                return(null);
            }

            var Obj = AssetManager.CreatePrefabSync(Uri);
            var Sfx = new ParticleSfx(Uri.AssetName, Obj.transform);

            SfxList_.Add(Sfx);
            Sfx.SetParent(Parent, false);
            Sfx.Play(string.Empty, IsLoop, Finished);
            Sfx.Position = Position ?? Vector2.zero;

            var order = UnityHelper.GetSortingOrderUpper(Parent);

            UnityHelper.AddSortingOrder(Obj, order + 1);

            return(Sfx);
        }
コード例 #15
0
        public static SkeletonSfx PlaySkeletonSfx(Transform Parent, AssetUri Uri, string AnimationName = "", bool IsLoop = false, Action Finished = null)
        {
            if (Parent == null || Uri == null)
            {
                return(null);
            }

            if (string.IsNullOrWhiteSpace(AnimationName))
            {
                AnimationName = Uri.AssetName;
            }

            var Obj = AssetManager.CreatePrefabSync(Uri);
            var Sfx = new SkeletonSfx(Uri.AssetName, Obj.transform);

            SfxList_.Add(Sfx);
            Sfx.SetParent(Parent, false);
            Sfx.Play(AnimationName, IsLoop, Finished);
            Sfx.Position = Vector2.zero;
            return(Sfx);
        }
コード例 #16
0
ファイル: BaseEntityRef.cs プロジェクト: xposure/zSprite_Old
        public override string ToString()
        {
            AssetUri      prefabUri = PrefabURI;
            StringBuilder builder   = new StringBuilder();

            builder.Append("EntityRef{id = ");
            builder.Append(Id);
            NetworkComponent networkComponent = getComponent(typeof(NetworkComponent));

            if (networkComponent != null)
            {
                builder.Append(", netId = ");
                builder.Append(networkComponent.NetworkId);
            }
            if (prefabUri != null)
            {
                builder.Append(", prefab = '");
                builder.Append(prefabUri.toSimpleString());
                builder.Append("'");
            }
            builder.Append("}");
            return(builder.ToString());
        }
コード例 #17
0
        public static void ReplaceSprite(Image Master, bool IsNativeSize, AssetUri Uri)
        {
            if (Master == null || Uri == null)
            {
                return;
            }

            AssetManager.CreateAssetAsync <Sprite>(Uri, (Spr) =>
            {
                if (Spr == null)
                {
                    LLogger.LWarning($"can't load {Uri}");
                    return;
                }

                Master.sprite = Spr;

                if (IsNativeSize)
                {
                    Master.SetNativeSize();
                }
            });
        }
コード例 #18
0
        public static ParticleSfx PlayParticleSfx(Transform Parent, AssetUri Uri, bool IsLoop = false, Action Finished = null)
        {
            if (Parent == null || Uri == null)
            {
                return(null);
            }

            var Obj = AssetManager.CreatePrefabSync(Uri);
            var Sfx = new ParticleSfx(Uri.AssetName, Obj.transform);

            SfxList_.Add(Sfx);
            Sfx.SetParent(Parent, false);
            Sfx.Play(string.Empty, IsLoop, Finished);
            Sfx.Position = Vector2.zero;

            var Canvas = UnityHelper.GetComponentUpper <Canvas>(Parent);

            if (Canvas != null && Canvas.overrideSorting)
            {
                UnityHelper.AddSortingOrder(Obj, Canvas.sortingOrder + 1);
            }

            return(Sfx);
        }
コード例 #19
0
        public static void PlayParticleSfxAsync(Transform Parent, AssetUri Uri, Vector2 Position, Action <ParticleSfx> Callback, bool IsLoop = false, Action Finished = null)
        {
            if (Parent == null || Uri == null)
            {
                return;
            }

            AssetManager.CreatePrefabAsync(Uri, (Obj) =>
            {
                var Sfx = new ParticleSfx(Uri.AssetName, Obj.transform);
                SfxList_.Add(Sfx);
                Sfx.SetParent(Parent, false);
                Sfx.Play(string.Empty, IsLoop, Finished);
                Sfx.Position = Position;

                var Canvas = UnityHelper.GetComponentUpper <Canvas>(Parent);
                if (Canvas != null && Canvas.overrideSorting)
                {
                    UnityHelper.AddSortingOrder(Obj, Canvas.sortingOrder + 1);
                }

                Callback?.Invoke(Sfx);
            });
        }
コード例 #20
0
 public void ReplaceSprite(string ChildPath, bool IsNativeSize, AssetUri Uri)
 {
     UIHelper.ReplaceSprite(GetComponent <Image>(ChildPath), IsNativeSize, Uri);
 }
コード例 #21
0
 public void AddClickEventToChild(string ChildPath, UnityAction Callback, AssetUri AudioUri)
 {
     UIHelper.AddClickEventToChild(UITransform, ChildPath, Callback, AudioUri);
 }
コード例 #22
0
 public void AddClickEventToChild(string ChildPath, LiteAction <EventSystemData> Callback, AssetUri AudioUri)
 {
     UIHelper.AddClickEventToChild(UITransform, ChildPath, Callback, AudioUri);
 }
コード例 #23
0
 public void AddClickEvent(UnityAction Callback, AssetUri AudioUri)
 {
     UIHelper.AddClickEvent(UITransform, Callback, AudioUri);
 }
コード例 #24
0
 public UIDescriptor(AssetUri Uri, bool OpenMore, bool Cached)
 {
     this.Uri      = Uri;
     this.OpenMore = OpenMore;
     this.Cached   = Cached;
 }
コード例 #25
0
 public static uint PlaySound(AssetUri Uri, bool IsLoop = false, float Volume = 1.0f)
 {
     return(PlayAudio(AudioType.Sound, Root_, Uri, IsLoop, Volume));
 }
コード例 #26
0
 public OpenTKMesh(AssetUri uri, MeshData data)
     : base(uri)
 {
     reload(data);
 }
コード例 #27
0
        public static void AddClickEventToChild(Transform Parent, string ChildPath, UnityAction Callback, AssetUri AudioUri)
        {
            void OnClick()
            {
                AudioManager.PlaySound(AudioUri);
                Callback?.Invoke();
            }

            AddEventToChild(Parent, ChildPath, OnClick);
        }
コード例 #28
0
 public static void AddClickEventToChild(GameEntity Entity, string ChildPath, UnityAction Callback, AssetUri AudioUri)
 {
     AddClickEventToChild(Entity?.GetTransform(), ChildPath, Callback, AudioUri);
 }
コード例 #29
0
ファイル: PojoPrefab.cs プロジェクト: xposure/zSprite_Old
 public PojoPrefab(AssetUri uri, PrefabData data) : base(uri)
 {
     reload(data);
 }
コード例 #30
0
 public static void AddClickEvent(GameEntity Entity, UnityAction Callback, AssetUri AudioUri)
 {
     AddClickEvent(Entity?.GetTransform(), Callback, AudioUri);
 }
コード例 #31
0
ファイル: Prefab.cs プロジェクト: xposure/zSprite_Old
 public Prefab(AssetUri uri) : base(uri)
 {
 }
コード例 #32
0
        public static void AddClickEventToChild(Transform Parent, string ChildPath, LiteAction <EventSystemData> Callback, AssetUri AudioUri)
        {
            void OnClick(EventSystemData Data)
            {
                AudioManager.PlaySound(AudioUri);
                Callback?.Invoke(Data);
            }

            AddEventToChild(Parent, ChildPath, OnClick);
        }