示例#1
0
        protected override void OnIconClick(SwitchListData data, bool pressedDown)
        {
            var gle    = _tableComponent.GetComponent <IGamelogicEngine>();
            var player = _tableComponent.GetComponent <Player>();

            gle?.Switch(data.Id, pressedDown);
            if (player != null && player.SwitchStatuses.ContainsKey(data.Id))
            {
                player.SwitchStatuses[data.Id].IsSwitchClosed = pressedDown;
            }
        }
示例#2
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            if (Application.isPlaying)
            {
                var tableApi  = TableComponent.GetComponent <Player>().TableApi;
                var switchApi = tableApi.Switchable((MonoBehaviour) target);

                if (switchApi is CollisionSwitchApi {
                    IsHittable : true
                })
        protected override void OnIconClick(LampListData data, bool pressedDown)
        {
            var player = _tableComponent.GetComponent <Player>();

            if (player == null || data.Device == null || string.IsNullOrEmpty(data.DeviceItem))
            {
                return;
            }
            var lamp = player.Lamp(data.Device);

            lamp?.OnChange(pressedDown);
            if (player.LampStatuses.ContainsKey(data.Id))
            {
                player.LampStatuses[data.Id].IsOn = pressedDown;
            }
        }
        protected override void OnIconClick(CoilListData data, bool pressedDown)
        {
            var player = _tableComponent.GetComponent <Player>();

            if (player == null || data.Device == null || string.IsNullOrEmpty(data.DeviceItem))
            {
                return;
            }
            var coil = player.Coil(data.Device, data.DeviceItem);

            coil?.OnCoil(pressedDown);
            if (player.CoilStatuses.ContainsKey(data.Id))
            {
                player.CoilStatuses[data.Id] = pressedDown;
            }
        }
示例#5
0
        protected override void OnIconClick(WireListData data, bool pressedDown)
        {
            var player = _tableComponent.GetComponent <Player>();

            if (player == null || data.DestinationDevice == null || string.IsNullOrEmpty(data.DestinationDeviceItem))
            {
                return;
            }
            var wire = player.WireDevice(data.DestinationDevice);

            wire?.Wire(data.DestinationDeviceItem).OnChange(pressedDown);
            if (player.WireStatuses.ContainsKey(data.Id))
            {
                player.WireStatuses[data.Id] = (pressedDown, Time.realtimeSinceStartup);
            }
        }
        public override void OnInspectorGUI()
        {
            if (HasErrors())
            {
                return;
            }

            serializedObject.Update();

            DropDownProperty("Type", _typeProperty, TypeLabels, TypeValues);

            if (MainComponent.Type != TroughType.ClassicSingleBall)
            {
                PropertyField(_ballCountProperty);
            }

            switch (MainComponent.Type)
            {
            case TroughType.ModernOpto:
            case TroughType.ModernMech:
            case TroughType.TwoCoilsNSwitches:
                PropertyField(_switchCountProperty);
                PropertyField(_jamSwitchProperty, "Has Jam Switch");
                break;

            case TroughType.TwoCoilsOneSwitch:
                PropertyField(_switchCountProperty, "Switch Position");
                PropertyField(_jamSwitchProperty, "Has Jam Switch");
                break;
            }

            if (MainComponent.JamSwitch || MainComponent.Type != TroughType.ModernOpto && MainComponent.Type != TroughType.ModernMech && MainComponent.Type != TroughType.TwoCoilsNSwitches)
            {
                PropertyField(_kickTimeProperty, "Kick Time (ms)");
            }

            PropertyField(_rollTimeProperty, "Roll Time (ms)");
            if (MainComponent.Type == TroughType.ModernOpto)
            {
                PropertyField(_transitionTimeProperty, "Transition Time (ms)");
            }

            if (!Application.isPlaying)
            {
                if (_togglePlayfield = EditorGUILayout.BeginFoldoutHeaderGroup(_togglePlayfield, "Playfield Links"))
                {
                    EditorGUI.indentLevel++;
                    PropertyField(_playfieldEntrySwitchProperty, "Input Switch");
                    PropertyField(_playfieldExitKickerProperty, "Exit Kicker");
                    EditorGUI.indentLevel--;
                }
                EditorGUILayout.EndFoldoutHeaderGroup();
            }

            serializedObject.ApplyModifiedProperties();

            if (Application.isPlaying)
            {
                EditorGUILayout.Separator();

                GUILayout.BeginHorizontal();
                GUILayout.BeginVertical();

                EditorGUILayout.LabelField("Switch status:", new GUIStyle(GUI.skin.label)
                {
                    fontStyle = FontStyle.Bold
                });
                var troughApi = TableComponent.GetComponent <Player>().TableApi.Trough(MainComponent.name);

                if (MainComponent.Type != TroughType.ModernOpto && MainComponent.Type != TroughType.ModernMech)
                {
                    DrawSwitch("Drain Switch", troughApi.EntrySwitch);
                }

                if (MainComponent.Type == TroughType.TwoCoilsOneSwitch)
                {
                    DrawSwitch("Stack Switch", troughApi.StackSwitch());
                }
                else if (MainComponent.Type != TroughType.ClassicSingleBall)
                {
                    for (var i = troughApi.NumStackSwitches - 1; i >= 0; i--)
                    {
                        DrawSwitch(SwitchDescription(i), troughApi.StackSwitch(i));
                    }
                }

                if (MainComponent.JamSwitch)
                {
                    DrawSwitch("Jam Switch", troughApi.JamSwitch);
                }

                if (troughApi.UncountedDrainBalls > 0)
                {
                    EditorGUILayout.LabelField("Undrained balls:", troughApi.UncountedDrainBalls.ToString());
                }
                if (troughApi.UncountedStackBalls > 0)
                {
                    EditorGUILayout.LabelField("Unswitched balls:", troughApi.UncountedStackBalls.ToString());
                }

                GUILayout.EndVertical();
                GUILayout.BeginVertical();

                EditorGUILayout.LabelField("Coil status:", new GUIStyle(GUI.skin.label)
                {
                    fontStyle = FontStyle.Bold
                });

                if (MainComponent.Type != TroughType.ModernOpto && MainComponent.Type != TroughType.ModernMech && MainComponent.Type != TroughType.ClassicSingleBall)
                {
                    DrawCoil("Entry Coil", troughApi.EntryCoil);
                }

                DrawCoil("Eject Coil", troughApi.ExitCoil);

                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
            }
        }
示例#7
0
        public override void OnInspectorGUI()
        {
            BeginEditing();

            OnPreInspectorGUI();

            DropDownProperty("Banks", _bankSizeProperty, BankSizeLabels, BankSizeValues);

            while (_dropTargetsProperty.arraySize < _bankSizeProperty.intValue)
            {
                _dropTargetsProperty.InsertArrayElementAtIndex(_dropTargetsProperty.arraySize);
            }

            if (!Application.isPlaying)
            {
                if (_togglePlayfield = EditorGUILayout.BeginFoldoutHeaderGroup(_togglePlayfield, "Playfield Links"))
                {
                    EditorGUI.indentLevel++;

                    for (var index = 0; index < _bankSizeProperty.intValue; index++)
                    {
                        PropertyField(_dropTargetsProperty.GetArrayElementAtIndex(index), $"Drop Target {index + 1}");
                    }

                    EditorGUI.indentLevel--;
                }
                EditorGUILayout.EndFoldoutHeaderGroup();
            }

            base.OnInspectorGUI();

            EndEditing();

            if (Application.isPlaying)
            {
                EditorGUILayout.Separator();

                TableApi          tableApi          = TableComponent.GetComponent <Player>().TableApi;
                DropTargetBankApi dropTargetBankApi = tableApi.DropTargetBank(target.name);

                GUILayout.BeginVertical();

                if (_togglePlayfield = EditorGUILayout.BeginFoldoutHeaderGroup(_togglePlayfield, "Playfield Links"))
                {
                    EditorGUI.indentLevel++;

                    for (var index = 0; index < _bankSizeProperty.intValue; index++)
                    {
                        GUILayout.BeginHorizontal();

                        var dropTargetComponent = (DropTargetComponent)_dropTargetsProperty.GetArrayElementAtIndex(index).objectReferenceValue;

                        if (dropTargetComponent != null)
                        {
                            var dropTargetApi = tableApi.DropTarget(dropTargetComponent);

                            DrawSwitch($"Drop Target {index + 1} ({dropTargetComponent.name})", dropTargetApi.IsSwitchEnabled);

                            if (GUILayout.Button(dropTargetApi.IsDropped ? "Reset" : "Drop"))
                            {
                                dropTargetApi.IsDropped = !dropTargetApi.IsDropped;
                            }
                        }
                        else
                        {
                            GUILayout.Label($"Drop Target {index + 1}");

                            GUIStyle style = new GUIStyle(GUI.skin.label);
                            style.fontStyle = FontStyle.Italic;
                            style.alignment = TextAnchor.MiddleRight;

                            GUILayout.Label("Not configured", style);
                        }

                        GUILayout.EndHorizontal();
                    }

                    EditorGUI.indentLevel--;
                }

                EditorGUILayout.Separator();

                GUILayout.BeginHorizontal();

                if (GUILayout.Button("Drop All"))
                {
                    for (var index = 0; index < _bankSizeProperty.intValue; index++)
                    {
                        var dropTargetComponent = (DropTargetComponent)_dropTargetsProperty.GetArrayElementAtIndex(index).objectReferenceValue;

                        if (dropTargetComponent != null)
                        {
                            tableApi.DropTarget(dropTargetComponent).IsDropped = true;
                        }
                    }
                }

                if (GUILayout.Button("Reset All"))
                {
                    for (var index = 0; index < _bankSizeProperty.intValue; index++)
                    {
                        var dropTargetComponent = (DropTargetComponent)_dropTargetsProperty.GetArrayElementAtIndex(index).objectReferenceValue;

                        if (dropTargetComponent != null)
                        {
                            tableApi.DropTarget(dropTargetComponent).IsDropped = false;
                        }
                    }
                }

                GUILayout.EndHorizontal();

                EditorGUILayout.Separator();

                DrawCoil("Reset Coil", dropTargetBankApi.ResetCoil);
                DrawSwitch("Sequence Completed Switch", dropTargetBankApi.SequenceCompletedSwitch.IsSwitchEnabled);

                GUILayout.EndVertical();
            }
        }