Exemplo n.º 1
0
        private static async UniTask Sample4()
        {
            using (var shapeObject = new DisposableGameObject(new Vector3(-3f, 0f, 0f)))
            {
                var shape = shapeObject.AddComponent <Rectangle>();
                shape.Type      = Rectangle.RectangleType.RoundedHollow;
                shape.Color     = new Color32(255, 242, 173, 255);
                shape.Thickness = 0.1f;

                var cube = shape;

                await Anime.Delay(0.3f);

                await UniTask.WhenAll(
                    Anime.PlayTo(
                        Moving.Linear(3f, 2f),
                        TranslateTo.LocalPositionX(cube)
                        ),
                    Anime.PlayTo(
                        Animator.Delay(1.8f, Easing.Create <Linear>(Vector3.zero, 0.2f)),
                        TranslateTo.LocalScale(cube)
                        )
                    );

                await Anime.Delay(0.3f);
            }
        }
Exemplo n.º 2
0
        private async UniTask CircleTestElement(Component go, float delay)
        {
            await Anime.Delay(delay);

            await Anime.Play(
                Animator.Convert(Easing.Create <OutCubic>(0.0f, Mathf.PI * 2.0f, 2f),
                                 x => new Vector3(Mathf.Sin(x), Mathf.Cos(x), 0.0f) * 3.0f),
                TranslateTo.LocalPosition(go)
                );
        }
Exemplo n.º 3
0
        private async UniTask LineTestElement()
        {
            const byte colorA = 64;

            /*
             * var colors = new[]
             * {
             *  // 114
             *  new Color32(78, 191, 214, colorA),
             *  new Color32(0, 85, 149, colorA),
             *  new Color32(25, 36, 74, colorA),
             *  new Color32(87, 189, 168, colorA),
             *  new Color32(246, 249, 228, colorA),
             *  new Color32(0, 0, 0, colorA),
             *  new Color32(162, 67, 137, colorA),
             *  new Color32(229, 230, 71, colorA),
             * };
             */
            var colors = new[]
            {
                new Color32(255, 0, 0, colorA),
                new Color32(0, 255, 0, colorA),
                new Color32(0, 0, 255, colorA),
                new Color32(255, 255, 0, colorA),
                new Color32(255, 0, 255, colorA),
                new Color32(0, 255, 255, colorA),
            };

            var unitCircle = Random.insideUnitCircle.normalized * Random.Range(2f, 8f);

            using (var shapeObject = new DisposableGameObject(
                       new Vector3(unitCircle.x, unitCircle.y, 50f)
                       ))
            {
                var shape = shapeObject.AddComponent <Line>();
                shape.Geometry  = LineGeometry.Volumetric3D;
                shape.BlendMode = ShapesBlendMode.Additive;
                shape.Color     = colors[Random.Range(0, colors.Length)];
                shape.Start     = new Vector3(0f, 0f, 0f);
                shape.End       = new Vector3(0f, 0f, Random.Range(4f, 10f));
                shape.Thickness = Random.Range(0.1f, 1.0f);

                await UniTask.WhenAll(
                    Anime.PlayTo(
                        Easing.Create <OutCubic>(-20f, Random.Range(1f, 3f)),
                        TranslateTo.LocalPositionZ(shape)
                        ),
                    Anime.Play(
                        Easing.Create <InCubic>(Vector3.zero, Vector3.one, 0.15f),
                        TranslateTo.LocalScale(shape)
                        )
                    );
            }
        }
Exemplo n.º 4
0
        private async Task CircleAnimation(GameObject go, float delay)
        {
            await Anime.Delay(delay);

            await Anime.Play(
                Easing.Create <OutCubic>(0.0f, Mathf.PI * 2.0f, 2f),
                TranslateTo.Action <float>(x =>
            {
                var p = new Vector3(Mathf.Sin(x), Mathf.Cos(x), 0.0f) * 3.0f;
                go.transform.localPosition = p;
            }));
        }
Exemplo n.º 5
0
        public async Task Sample01()
        {
            using (var cubes = new SampleCubes(new Vector3(-5f, 0f, 0f)))
            {
                await Anime.Delay(1f);

                await Anime.PlayTo(
                    Easing.Create <OutCubic>(new Vector3(5f, 0f, 0f), 2f),
                    TranslateTo.LocalPosition(cubes[0])
                    );

                await Anime.Delay(1f);
            }
        }
Exemplo n.º 6
0
        public async Task Sample03()
        {
            using (var cubes = new SampleCubes(new Vector3(-5f, 0f, 0f)))
            {
                await Anime.Delay(1f);

                CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
                cancellationTokenSource.Token.Register(() => Debug.Log("Cancel"));
                cancellationTokenSource.CancelAfter(500);

                await Anime.PlayTo(
                    Easing.Create <OutCubic>(new Vector3(5f, 0f, 0f), 2f),
                    TranslateTo.LocalPosition(cubes[0]),
                    cancellationTokenSource.Token
                    );

                await Anime.Delay(1f);
            }
        }
