Exemple #1
0
        private void OnShrink(object sender, RoutedEventArgs e)
        {
            var widthAnimation = new DoubleAnimation {
                Duration = TimeSpan.FromSeconds(5)
            };
            var heightAnimation = new DoubleAnimation {
                Duration = TimeSpan.FromSeconds(5)
            };

            GrowButton.BeginAnimation(WidthProperty, widthAnimation);
            GrowButton.BeginAnimation(HeightProperty, heightAnimation);
        }
Exemple #2
0
        private void OnGrow(object sender, RoutedEventArgs e)
        {
            var widthAnimation = new DoubleAnimation
            {
                To       = Width - 30,
                Duration = TimeSpan.FromSeconds(5)
            };

            widthAnimation.Completed += OnAnimationCompleted;

            var heightAnimation = new DoubleAnimation
            {
                To       = (Height - 50) / 3,
                Duration = TimeSpan.FromSeconds(5)
            };

            GrowButton.BeginAnimation(WidthProperty, widthAnimation);
            GrowButton.BeginAnimation(HeightProperty, heightAnimation);
        }
Exemple #3
0
    /// <summary>
    /// Handle selecting buttons.
    /// </summary>
    private void HandlePressingButtons()
    {
        // Look at a button
        RaycastHit hitInfo;

        if (Physics.Raycast(PlayerCamera.transform.position, PlayerCamera.transform.forward, out hitInfo, PickupItemDistance * Scale, LayerMask.GetMask("GrowButton", "HeldItem")))
        {
            GrowButton lookedAtItem = hitInfo.transform.GetComponent <GrowButton>();

            if (lookedAtItem != null)
            {
                GrabFailReason reason = GrabFailReason.Range;
                if (CanSelectItemBasedOnScale(lookedAtItem, out reason))
                {
                    // If a valid item is looked at, you can pick it up with a button.
                    if (Input.GetButtonDown("Grab") && !m_grabbedThisFrame)
                    {
                        m_grabbedThisFrame = true;
                        PressButton(lookedAtItem);
                    }

                    lookedAtItem.SetSelectionVisual(true);
                }
                else
                {
                    // If an invalid item is looked at, do the animation
                    if (Input.GetButtonDown("Grab") && !m_grabbedThisFrame)
                    {
                        m_grabbedThisFrame = true;
                        GameManager.Instance.GameCanvas.PlayGrabFailAnimation(reason);
                    }

                    lookedAtItem.SetSelectionVisual(false);
                }
            }
            else if (lookedAtItem != null)
            {
            }
        }
    }