Пример #1
0
    private void Unpossessed(Player player)
    {
        ToolTipPlacement tooltipCanvas = player.GetComponentInChildren <ToolTipPlacement>();

        if (tooltipCanvas != null)
        {
            tooltipCanvas.SetText("");
        }
    }
Пример #2
0
    private ToolTipPlacement CheckMakeCanvas(Player player)
    {
        ToolTipPlacement tooltipCanvas = player?.GetComponentInChildren <ToolTipPlacement>();

        if (tooltipCanvas == null && player != null)
        {
            tooltipCanvas = Instantiate(canvasPrefab, player.transform).GetComponent <ToolTipPlacement>();
        }
        return(tooltipCanvas);
    }
Пример #3
0
    private void ShootAtGoal(object sender)
    {
        Player           player        = sender as Player;
        ToolTipPlacement tooltipCanvas = CheckMakeCanvas(player);

        if (!alreadySeen && player != null && player.team != null &&
            player.team.score <= scoreThreshold)
        {
            tooltipCanvas?.SetText("<AButton> Shoot at the goal");
        }
        else
        {
            tooltipCanvas?.SetText("");
        }
    }
Пример #4
0
    private void PassToTeammate(object sender)
    {
        Player           player        = sender as Player;
        ToolTipPlacement tooltipCanvas = CheckMakeCanvas(player);

        if (!alreadySeen && player != null && player.team != null &&
            player.team.score <= scoreThreshold)
        {
            tooltipCanvas?.SetText("<AButton> Pass to your teammate");
        }
        else
        {
            tooltipCanvas?.SetText("");
        }
    }
Пример #5
0
 public static void SetPlacementPriority(DependencyObject obj, ToolTipPlacement value)
 {
     obj.SetValue(PlacementPriorityProperty, value);
 }
        private void RefreshPosition()
        {
            double width  = RenderSize.Width;
            double height = RenderSize.Height;

            if (width == 0.0 || height == 0.0)
            {
                return;
            }
            double top  = 0.0;
            double left = 0.0;

            //TODO
            switch (PlacementPriority)
            {
            case ToolTipPlacement.Bottom:
                left = TargetRect.Left + TargetRect.Width / 2.0 - width / 2.0;
                if (left + width > ParentOverlay.ActualWidth)
                {
                    left = ParentOverlay.ActualWidth - width;
                }
                else if (left < 0.0)
                {
                    left = 0.0;
                }
                top = TargetRect.Top + TargetRect.Height;
                if (top + height > ParentOverlay.ActualHeight)
                {
                    top = TargetRect.Top - height;
                    CalculatedPlacement = ToolTipPlacement.Top;
                }
                else
                {
                    CalculatedPlacement = ToolTipPlacement.Bottom;
                }
                break;

            case ToolTipPlacement.Top:
                left = TargetRect.Left + TargetRect.Width / 2.0 - width / 2.0;
                if (left + width > ParentOverlay.ActualWidth)
                {
                    left = ParentOverlay.ActualWidth - width;
                }
                else if (left < 0.0)
                {
                    left = 0.0;
                }
                top = TargetRect.Top - height;
                if (top < 0.0)
                {
                    top = TargetRect.Top + TargetRect.Height;
                    CalculatedPlacement = ToolTipPlacement.Bottom;
                }
                else
                {
                    CalculatedPlacement = ToolTipPlacement.Top;
                }
                break;

            case ToolTipPlacement.Left:
                left = TargetRect.Left - width;
                if (left < 0.0)
                {
                    left = 0.0;
                    CalculatedPlacement = ToolTipPlacement.Right;
                }
                else
                {
                    CalculatedPlacement = ToolTipPlacement.Left;
                }
                top = TargetRect.Top + TargetRect.Height / 2.0 - height / 2.0;
                break;

            case ToolTipPlacement.Right:
                left = TargetRect.Left + TargetRect.Width;
                if (left + width > ParentOverlay.ActualWidth)
                {
                    left = TargetRect.Left - width;
                    CalculatedPlacement = ToolTipPlacement.Left;
                }
                else
                {
                    CalculatedPlacement = ToolTipPlacement.Right;
                }
                top = TargetRect.Top + TargetRect.Height / 2.0 - height / 2.0;
                break;

            default:
                break;
            }
            Canvas.SetLeft(this, left);
            Canvas.SetTop(this, top);
        }