Exemplo n.º 7
0
        private static async UniTask AnimationElement()
        {
            using (var shapeObjects = new DisposableGameObject(Vector3.zero))
            {
                var shape = shapeObjects.AddComponent <Disc>();
                shape.Type      = Disc.DiscType.Ring;
                shape.Color     = new Color32(255, 242, 173, 255);
                shape.Radius    = 0.3f;
                shape.Thickness = 0.1f;

                const float xrange    = 5f;
                const float yrangeMin = 5f;
                const float yrangeMax = 10f;
                await Anime.PlayTo(
                    Moving.Gravity(new Vector3(Random.Range(-xrange, xrange), Random.Range(yrangeMin, yrangeMax)), Vector3.down * 9.8f, 3f),
                    TranslateTo.LocalPosition(shape)
                    );
            }
        }
Exemplo n.º 8
0
        public async Task Sample04()
        {
            using (var cubes = new SampleCubes(new Vector3(-5f, 0f, 0f)))
            {
                await Anime.Delay(1f);

                await UniTask.WhenAll(
                    Anime.PlayTo(
                        Moving.Linear(2f, 2f),
                        TranslateTo.LocalPositionX(cubes[0])
                        ),
                    Anime.PlayTo(
                        Animator.Delay(1.8f, Easing.Create <Linear>(Vector2.zero, 0.2f)),
                        TranslateTo.LocalScale(cubes[0])
                        )
                    );

                await Anime.Delay(1f);
            }
        }
