/// <summary>
        /// </summary>
        private void CreateDeleteButton() => DeleteButton = new JukeboxButton(FontAwesome.Get(FontAwesomeIcon.fa_times),
                                                                              (sender, args) =>
        {
            if (SelectedLayerIndex.Value == 0)
            {
                NotificationManager.Show(NotificationLevel.Error, "You cannot delete the default layer!");
                return;
            }

            // Show them a confirmation dialog if objects are contained inside of the layer.
            if (Screen.WorkingMap.HitObjects.Any(x => x.EditorLayer == SelectedLayerIndex.Value))
            {
                DialogManager.Show(new EditorLayerDeleteConfirmationDialog(Screen.Ruleset as EditorRulesetKeys,
                                                                           ScrollContainer.AvailableItems[SelectedLayerIndex.Value]));

                return;
            }

            Screen.Ruleset.ActionManager.RemoveLayer(Screen.WorkingMap, this, ScrollContainer.AvailableItems[SelectedLayerIndex.Value]);
        })
        {
            Parent    = HeaderBackground,
            Alignment = Alignment.MidRight,
            Size      = new ScalableVector2(20, 20),
            Tint      = Color.Crimson,
            X         = -8
        };
Ejemplo n.º 2
0
        /// <summary>
        /// </summary>
        private void CreateReturnButton() => ReturnButton = new JukeboxButton(FontAwesome.Get(FontAwesomeIcon.fa_long_arrow_pointing_to_the_right),
                                                                              (sender, args) =>
        {
            if (string.IsNullOrWhiteSpace(NameTextbox.RawText))
            {
                NotificationManager.Show(NotificationLevel.Error, "Your layer name must not be empty ");
                return;
            }

            var selectedLayer = View.LayerCompositor.ScrollContainer.AvailableItems[View.LayerCompositor.SelectedLayerIndex.Value];
            var colorString   = $"{SelectedColor.Tint.R},{SelectedColor.Tint.G},{SelectedColor.Tint.B}";

            // Only change/add add an action if it was actually changed.
            if (NameTextbox.RawText != selectedLayer.Name || selectedLayer.ColorRgb != colorString && selectedLayer.ColorRgb != null)
            {
                Screen.Ruleset.ActionManager.EditLayer(View.LayerCompositor, selectedLayer, NameTextbox.RawText, colorString);
            }

            Screen.ActiveLayerInterface.Value = EditorLayerInterface.Composition;
        })
        {
            Parent    = HeaderBackground,
            Alignment = Alignment.MidRight,
            Size      = new ScalableVector2(20, 20),
            Tint      = Color.White,
            X         = -8
        };
 /// <summary>
 /// </summary>
 private void CreateAddButton() => AddButton = new JukeboxButton(FontAwesome.Get(FontAwesomeIcon.fa_plus_black_symbol),
                                                                 (sender, args) => Screen.Ruleset.ActionManager.AddLayer(Screen.WorkingMap, this,
                                                                                                                         new EditorLayerInfo
 {
     Name = $"Layer {ScrollContainer.AvailableItems.Count}"
 }))
 {
     Parent    = HeaderBackground,
     Alignment = Alignment.MidRight,
     Size      = new ScalableVector2(20, 20),
     Tint      = Color.LimeGreen,
     X         = DeleteButton.X - DeleteButton.Width - 10
 };
Ejemplo n.º 4
0
        /// <summary>
        /// </summary>
        private void CreateEditNamePencil() => EditLayerNameButton = new JukeboxButton(FontAwesome.Get(FontAwesomeIcon.fa_pencil),
                                                                                       (o, e) =>
        {
            if (Index == 0)
            {
                NotificationManager.Show(NotificationLevel.Error, "You cannot edit the default layer!");
                return;
            }

            LayerCompositor.SelectedLayerIndex.Value          = Index;
            LayerCompositor.Screen.ActiveLayerInterface.Value = EditorLayerInterface.Editing;
        })
        {
            Parent    = this,
            Alignment = Alignment.MidLeft,
            X         = VisibilityCheckbox.X + VisibilityCheckbox.Width + 10,
            Size      = VisibilityCheckbox.Size,
            Tint      = ColorHelper.ToXnaColor(Item.GetColor())
        };
