private void CreateRootHierarchy(string tableName = null)
        {
            // set the GameObject name; this needs to happen after MakeSerializable because the name is set there as well
            if (string.IsNullOrEmpty(tableName))
            {
                tableName = _sourceTable.Name;
            }
            else
            {
                tableName = tableName
                            .Replace("%TABLENAME%", _sourceTable.Name)
                            .Replace("%INFONAME%", _sourceContainer.InfoName);
            }

            _tableGo     = new GameObject(tableName);
            _playfieldGo = new GameObject("Playfield");
            var backglassGo = new GameObject("Backglass");
            var cabinetGo   = new GameObject("Cabinet");

            _tableComponent = _tableGo.AddComponent <TableComponent>();
            _tableComponent.SetData(_sourceTable.Data);

            _playfieldGo.transform.SetParent(_tableGo.transform, false);
            backglassGo.transform.SetParent(_tableGo.transform, false);
            cabinetGo.transform.SetParent(_tableGo.transform, false);

            _playfieldComponent = _playfieldGo.AddComponent <PlayfieldComponent>();
            _playfieldGo.AddComponent <PlayfieldColliderComponent>();
            _playfieldGo.AddComponent <PlayfieldMeshComponent>();
            _playfieldGo.AddComponent <MeshFilter>();
            _playfieldGo.transform.localRotation = PlayfieldComponent.GlobalRotation;
            _playfieldGo.transform.localPosition = new Vector3(-_sourceTable.Width / 2 * PlayfieldComponent.GlobalScale, 0f, _sourceTable.Height / 2 * PlayfieldComponent.GlobalScale);
            _playfieldGo.transform.localScale    = new Vector3(PlayfieldComponent.GlobalScale, PlayfieldComponent.GlobalScale, PlayfieldComponent.GlobalScale);
            _playfieldComponent.SetData(_sourceTable.Data);
        }
Ejemplo n.º 2
0
 public DragPointsInspectorHelper(IMainRenderableComponent mainComponent, IDragPointsInspector dragPointsInspector)
 {
     _mb                  = mainComponent as MonoBehaviour;
     _mainComponent       = mainComponent;
     _dragPointsInspector = dragPointsInspector;
     _playfieldComponent  = mainComponent.gameObject.GetComponentInParent <PlayfieldComponent>();;
     DragPointsHandler    = new DragPointsHandler(mainComponent, _dragPointsInspector);
 }
Ejemplo n.º 3
0
        protected virtual void OnEnable()
        {
            Undo.undoRedoPerformed += OnUndoRedoPerformed;

            TableComponent     = (target as MonoBehaviour)?.gameObject.GetComponentInParent <TableComponent>();
            PlayfieldComponent = (target as MonoBehaviour)?.gameObject.GetComponentInParent <PlayfieldComponent>();

            _isLockedProperty = serializedObject.FindProperty("_isLocked");
        }
 private void OnTableSelected(object sender, EventArgs e)
 {
     if (!_windowLocked && TableSelector.Instance.SelectedTable != null)
     {
         TableComponent     = TableSelector.Instance.SelectedTable;
         PlayfieldComponent = TableComponent.GetComponentInChildren <PlayfieldComponent>();
         SetTable(TableComponent);
         Repaint();
     }
 }
Ejemplo n.º 5
0
 public VpxPlayfieldPrefab(GameObject playfieldGo, Primitive item)
 {
     _primitive          = item;
     _playfieldComponent = playfieldGo.GetComponent <PlayfieldComponent>();
     GameObject          = playfieldGo;
 }