Exemplo n.º 9
0
        private static async UniTask Sample3()
        {
            using (var shapeObject = new DisposableGameObject(new Vector3(1f, -2f, 0f)))
            {
                var shape = shapeObject.AddComponent <Rectangle>();
                shape.Type      = Rectangle.RectangleType.RoundedHollow;
                shape.Color     = new Color32(255, 242, 173, 255);
                shape.Thickness = 0.1f;

                var cube = shape;

                await Anime.Delay(0.3f);

                await Anime.PlayTo(
                    Easing.Create <InCubic>(new Vector3(-5f, 3f, 0f), 2f),
                    TranslateTo.LocalPosition(cube)
                    );

                await Anime.Delay(0.3f);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// 翻译一个字符串
        /// </summary>
        public static string Translate(string query, TranslateTo TranslateTo)
        {
            // 多个query可以用\n连接  如 query='apple\norange\nbanana\npear'
            //http://api.fanyi.baidu.com/api/trans/vip/translate?q=apple&from=en&to=zh&appid=2015063000000001&salt=1435660288&sign=f89f9594663708c1605f3d736d01d2d4
            //md5加密的参数:str为拼接appid=2015063000000001+q=apple+salt=1435660288+密钥=12345678
            const string serverUrl = "http://api.fanyi.baidu.com/api/trans/vip/translate";
            const string appid     = "20170619000059276";
            const string appsecret = "gzTeKfsNbwJcimeJWNxp";
            string       salt      = TimeHelper.GetTimeStamp().ToString();
            string       sign      = SecurityHelper.MD5String(appid + query + salt + appsecret).ToLower();
            string       to        = "auto";

            if (TranslateTo == TranslateTo.ToEn)
            {
                to = "en";
            }
            if (TranslateTo == TranslateTo.ToZh)
            {
                to = "zh";
            }
            string  json    = RequestHelper.GetWebRequest(serverUrl, new { from = "auto", to = to, appid = appid, q = query, salt = salt, sign = sign }, Encoding.UTF8);
            JObject jsonObj = JsonHelper.DeserializeJObject(json);

            if (!jsonObj.HasValues)
            {
                throw new Exception("Translate Failed");
            }
            JToken temp;

            if (jsonObj.TryGetValue("error_code", out temp))
            {
                //返回错误代码http://api.fanyi.baidu.com/api/trans/product/apidoc
                return(jsonObj.GetValue("error_msg").ToString());
            }
            JToken res  = jsonObj.GetValue("trans_result");
            var    ress = res[0]["dst"].ToString();

            return(ress);
        }
Exemplo n.º 11
0
        private static async UniTask ExplosionTestElement()
        {
            using (var shapeObjects = new DisposableGameObject(Vector3.zero))
            {
                var shape = shapeObjects.AddComponent <Disc>();
                shape.Type      = Disc.DiscType.Ring;
                shape.Color     = new Color32(255, 242, 173, 255);
                shape.Radius    = 0.3f;
                shape.Thickness = 0.1f;

                const float rangeMin = 1f;
                const float rangeMax = 3f;
                var         v        = Random.insideUnitCircle.normalized * Random.Range(rangeMin, rangeMax);

                const float duration      = 1f;
                const float eraseDuration = 0.5f;
                await Anime.Delay(0.5f);

                await UniTask.WhenAll(
                    Anime.PlayTo(
                        Easing.Create <OutExpo>(
                            new Vector3(v.x, v.y, 0f),
                            duration
                            ),
                        TranslateTo.LocalPosition(shape)
                        ),
                    Anime.Play(
                        Animator.Delay(duration - eraseDuration - 0.3f, Easing.Create <Linear>(1f, 0f, eraseDuration)),
                        TranslateTo.Action <float>(x =>
                {
                    var tmp     = shape.Color;
                    tmp.a       = x;
                    shape.Color = tmp;
                })
                        )
                    );
            }
        }
Exemplo n.º 12
0
        static void Main(String[] args)
        {
            if (args.Length < 4)
            {
                throw new ArgumentException("参数错误。参数格式应为:[-a2b|-b2a] [dictionary path] [input path] [output path]");
            }

            TranslateTo _to       = args[0].Equals("-a2b", StringComparison.CurrentCultureIgnoreCase) ? TranslateTo.B : TranslateTo.A;
            String      _dictPath = Path.GetFullPath(args[1]);
            var         _xmlDict  = XmlDictionary.FromFile(_dictPath, _to);

            String _inputPath = Path.GetFullPath(args[2]);

            var _in_file_paths = new List <FileInfo>();

            ListFiles(new DirectoryInfo(_inputPath), _in_file_paths);

            String _outputPath = Path.GetFullPath(args[3]);

            var   _log          = new List <String>();
            var   _outDict      = new XmlDictionary(_xmlDict.LanguageA, _xmlDict.LanguageB, _xmlDict.To);
            Int32 _changedCount = 0;

            foreach (var path in _in_file_paths)
            {
                //String _outPath = path.DirectoryName.Replace( _inputPath, _outputPath );
                //Translate( path, _outPath, _xmlDict );

                try
                {
                    String _outPath = path.DirectoryName.Replace(_inputPath, _outputPath);
                    Translate(path, _outPath, _xmlDict);
                }
                catch (EntryNotFoundException ex)
                {
                    _outDict.AddRange(ex.Dict);
                    _changedCount += ex.ChangedCount;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    _log.Add(ex.Message);
                }
            }

            if (_log.Count != 0)
            {
                StreamWriter log = new StreamWriter(_outputPath + "\\TS4TSLog.txt", true);

                log.WriteLine("时间:" + System.DateTime.Now.ToLongTimeString());

                log.WriteLine("已汉化条目:" + _changedCount);
                log.WriteLine("未汉化条目:" + _outDict.Count);

                for (Int32 i = 0; i < _log.Count; i++)
                {
                    log.WriteLine(_log[i]);
                }

                log.Close();
            }

            if (_outDict.Count != 0)
            {
                _outDict.SaveAs(_outputPath + "\\XMLDictionary.xml");
            }

            Console.WriteLine("按任意键退出...");
            Console.ReadLine();
        }
Exemplo n.º 13
0
        private static async UniTask Tweet1()
        {
            using (var shapeObjects = new DisposableGameObjectList(new[]
            {
                new Vector3(-5f, 0f),
                new Vector3(-2.5f, 0f),
                new Vector3(0.0f, 0f),
                new Vector3(2.5f, 0f),
                new Vector3(5f, 0f),
            }))

            {
                var shapes = shapeObjects.GameObjects.Select(x =>
                {
                    var shape              = x.AddComponent <Rectangle>();
                    shape.Type             = Rectangle.RectangleType.RoundedHollow;
                    shape.Width            = 1f;
                    shape.Height           = 1f;
                    shape.Color            = new Color32(255, 242, 173, 0);
                    shape.Thickness        = 0f;
                    shape.CornerRadiusMode = Rectangle.RectangleCornerRadiusMode.PerCorner;
                    shape.CornerRadiii     = Vector4.zero;
                    return(shape);
                }).ToArray();

                async UniTask Anime1(Rectangle shape, int index)
                {
                    await Anime.Delay(index * 0.2f);

                    await UniTask.WhenAll(
                        Anime.Play(
                            Easing.Create <OutSine>(0f, 0.15f, 0.5f),
                            TranslateTo.Action <float>(x => shape.Thickness = x)
                            ),
                        Anime.Play(
                            Easing.Create <OutSine>(0f, 1f, 0.1f),
                            TranslateTo.Action <float>(x =>
                    {
                        var tmp     = shape.Color;
                        tmp.a       = x;
                        shape.Color = tmp;
                    })
                            )
                        );

                    await Anime.Delay(0.5f);

                    for (var i = 0; i < 4; ++i)
                    {
                        const float duration = 0.3f;
                        await Anime.Play(
                            Easing.Create <InOutCubic>(0f, 0.5f, duration),
                            TranslateTo.Action <float>(x =>
                        {
                            var tmp = shape.CornerRadiii;
                            tmp[(i + index) % 4] = x;
                            shape.CornerRadiii   = tmp;
                        })
                            );

                        var tmp2 = shape.CornerRadiii;
                        tmp2[(i + index) % 4] = 100;
                        shape.CornerRadiii    = tmp2;
                    }
                }

                async UniTask Anime2(Rectangle shape, int index)
                {
                    const float duration = 1f;
                    await UniTask.WhenAll(
                        Anime.PlayTo(
                            Easing.Create <InOutExpo>(0f, duration),
                            TranslateTo.LocalPositionX(shape.gameObject)
                            )
                        );

                    if (index != 0)
                    {
                        await UniTask.WhenAll(
                            Anime.Play(
                                Easing.Create <OutSine>(1f, 0f, 0.1f),
                                TranslateTo.Action <float>(x =>
                        {
                            var tmp     = shape.Color;
                            tmp.a       = x;
                            shape.Color = tmp;
                        })
                                )
                            );
                    }
                }

                async UniTask Anime3(Rectangle shape)
                {
                    await Anime.Play(
                        Easing.Create <InOutExpo>(0.5f, 0f, 0.5f),
                        TranslateTo.Action <float>(x => shape.CornerRadiii = Vector4.one *x)
                        );

                    await Anime.Play(
                        Easing.Create <InOutExpo>(0f, -20f, 0.5f),
                        TranslateTo.Action <float>(x => shape.transform.localRotation = Quaternion.Euler(0f, 0f, x))
                        );

                    await Anime.Play(
                        Easing.Create <InCubic>(0f, -7f, 0.5f),
                        TranslateTo.LocalPositionY(shape.gameObject)
                        );
                }

                await UniTask.WhenAll(shapes.Select((x, i) => Anime1(x, i)));

                await Anime.Delay(0.25f);

                await UniTask.WhenAll(shapes.Select((x, i) => Anime2(x, i)));
                await Anime3(shapes[0]);

                await Anime.Delay(0.5f);
            }
        }
Exemplo n.º 14
0
 public XmlDictionary(System.Byte languageA, System.Byte languageB, TranslateTo to)
 {
     LanguageA = languageA;
     LanguageB = languageB;
     To        = to;
 }
Exemplo n.º 15
0
        public static XmlDictionary FromFile(String xmlDictionaryPath, TranslateTo to)
        {
            XmlDictionary xmlDictionary;
            var           _xe = XDocument.Load(xmlDictionaryPath)?.Element(DICTIONARY) ?? null;

            if (_xe == null)
            {
                throw new ApplicationException("Xml读取失败。");
            }

            String _as = _xe.Attribute(A)?.Value ?? String.Empty;
            Byte   _a  = Convert.ToByte(_as, 16);
            String _bs = _xe.Attribute(B)?.Value ?? String.Empty;
            Byte   _b  = Convert.ToByte(_bs, 16);

            if (String.IsNullOrEmpty(_as) || String.IsNullOrEmpty(_bs))
            {
                throw new ApplicationException("语言代码不能为空。");
            }

            xmlDictionary = new XmlDictionary(_a, _b, to);
            var _enumerable = _xe.Elements(ENTRY);

            foreach (var item in _enumerable)
            {
                String _ia = item.Attribute(A)?.Value ?? String.Empty;
                String _ib = item.Attribute(B)?.Value ?? String.Empty;

                if (String.IsNullOrEmpty(to == TranslateTo.A ? _ib : _ia))
                {
                    continue;
                }

                StringEntryIdent _ident   = null;
                String           _package = null;
                String           _ns      = item.Attribute(NAMESPACE)?.Value ?? String.Empty;
                if (!String.IsNullOrEmpty(_ns))
                {
                    String[] _sp = _ns.Split('|');
                    if (_sp.Length >= 1)
                    {
                        if (_sp[0].ToLower().IndexOf(".package") != -1)
                        {
                            _package = _sp[0];

                            if (_sp.Length == 2)
                            {
                                try
                                {
                                    _ident = _sp[1].ToStringEntryIdent();
                                }
                                catch (Exception)
                                {
                                    _ident = null;
                                }
                            }
                        }
                    }
                }

                Entry _entry = new Entry(_ia, _ib, _ident, _package);
                xmlDictionary.Add(_entry);
            }

            return(xmlDictionary);
        }