Ejemplo n.º 5
0
        /// <summary>
        /// </summary>
        private void CreateClearButton() => ClearButton = new JukeboxButton(FontAwesome.Get(FontAwesomeIcon.fa_double_sided_eraser),
                                                                            (sender, args) =>
        {
            var ruleset = (EditorRulesetKeys)Screen.Ruleset;

            if (ruleset.SelectedHitObjects.Count == 0)
            {
                return;
            }

            ruleset.ActionManager.Perform(new EditorActionRemoveHitsoundKeys(ruleset,
                                                                             new List <DrawableEditorHitObject>(ruleset.SelectedHitObjects), 0));
        })
        {
            Parent    = HeaderBackground,
            Alignment = Alignment.MidRight,
            Size      = new ScalableVector2(20, 20),
            Tint      = ColorHelper.HexToColor("#dbb7bb"),
            X         = -8
        };
Ejemplo n.º 6
0
        /// <summary>
        /// </summary>
        private void CreateColorEditor()
        {
            TextColor = new SpriteTextBitmap(FontsBitmap.AllerRegular, "Layer Color")
            {
                Parent   = this,
                X        = TextLayerName.X,
                Y        = NameTextbox.Y + NameTextbox.Height + 20,
                FontSize = 16
            };

            SelectedColor = new Sprite
            {
                Parent = this,
                X      = TextLayerName.X,
                Y      = TextColor.Y + TextColor.Height + 10,
                Size   = new ScalableVector2(24, 24),
                Tint   = Color.White
            };

            ButtonSelectRandomColor = new JukeboxButton(FontAwesome.Get(FontAwesomeIcon.fa_refresh_page_option), (sender, args) =>
            {
                SelectedColor.Tint     = new Color(RNG.Next(255), RNG.Next(255), RNG.Next(255));
                TextSelectedColor.Text = $"(R:{SelectedColor.Tint.R}, G:{SelectedColor.Tint.G}, B:{SelectedColor.Tint.B})";
            })
            {
                Parent    = this,
                Size      = new ScalableVector2(18, 18),
                Alignment = Alignment.TopRight,
                Y         = SelectedColor.Y,
                X         = -10,
                Tint      = Color.White
            };

            TextSelectedColor = new SpriteTextBitmap(FontsBitmap.AllerRegular, $"(R:{SelectedColor.Tint.R}, G:{SelectedColor.Tint.G}, B:{SelectedColor.Tint.B})")
            {
                Parent    = SelectedColor,
                Alignment = Alignment.MidLeft,
                X         = SelectedColor.Width + 10,
                FontSize  = 16
            };
        }
