{"id":530,"date":"2016-02-05T11:33:36","date_gmt":"2016-02-05T03:33:36","guid":{"rendered":"http:\/\/39.100.100.179\/?p=530"},"modified":"2016-10-11T09:30:00","modified_gmt":"2016-10-11T01:30:00","slug":"%e8%bf%90%e5%8a%a8%e5%ad%a6%e7%bc%96%e7%a8%8b","status":"publish","type":"post","link":"http:\/\/www.u3d8.com\/?p=530","title":{"rendered":"\u8fd0\u52a8\u5b66\u7f16\u7a0b"},"content":{"rendered":"<p>\u672c\u6587\u6458\u81ea\u86ee\u725b<a href=\"http:\/\/www.manew.com\/thread-45376-1-1.html\" target=\"_blank\">http:\/\/www.manew.com\/thread-45376-1-1.html<\/a><\/p>\n<p>\u4f9d\u6b21\u662f\uff1a\u7f13\u52a8\u3001\u95f4\u6b47\u3001\u52a0\u901f\u8fd0\u52a8\u3001\u6469\u64e6\u529b\u3001\u5f39\u6027\u79fb\u52a8\u3001\u692d\u5706\u8fd0\u52a8\u3001\u5706\u5468\u8fd0\u52a8\u3001\u6b63\u5f26\u4f59\u5f26\u8fd0\u52a8<br \/>\n<a href=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2016\/02\/huandong.gif\" data-lightbox=\"image_lg\"><img title=\"\u8fd0\u52a8\u5b66\u7f16\u7a0b - \u7b2c1\u5f20  | u3d8\u6280\u672f\u5206\u4eab\" alt=\"\u8fd0\u52a8\u5b66\u7f16\u7a0b - \u7b2c1\u5f20  | u3d8\u6280\u672f\u5206\u4eab\"  loading=\"lazy\" class=\"wp-image-533 alignnone\"  data-src=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2016\/02\/huandong.gif\" width=\"400\" height=\"238\" \/><\/a><a href=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2016\/02\/jianxie.gif\" data-lightbox=\"image_lg\"><img title=\"\u8fd0\u52a8\u5b66\u7f16\u7a0b - \u7b2c2\u5f20  | u3d8\u6280\u672f\u5206\u4eab\" alt=\"\u8fd0\u52a8\u5b66\u7f16\u7a0b - \u7b2c2\u5f20  | u3d8\u6280\u672f\u5206\u4eab\"  loading=\"lazy\" class=\"wp-image-534 alignnone\"  data-src=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2016\/02\/jianxie.gif\" width=\"401\" height=\"239\" \/><\/a><a href=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2016\/02\/jiasu.gif\" data-lightbox=\"image_lg\"><img title=\"\u8fd0\u52a8\u5b66\u7f16\u7a0b - \u7b2c3\u5f20  | u3d8\u6280\u672f\u5206\u4eab\" alt=\"\u8fd0\u52a8\u5b66\u7f16\u7a0b - \u7b2c3\u5f20  | u3d8\u6280\u672f\u5206\u4eab\"  loading=\"lazy\" class=\"wp-image-535 alignnone\"  data-src=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2016\/02\/jiasu.gif\" width=\"399\" height=\"238\" \/><\/a><a href=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2016\/02\/mocali.gif\" data-lightbox=\"image_lg\"><img title=\"\u8fd0\u52a8\u5b66\u7f16\u7a0b - \u7b2c4\u5f20  | u3d8\u6280\u672f\u5206\u4eab\" alt=\"\u8fd0\u52a8\u5b66\u7f16\u7a0b - \u7b2c4\u5f20  | u3d8\u6280\u672f\u5206\u4eab\"  loading=\"lazy\" class=\"wp-image-536 alignnone\"  data-src=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2016\/02\/mocali.gif\" width=\"401\" height=\"239\" \/><\/a><a href=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2016\/02\/tanxing.gif\" data-lightbox=\"image_lg\"><img title=\"\u8fd0\u52a8\u5b66\u7f16\u7a0b - \u7b2c5\u5f20  | u3d8\u6280\u672f\u5206\u4eab\" alt=\"\u8fd0\u52a8\u5b66\u7f16\u7a0b - \u7b2c5\u5f20  | u3d8\u6280\u672f\u5206\u4eab\"  loading=\"lazy\" class=\"wp-image-537 alignnone\"  data-src=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2016\/02\/tanxing.gif\" width=\"401\" height=\"239\" \/><\/a><a href=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2016\/02\/tuoyuan.gif\" data-lightbox=\"image_lg\"><img title=\"\u8fd0\u52a8\u5b66\u7f16\u7a0b - \u7b2c6\u5f20  | u3d8\u6280\u672f\u5206\u4eab\" alt=\"\u8fd0\u52a8\u5b66\u7f16\u7a0b - \u7b2c6\u5f20  | u3d8\u6280\u672f\u5206\u4eab\"  loading=\"lazy\" class=\"wp-image-538 alignnone\"  data-src=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2016\/02\/tuoyuan.gif\" width=\"399\" height=\"238\" \/><\/a><a href=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2016\/02\/yuanzhou.gif\" data-lightbox=\"image_lg\"><img title=\"\u8fd0\u52a8\u5b66\u7f16\u7a0b - \u7b2c7\u5f20  | u3d8\u6280\u672f\u5206\u4eab\" alt=\"\u8fd0\u52a8\u5b66\u7f16\u7a0b - \u7b2c7\u5f20  | u3d8\u6280\u672f\u5206\u4eab\"  loading=\"lazy\" class=\"wp-image-539 alignnone\"  data-src=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2016\/02\/yuanzhou.gif\" width=\"401\" height=\"239\" \/><\/a><a href=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2016\/02\/zhengxuanyuxuan.gif\" data-lightbox=\"image_lg\"><img title=\"\u8fd0\u52a8\u5b66\u7f16\u7a0b - \u7b2c8\u5f20  | u3d8\u6280\u672f\u5206\u4eab\" alt=\"\u8fd0\u52a8\u5b66\u7f16\u7a0b - \u7b2c8\u5f20  | u3d8\u6280\u672f\u5206\u4eab\"  loading=\"lazy\" class=\"wp-image-540 alignnone\"  data-src=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2016\/02\/zhengxuanyuxuan.gif\" width=\"401\" height=\"239\" \/><\/a><\/p>\n<pre class=\"lang:c# decode:true\">using UnityEngine;\r\nusing System.Collections;\r\nusing System;\r\n\r\npublic class TestMoveAnimation : MonoBehaviour {\r\n\r\n    public enum MoveType\r\n    {\r\n        None,\r\n        Yuan,\r\n        TuoYuan,\r\n        HuanDong,\r\n        JianXie,\r\n        ZhengCibo,\r\n        YuSu,\r\n        JiaSu,\r\n        MoCaLi,\r\n        JiaoJiaSu,\r\n        TanXing,\r\n    }\r\n\r\n    public Transform ball;\r\n    public Transform target;\r\n\r\n    public MoveType moveType = MoveType.None;\r\n    public Vector3 center = Vector3.zero;\r\n    public float dis = 3f;\r\n\r\n    private float _px = 0f;\r\n    private float _pz = 0f;\r\n    private float _py = 0f;\r\n    private float _angele = 0f;\r\n\r\n    private float _ratio = 0.05f;\r\n    private float _moveSpeed = 0.05f;\r\n    private float _a = 0.001f;\r\n    private float _ax = 0.001f;\r\n    private float _az = 0.001f;\r\n\r\n    private float _moveSpeedx = 0.05f;\r\n    private float _moveSpeedz = 0.01f;\r\n   \r\n\t\/\/ Use this for initialization\r\n\tvoid Start () {\r\n\t\r\n\t}\r\n\t\r\n\t\/\/ Update is called once per frame\r\n\tvoid Update () {\r\n\r\n        if (ball != null &amp;&amp; target != null)\r\n        {\r\n            if (moveType == MoveType.Yuan)\r\n            {\r\n                _yuanMove();\r\n                _toBounds();\r\n            }\r\n            if (moveType == MoveType.TuoYuan)\r\n            {\r\n                _tuoYuanMove();\r\n                _toBounds();\r\n            }\r\n            if (moveType == MoveType.JianXie)\r\n            {\r\n                _JianXieMove();\r\n                _toBounds();\r\n            }\r\n            if (moveType == MoveType.ZhengCibo)\r\n            {\r\n                _ZhengCiBoMove();\r\n                _toBounds();\r\n            }\r\n            if (moveType == MoveType.YuSu)\r\n            {\r\n                _YuSuMove();\r\n                _toBounds();\r\n            }\r\n            if (moveType == MoveType.JiaSu)\r\n            {\r\n                _JiaSuMove();\r\n                _toBounds();\r\n            }\r\n            if (moveType == MoveType.MoCaLi)\r\n            {\r\n                _MoCaLiMove();\r\n                _toBounds();\r\n            }\r\n            if (moveType == MoveType.HuanDong)\r\n            {\r\n                _huanDongMove();\r\n                _toBounds();\r\n            }\r\n            if (moveType == MoveType.TanXing)\r\n            {\r\n                _tanXinMove();\r\n            }\r\n           \r\n            \r\n        }\r\n\t\r\n\t}\r\n\r\n   \r\n\r\n\r\n\r\n    void OnGUI()\r\n    {\r\n\r\n        if (GUILayout.Button(\"\u5706\u5468\u8fd0\u52a8\"))\r\n        {\r\n             _angele = 0f;\r\n             _moveSpeed = .2f;\r\n             ball.localPosition = Vector3.zero;\r\n             target.localPosition = new Vector3(18f, 0f, 0f);\r\n             moveType = MoveType.Yuan;\r\n             target.gameObject.SetActive(false);\r\n        }\r\n        if (GUILayout.Button(\"\u692d\u5706\u8fd0\u52a8\"))\r\n        {\r\n            _angele = 0f;\r\n            _moveSpeed = .2f;\r\n            ball.localPosition = Vector3.zero;\r\n            target.localPosition = new Vector3(18f, 0f, 0f);\r\n            moveType = MoveType.TuoYuan;\r\n            target.gameObject.SetActive(false);\r\n        }\r\n        if (GUILayout.Button(\"\u7b80\u8c10\u632f\u52a8\"))\r\n        {\r\n            _angele = 0f;\r\n            _moveSpeed = .2f;\r\n            ball.localPosition = Vector3.zero;\r\n            target.localPosition = new Vector3(18f, 0f, 0f);\r\n            moveType = MoveType.JianXie;\r\n            target.gameObject.SetActive(false);\r\n        }\r\n        if (GUILayout.Button(\"\u6b63\u5f26\u4f59\u5f26\u8fd0\u52a8\"))\r\n        {\r\n            _angele = 0f;\r\n            _moveSpeed = .25f;\r\n            ball.localPosition = new Vector3(-18f, 0f, 0f);\r\n            target.localPosition = new Vector3(18f, 0f, 0f);\r\n            moveType = MoveType.ZhengCibo;\r\n            target.gameObject.SetActive(false);\r\n        }\r\n        if (GUILayout.Button(\"\u5300\u901f\u8fd0\u52a8\"))\r\n        {\r\n            _angele = 0f;\r\n            _moveSpeed = .2f;\r\n            ball.localPosition = new Vector3(-18f, 0f, 0f);\r\n            target.localPosition = new Vector3(18f, 0f, 0f);\r\n            moveType = MoveType.YuSu;\r\n            target.gameObject.SetActive(true);\r\n        }\r\n        if (GUILayout.Button(\"\u52a0\u901f\u8fd0\u52a8\"))\r\n        {\r\n            _angele = 0f;\r\n            _moveSpeed = .5f;\r\n            _a = 0.001f;\r\n            ball.localPosition = new Vector3(-18f, 0f, 0f);\r\n            target.localPosition = new Vector3(18f, 0f, 0f);\r\n            moveType = MoveType.JiaSu;\r\n            target.gameObject.SetActive(true);\r\n        }\r\n        if (GUILayout.Button(\"\u6469\u64e6\u529b\"))\r\n        {\r\n            _angele = 0f;\r\n            _moveSpeed = 3f;\r\n            ball.localPosition = new Vector3(-18f, 0f, 0f);\r\n            target.localPosition = new Vector3(18f, 0f, 0f);\r\n            moveType = MoveType.MoCaLi;\r\n            target.gameObject.SetActive(false);\r\n        }\r\n\r\n        if (GUILayout.Button(\"\u7f13\u52a8\"))\r\n        {\r\n            _angele = 0f;\r\n            _moveSpeed = 2f;\r\n            ball.localPosition = new Vector3(-18f, 0f, 0f);\r\n            target.localPosition = new Vector3(18f, 0f, 0f);\r\n            moveType = MoveType.HuanDong;\r\n            target.gameObject.SetActive(true);\r\n        }\r\n        if (GUILayout.Button(\"\u5f39\u6027\u79fb\u52a8\"))\r\n        {\r\n            _angele = 0f;\r\n            _moveSpeed = 2f;\r\n            ball.localPosition = new Vector3(-18f, 0f, 0f);\r\n            target.localPosition = Vector3.zero;\r\n            moveType = MoveType.TanXing;\r\n            target.gameObject.SetActive(true);\r\n        }\r\n        \r\n    }\r\n\r\n\r\n\r\n    private void _yuanMove()\r\n    {\r\n\r\n        _angele += 0.1f;\r\n        _px = center.x + dis * (float)Math.Cos(_angele);\r\n\t\t_pz = center.z + dis * (float)Math.Sin(_angele);\r\n\t\t_py = 0f;\r\n\t\tball.localPosition = new Vector3(_px, _py, _pz);\r\n    }\r\n    private void _tuoYuanMove()\r\n    {\r\n\r\n        _angele += 0.1f;\r\n        _px = center.x + dis * (float)Math.Cos(_angele);\r\n        _pz = center.z + dis * 0.5f * (float)Math.Sin(_angele);\r\n        _py = 0f;\r\n        ball.localPosition = new Vector3(_px,_py, _pz);\r\n    }\r\n    private void _huanDongMove()\r\n    {\r\n        float dis = Vector3.Distance(ball.localPosition, target.localPosition);\r\n\r\n        float speed = dis * _ratio;\r\n\r\n        _px = ball.localPosition.x + speed;\r\n        _py = 0f;\r\n        _pz = 0f;\r\n        ball.localPosition = new Vector3(_px, _py, _pz);\r\n    }\r\n\r\n    private void _JianXieMove()\r\n    {\r\n        _angele += 0.1f;\r\n       \/\/ _px = center.x + dis * (float)Math.Cos(_angele);\r\n        _pz = center.z + dis * (float)Math.Sin(_angele);\r\n        _py = 0f;\r\n        _px = 0f;\r\n        ball.localPosition = new Vector3(_px, _py, _pz);\r\n    }\r\n    private void _ZhengCiBoMove()\r\n    {\r\n        _angele += 0.15f;\r\n        _px = ball.localPosition.x + _moveSpeed;\r\n        _pz = center.z + dis * (float)Math.Sin(_angele);\r\n        _py = 0f;\r\n        ball.localPosition = new Vector3(_px,_py, _pz);\r\n    }\r\n    private void _YuSuMove()\r\n    {\r\n        float dis = Vector3.Distance(ball.localPosition, target.localPosition);\r\n        if (dis &gt; 0.5f)\r\n        {\r\n            _px =ball.localPosition.x + _moveSpeed;\r\n            _py = 0f;\r\n            _pz = 0f;\r\n            ball.localPosition = new Vector3(_px, _py, _pz);\r\n        }\r\n    }\r\n    private void _JiaSuMove()\r\n    {\r\n       \r\n        float dis = Vector3.Distance(ball.localPosition, target.localPosition);\r\n        if (dis &gt; 0.5f)\r\n        {\r\n            _moveSpeed += _a;\r\n            _px = ball.localPosition.x + _moveSpeed;\r\n            _py = 0f;\r\n            _pz = 0f;\r\n            ball.localPosition = new Vector3(_px, _py, _pz);\r\n        }\r\n        else\r\n        {\r\n          \r\n        }\r\n\r\n    }\r\n    \r\n    private void _MoCaLiMove()\r\n    {\r\n        if (_moveSpeed &gt;= 0.001f)\r\n            _moveSpeed *= 0.92f;\r\n        else\r\n            _moveSpeed = 0f;\r\n        _px = ball.localPosition.x + _moveSpeed;\r\n        _py = 0f;\r\n        _pz = 0f;\r\n        ball.localPosition = new Vector3(_px, _py, _pz);\r\n    }\r\n    private void _tanXinMove()\r\n    {\r\n        float disx =  target.localPosition.x - ball.localPosition.x ;\r\n        float disz = target.localPosition.z - ball.localPosition.z;\r\n        _ax = disx * 0.1f;\r\n        _az = disz * 0.1f;\r\n        _moveSpeedx += _ax;\r\n        _moveSpeedz += _az;\r\n        _moveSpeedx *= 0.95f;\r\n        _moveSpeedz *= 0.95f;\r\n        _px = ball.localPosition.x + _moveSpeedx;\r\n        _py =0f; \r\n        _pz =ball.localPosition.z + _moveSpeedz;\r\n        ball.localPosition = new Vector3(_px, _py, _pz);\r\n        if (Math.Abs(_moveSpeedx) &lt;= 0.0001f &amp;&amp; Math.Abs(_moveSpeedz) &lt;= 0.0001f)\r\n        {\r\n            target.localPosition = new Vector3(UnityEngine.Random.Range(-18f, 18f), 0f,UnityEngine.Random.Range(-10f, 10f));\r\n        }\r\n    }\r\n\r\n\r\n    private void _toBounds()\r\n    {\r\n        if (ball.localPosition.x &gt; 25f)\r\n        {\r\n            ball.localPosition = new Vector3(-25f,ball.localPosition.y,ball.localPosition.z);\r\n        }\r\n       else if (ball.localPosition.x &lt; -25f)\r\n        {\r\n            ball.localPosition = new Vector3(25f, ball.localPosition.y, ball.localPosition.z);\r\n        }\r\n        if (ball.localPosition.z &gt;15f)\r\n        {\r\n            ball.localPosition = new Vector3(ball.localPosition.x, ball.localPosition.y,-15f);\r\n        }\r\n       else  if (ball.localPosition.z &lt;-15f)\r\n        {\r\n            ball.localPosition = new Vector3(ball.localPosition.x, ball.localPosition.y,15f);\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u6458\u81ea\u86ee\u725bhttp:\/\/www.manew.com\/thread-45376- &hellip; <a href=\"http:\/\/www.u3d8.com\/?p=530\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[23],"tags":[],"_links":{"self":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/530"}],"collection":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=530"}],"version-history":[{"count":7,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/530\/revisions"}],"predecessor-version":[{"id":721,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/530\/revisions\/721"}],"wp:attachment":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=530"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}