Esempio n. 1
0
        // draw the point,besides,show/hide the rotation object
        void    DrawPoint(int x, int y)
        {
            var pname = DemoMenuItems.PointName(x, y);

            // inspector
            DrawPointInspector(x, y, pname);
        }
Esempio n. 2
0
        private GameObject CreateElement(Data.IndexData lh, Texture t, Color c)
        {
            GameObject go = Instantiate(DicePrefab) as GameObject;

            go.transform.parent = this.transform;
            go.name             = lh.walli + "." + lh.xi + "." + lh.yi;
            var tg = go.GetComponent <CustomTarget>();

            tg.DeepColor   = c;
            tg.DiceTexture = t;
            var     point = currentData.walls[lh.walli].schema[lh.xi, lh.yi];
            Vector3 pos   = DemoMenuItems.PointPosition(lh.walli, lh.xi, lh.yi);

            go.transform.localPosition = pos;
            switch (point.easy)
            {
            case PointEasyOrHard.eFix:
                break;

            case PointEasyOrHard.eShowLess:
            {
                var poff = DemoMenuItems.PositionAwayCenter(lh.walli);
                poff *= Random.Range(0.01f, 0.30f);
                go.transform.localPosition += poff;
            }
            break;

            case PointEasyOrHard.eShowMore:
            {
                var poff = DemoMenuItems.PositionAwayCenter(lh.walli);
                poff *= Random.Range(0.01f, 0.30f);
                go.transform.localPosition -= poff;
            }
            break;
            }
            switch (point.distort)
            {
            case PointDistort.eFaceCamera:
            {
                go.transform.LookAt(Vector3.zero);
            }
            break;

            case PointDistort.eRandom:
            {
                Quaternion qt = Quaternion.Euler(Random.Range(0, 360)
                                                 , Random.Range(0, 360), Random.Range(0, 360));
                go.transform.localRotation = qt;
            }
            break;

            case PointDistort.eFix:
                break;
            }
            return(go);
        }
Esempio n. 3
0
        // retrieve data from transform.
        void RetrievePointData(int x, int y)
        {
            string pointname = DemoMenuItems.PointName(x, y);

            if (findwall.transform.FindChild(pointname))
            {
                findwall.walldata.points[x, y] = true;
            }
            else
            {
                findwall.walldata.points[x, y] = false;
            }
        }
Esempio n. 4
0
        private bool LoadPointFromProfile(FWallView wall, int idx, int x, int y)
        {
            var fn     = DemoMenuItems.PointName(x, y);
            var pt     = wall.transform.FindChild(fn);
            var schema = currentData.walls[idx].schema[x, y];

            if (!pt)
            {
                schema.state = Data.DataPointState.eNone;
                return(false);
            }
            var pi = pt.gameObject.GetComponent <FPointView>();

            schema.state   = Data.DataPointState.eProfiled;
            schema.distort = pi.ViewTrans;
            schema.easy    = pi.ViewParts;
            return(true);
        }
Esempio n. 5
0
        private void LoadWallFromProfile(FWallView wall)
        {
            var fn  = wall.gameObject.name;
            int idx = DemoMenuItems.FaceName2Index(fn);

            currentData.walls[idx].Capacity = wall.capacity;
            // we will fill count latter
            currentData.walls[idx].Count = 0;
            for (int x = 0; x < DemoMenuItems.TILE_WIDTH; ++x)
            {
                for (int y = 0; y < DemoMenuItems.TILE_HEIGHT; ++y)
                {
                    currentData.walls[idx].schema[x, y] = new Data.DataPoint();
                    if (LoadPointFromProfile(wall, idx, x, y))
                    {
                        ++currentData.walls[idx].Count;
                    }
                }
            }
        }
Esempio n. 6
0
        void    DrawPointInspector(int x, int y, string pointname)
        {
            float  left     = rectSize * x;
            float  top      = rectSize * y;
            Color  guicolor = GUI.color;
            string info     = "";

            if (findwall.walldata.points[x, y])
            {
                info = "V";
            }
            else
            {
                var c = GUI.color;
                c.a       = 0;
                GUI.color = c;
            }

            if (GUI.Button(new Rect(guiCurrentRect.xMin + left + 1
                                    , guiCurrentRect.yMin + top + 1
                                    , rectSize - 2, rectSize - 2)
                           , info))
            {
                var pname = DemoMenuItems.PointName(x, y);
                var t     = findwall.transform.FindChild(pname);
                if (t)
                {
                    Undo.DestroyObjectImmediate(t.gameObject);
                }
                else
                {
                    // process add new point
                    var g = DemoMenuItems.CreatePointObject(x, y
                                                            , findwall.gameObject);
                    Undo.RegisterCreatedObjectUndo(g, "new point");
                }
            }
            GUI.color = guicolor;
        }