예제 #1
0
        void ConnectRoom(Vector2 source, Vector2 target)
        {
            //System.Random random = new System.Random();
            Vector2 delta    = target - source;
            float   angle    = Mathf.Atan((-delta.x) / delta.y) * 180 / Mathf.PI;
            float   distance = delta.magnitude;
            int     num      = (int)distance / 16;

            for (int i = 2; i < num - 1; i++)
            {
                GLoader loader = new GLoader();
                loader.width    = 16;
                loader.height   = 16;
                loader.color    = new Color32(80, 80, 80, 255);
                loader.url      = "ui://Map/dot1";
                loader.rotation = angle + UnityEngine.Random.Range(-10, 10);
                GLine.AddChild(loader);
                loader.xy  = new Vector2(source.x + (target.x - source.x) * i / num, source.y + (target.y - source.y) * i / num);
                loader.xy += new Vector2(UnityEngine.Random.Range(-5, 5), UnityEngine.Random.Range(-5, 5));
            }
        }