Ejemplo n.º 1
0
    public void load(BinaryReader buf)
    {
        int stairIndex = buf.ReadInt32 ();
        int gizmoIndex = buf.ReadInt32 ();
        int gizmoCount = buf.ReadInt32 ();

        if (_controller != null)
        {
            _controller.SetStairIndex (stairIndex);
            _controller.SetGizmoIndex (gizmoIndex);

            Transform gizmo1 = _controller.transform.Find ("Gizmo1");

            if (/*_controller.GetGizmoList ().Count <= 0*/gizmo1 == null)
            {
                List<StairGizmo> gizmos = new List<StairGizmo> ();

                for (int gizIndex = 0; gizIndex < gizmoCount; ++gizIndex)
                {
                    Vector3 position = new Vector3 ((float)buf.ReadDouble (),
                                                    (float)buf.ReadDouble (),
                                                    (float)buf.ReadDouble ());

                    Quaternion rotation = new Quaternion ((float)buf.ReadDouble (),
                                                          (float)buf.ReadDouble (),
                                                          (float)buf.ReadDouble (),
                                                          (float)buf.ReadDouble ());

                    StairGizmo g = new StairGizmo ();
                    g.index = gizIndex;
                    g.position = position;
                    g.rotation = rotation;

                    gizmos.Add (g);

                    GameObject gizmoT = GameObject.CreatePrimitive (PrimitiveType.Cube);
                    Destroy (gizmoT.GetComponent<Collider>());
                    Destroy (gizmoT.GetComponent<Rigidbody>());

                    gizmoT.transform.parent = _controller.transform;
                    gizmoT.transform.localPosition = g.position;
                    gizmoT.transform.localRotation = g.rotation;

                    gizmoT.name = "Gizmo" + (gizIndex + 1).ToString ();
                    gizmoT.GetComponent<Renderer>().enabled = false;
                }
                _controller.SetGizmoList (gizmos);
            }

            _controller.Init ();
            if (stairIndex >= 0 && gizmoIndex >= 0)
            {
                StartCoroutine (_controller.SwapPool (gizmoIndex, stairIndex));
            }
        }
    }
Ejemplo n.º 2
0
    public void Init()
    {
        //check stair module
        ObjData objData = GetComponent<ObjData> ();
        if (objData != null)
        {
            //OSLibModules modules = objData.GetObjectModel ().GetModules ();
            _stairList = objData.GetObjectModel ().GetLibrary ().GetStairsList ()[0];

            if (_selectedStairIndex >= _stairList.GetStairList ().Count)
            {
                _selectedStairIndex = -1;
            }
            //OSLibModule stairModule = modules.FindModule ("stair");

            if (/*stairModule != null &&*/_gizmos.Count <= 0)
            {
                //find gizmos
                int gizmoIndex = 1;
                bool gizmoIsNotNull = true;

                do
                {
                    Transform gizmo = transform.Find ("Gizmo" + gizmoIndex.ToString ());
                    _transformGizmos.Add (gizmo);

                    if (gizmo != null)
                    {
                        StairGizmo g = new StairGizmo ();
                        g.index = gizmoIndex - 1;
                        g.position = gizmo.localPosition;
                        g.rotation = gizmo.localRotation;

                        _gizmos.Add (g);
                    }
                    else
                    {
                        gizmoIsNotNull = false;
                    }

                    ++gizmoIndex;
                }
                while (gizmoIsNotNull);
            }
        }
    }