Ejemplo n.º 7
0
    void Update()
    {
        // only check for pause stuff in levels
        if (isLevel)
        {
            // check whether player is currently pressing pause button
            if (OVRInput.Get(OVRInput.Button.Back))
            {
                // check to make sure pause button wasn't already being pressed (debouncing)
                if (!onPauseButton)
                {
                    // if game is already paused, resume game
                    if (isPaused)
                    {
                        resume();
                    }
                    // otherwise, pause game
                    else
                    {
                        pause();
                    }

                    onPauseButton = true;
                }
            }
            else
            {
                onPauseButton = false;
            }
        }

        // check if we're currently dispensing a tap
        if (tapDispensing)
        {
            // if tap is dispensing and player takes finger off trigger, stop dispensing
            if (!OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger))
            {
                tapTrigger.onUnclick();
                lineRenderer.enabled = true;
                tapDispensing        = false;
            }
            // otherwise, do nothing to let the tap keep dispensing
            else
            {
                return;
            }
        }

        Transform pointer = Pointer;

        if (pointer == null)
        {
            return;
        }

        // get ray pointing in direction of controller
        Ray laserPointer = new Ray(pointer.position, pointer.forward);

        // handles when object is currently being held
        if (objectPickedUp)
        {
            // drop object when user releases trigger
            if (!(OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger)))
            {
                dropObject();
                return;
            }

            // keep track of position for only last 10 frames
            if (recentPositions.Count >= 10)
            {
                recentPositions.Dequeue();
            }

            // if player's finger is on touchpad, adjust object depth accordingly
            if (OVRInput.Get(OVRInput.Touch.One))
            {
                // get current y position of finger on touchpad
                currTouch = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad).y;
                // if player's finger was already on touchpad, adjust object depth
                // based on the difference in y position of touch
                if (onTouchpad)
                {
                    objDistance += (currTouch - prevTouch) * depthMultiplier;
                }
                prevTouch  = currTouch;
                onTouchpad = true;
            }
            else
            {
                onTouchpad = false;
            }

            rb.MovePosition(laserPointer.origin + laserPointer.direction * objDistance);

            if (isCup)
            {
                rb.MoveRotation(Quaternion.Euler(-90, 90, 0));
            }
            else if (isBeerBottle)
            {
                rb.MoveRotation(Quaternion.identity);
            }
            else
            {
                rb.MoveRotation(pointer.rotation);
            }

            recentPositions.Enqueue(rb.position);

            return;
        }

        // render line to position of laser pointer
        if (lineRenderer != null)
        {
            lineRenderer.SetPosition(0, laserPointer.origin);
            lineRenderer.SetPosition(1, laserPointer.origin + laserPointer.direction * maxRayDistance);
        }

        isHovering = false;

        RaycastHit hit;

        if (Physics.Raycast(laserPointer, out hit, maxRayDistance, ~excludeLayers))
        {
            // render line onto hit object
            if (lineRenderer != null)
            {
                lineRenderer.SetPosition(1, hit.point);
            }

            // check if we hit a cup that we are able to pick up
            if (((hit.collider.tag == "isCupThreshold" && hit.collider.gameObject.GetComponent <CupManager>().canPickup()) ||
                 hit.collider.tag == "canPickUp") && !isPaused)
            {
                lineRenderer.material.color = Color.blue;

                // if we were holding down the trigger before hovering over object,
                // then we need to release the trigger before being able to pick it up
                if (!onPickupableObject)
                {
                    canPickupObject = !(OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger));
                }
                else if (!canPickupObject && !(OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger)))
                {
                    canPickupObject = true;
                }

                // indicate that we are hovering over object that we can pick up
                onPickupableObject = true;

                // if we can pick up this object and the trigger is down, pick up the object
                if (canPickupObject && OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger))
                {
                    pickupObject(hit.collider.gameObject);
                    objDistance = hit.distance;
                }
            }
            // check if we hit a menu item that dispenses objects
            else if (hit.collider.tag == "objectDispenser" && !isPaused)
            {
                lineRenderer.material.color = Color.green;
                isHovering = true;

                // if we were holding down the trigger before hovering over menu item,
                // then we need to release the trigger before being able to click it
                if (!onPickupableObject)
                {
                    canPickupObject = !(OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger));
                }
                else if (!canPickupObject && !(OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger)))
                {
                    canPickupObject = true;
                }

                // indicate that we are hovering over object that we can pick up
                onPickupableObject = true;

                // if we can click this menu item and the trigger is down, click it
                if (canPickupObject && OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger))
                {
                    GameObject     menuItem = hit.collider.gameObject;
                    OnSelectScript oss      = menuItem.GetComponent <OnSelectScript>();
                    pickupObject(oss.OnSelect());

                    // set "unhover" on menu item since we clicked
                    ohs.OnUnhover();
                }
            }
            // check if we hit one of the drop-down menu items
            else if (hit.collider.tag == "hoverable" && !isPaused)
            {
                // tell menu item to perform drop-down
                isHovering = true;
                GameObject menuItem = hit.collider.gameObject;
                ohs = menuItem.GetComponent <OnHoverScript>();
                ohs.OnHover();
            }
            // check if we hit a button
            else if (hit.collider.tag == "physicalButton" || hit.collider.tag == "ResumeCube")
            {
                lineRenderer.material.color = Color.green;

                // if we were holding down the trigger before hovering over button,
                // then we need to release the trigger before being able to click it
                if (!onPickupableObject)
                {
                    canPickupObject = !(OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger));
                }
                else if (!canPickupObject && !(OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger)))
                {
                    canPickupObject = true;
                }

                // indicate that we are hovering over button
                onPickupableObject = true;

                PhysicalButton btn = hit.collider.gameObject.GetComponent <PhysicalButton>();

                // if we can click this button and the trigger is down, click it
                // otherwise, call onHover()
                if (canPickupObject && OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger))
                {
                    btn.onClick();

                    // special case: button is resume button; we should also call resume() after clicking
                    if (hit.collider.tag == "ResumeCube" && isPaused)
                    {
                        resume();
                    }
                }
                else
                {
                    btn.onHover();
                }
            }
            else if (hit.collider.tag == "jukeboxButton" || hit.collider.tag == "jukebox")
            {
                lineRenderer.material.color = Color.green;

                if (hit.collider.tag == "jukebox" && jukebox == null)
                {
                    jukebox = hit.collider.gameObject;
                }

                jukebox.GetComponent <ToggleUi>().onHover();

                if (hit.collider.tag == "jukeboxButton")
                {
                    // if we were holding down the trigger before hovering over button,
                    // then we need to release the trigger before being able to click it
                    if (!onPickupableObject)
                    {
                        canPickupObject = !(OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger));
                    }
                    else if (!canPickupObject && !(OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger)))
                    {
                        canPickupObject = true;
                    }

                    // indicate that we are hovering over button
                    onPickupableObject = true;

                    JukeboxButton btn = hit.collider.gameObject.GetComponent <JukeboxButton>();

                    // if we can click this button and the trigger is down, click it
                    // otherwise, call onHover()
                    if (canPickupObject && OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger))
                    {
                        btn.onClick();

                        // special case: button is resume button; we should also call resume() after clicking
                        if (hit.collider.tag == "ResumeCube" && isPaused)
                        {
                            resume();
                        }
                    }
                    else
                    {
                        btn.onHover();
                    }
                }
            }
            else if (hit.collider.tag == "door" && !isPaused)
            {
                lineRenderer.material.color = Color.green;

                // if we were holding down the trigger before hovering over quit button,
                // then we need to release the trigger before being able to click it
                if (!onPickupableObject)
                {
                    canPickupObject = !(OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger));
                }
                else if (!canPickupObject && !(OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger)))
                {
                    canPickupObject = true;
                }

                // indicate that we are hovering over object that we can click
                onPickupableObject = true;

                FridgeDoorManager m = hit.collider.gameObject.GetComponent <FridgeDoorManager>();
                // if we can click this button and the trigger is down, click it
                if (canPickupObject && OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger))
                {
                    GameObject retval = m.onClick();
                    if (retval != null)
                    {
                        pickupObject(retval);
                        isBeerBottle = true;
                    }
                    canPickupObject = false;
                }
                // otherwise, call on hover
                else
                {
                    m.onHover();
                }
            }
            else if (hit.collider.tag == "tap" && !isPaused)
            {
                lineRenderer.material.color = Color.green;

                // if we were holding down the trigger before hovering over quit button,
                // then we need to release the trigger before being able to click it
                if (!onPickupableObject)
                {
                    canPickupObject = !(OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger));
                }
                else if (!canPickupObject && !(OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger)))
                {
                    canPickupObject = true;
                }

                // indicate that we are hovering over object that we can click
                onPickupableObject = true;

                tapTrigger = hit.collider.gameObject.GetComponent <TapTrigger>();
                // if we can click this button and the trigger is down, click it
                if (canPickupObject && OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger))
                {
                    tapTrigger.onClick();
                    canPickupObject      = false;
                    tapDispensing        = true;
                    lineRenderer.enabled = false;
                }
                // otherwise, call on hover
                else
                {
                    tapTrigger.onHover();
                }
            }
            // otherwise, reset pointer color and indicate that we can't
            // currently pick up an object
            else
            {
                lineRenderer.material.color = Color.red;
                onPickupableObject          = false;
            }
        }

        if (wasHovering && !isHovering)
        {
            ohs.OnUnhover();
        }

        wasHovering = isHovering;
    }