private void NotifyIcon_OnLoaded(object sender, RoutedEventArgs e) { if (!isLoaded) { TrayIcon = DataContext as ManagedShell.WindowsTray.NotifyIcon; if (TrayIcon == null) { return; } applyEffects(); TrayIcon.NotificationBalloonShown += TrayIcon_NotificationBalloonShown; // If a notification was received before we started listening, it will be here. Show the first one that is not expired. NotificationBalloon firstUnexpiredNotification = TrayIcon.MissedNotifications.FirstOrDefault(balloon => balloon.Received.AddMilliseconds(balloon.Timeout) > DateTime.Now); if (firstUnexpiredNotification != null && Host != null && Host.Screen.Primary) { BalloonControl.Show(firstUnexpiredNotification, NotifyIconBorder); TrayIcon.MissedNotifications.Remove(firstUnexpiredNotification); } isLoaded = true; } }
/// <summary>显示说明文字</summary> public void showText(string text, Vector2 center, float marginX, float marginY, float radius) { // 先隐藏 this.hide(); this.balloon_control = this.create_balloon(); this.balloon_control.setText(text, TEXT_BACK_COLOR, new Vector2(0.0f, -200.0f)); this.balloon_control.show(); }
private void TrayIcon_NotificationBalloonShown(object sender, NotificationBalloonEventArgs e) { if (Host == null || !Host.Screen.Primary) { return; } BalloonControl.Show(e.Balloon, NotifyIconBorder); e.Handled = true; }
void Start() { gamePaused = true; BalloonScript = Balloon.GetComponent <BalloonControl> (); MovingObjects = new GameObject[movingObjectsNames.Length][]; for (int i = 0; i < movingObjectsNames.Length; i++) { MovingObjects[i] = GameObject.FindGameObjectsWithTag(movingObjectsNames[i]); } }
/// <summary>显示对话文字</summary> public void showDialog(BaseObject baseObject, string text, float marginX, float marginY, float radius) { // 先隐藏 this.hide(); this.balloon_control = this.create_balloon(); this.balloon_control.setText(text, baseObject.getDialogBackgroundColor(), Vector2.zero); Rect canvas_rect = this.GetComponent <RectTransform>().rect; float screen_right = canvas_rect.xMax; float screen_left = canvas_rect.xMin; float screen_top = canvas_rect.yMax; Rect balloon_rect = this.balloon_control.underlay.getRect(); float balloon_width = balloon_rect.width; float balloon_height = balloon_rect.height; Vector3 bo_pos = baseObject.gameObject.transform.position; // 获取GameObject 位于屏幕上的坐标 Vector3 screenPointTop = Camera.main.WorldToScreenPoint(bo_pos + new Vector3(0.0f, baseObject.getYTop(), 0.0f)); Vector3 screenPointBottom = Camera.main.WorldToScreenPoint(bo_pos + new Vector3(0.0f, baseObject.getYBottom(), 0.0f)); screenPointTop.x -= 320.0f; screenPointTop.y -= 240.0f; screenPointBottom.x -= 320.0f; screenPointBottom.y -= 240.0f; float balloon_x = screenPointTop.x + 0.2f * balloon_width; // ちょっとだけ右にずらすと吹き出しっぽくなる. float knob_x = screenPointTop.x; // -------------------------------------------------------- // // 检测是否超出画面左右两侧 if (balloon_x - balloon_width / 2.0f < screen_left + SCREEN_MARGIN_OF_BALLOON) { // 如果向左突出 balloon_x = screen_left + SCREEN_MARGIN_OF_BALLOON + balloon_width / 2.0f; } else if (balloon_x + balloon_width / 2.0f > screen_right - SCREEN_MARGIN_OF_BALLOON) { // 如果向右突出 balloon_x = screen_right - SCREEN_MARGIN_OF_BALLOON - balloon_width / 2.0f; } // -------------------------------------------------------- // // 检测是否超出画面上下范围 // 选择在头上或脚底显示(原则是头上显示) bool knob_below = true; float balloon_y = screenPointTop.y + BALLOON_OBJECT_SPACE + UIUnderlay.KNOB_SIZE + balloon_height / 2.0f; if (balloon_y + balloon_height / 2.0f > screen_top + SCREEN_MARGIN_OF_BALLOON) { // 如果对话框向上突出则显示在脚下 balloon_y = screenPointBottom.y - (BALLOON_OBJECT_SPACE + UIUnderlay.KNOB_SIZE + balloon_height / 2.0f); knob_below = false; } // -------------------------------------------------------- // this.balloon_control.setPosition(new Vector2(balloon_x, balloon_y)); this.balloon_control.drawKnob(knob_below, knob_x - balloon_x, baseObject.getDialogBackgroundColor()); this.balloon_control.show(); // 显示对话文字时发出音效 dialog_sound_source.Play(); }
/// <summary>会話文を表示する</summary> public void showDialog(BaseObject baseObject, string text, float marginX, float marginY, float radius) { // いったん隠す. this.hide(); this.balloon_control = this.create_balloon(); this.balloon_control.setText(text, baseObject.getDialogBackgroundColor(), Vector2.zero); Rect canvas_rect = this.GetComponent <RectTransform>().rect; float screen_right = canvas_rect.xMax; float screen_left = canvas_rect.xMin; float screen_top = canvas_rect.yMax; Rect balloon_rect = this.balloon_control.underlay.getRect(); float balloon_width = balloon_rect.width; float balloon_height = balloon_rect.height; Vector3 bo_pos = baseObject.gameObject.transform.position; // GameObject のスクリーン座標を取得する. Vector3 screenPointTop = Camera.main.WorldToScreenPoint(bo_pos + new Vector3(0.0f, baseObject.getYTop(), 0.0f)); Vector3 screenPointBottom = Camera.main.WorldToScreenPoint(bo_pos + new Vector3(0.0f, baseObject.getYBottom(), 0.0f)); screenPointTop.x -= 320.0f; screenPointTop.y -= 240.0f; screenPointBottom.x -= 320.0f; screenPointBottom.y -= 240.0f; float balloon_x = screenPointTop.x + 0.2f * balloon_width; // ちょっとだけ右にずらすと吹き出しっぽくなる. float knob_x = screenPointTop.x; // -------------------------------------------------------- // // 画面の左右からのはみ出しをチェック. if (balloon_x - balloon_width / 2.0f < screen_left + SCREEN_MARGIN_OF_BALLOON) { // 吹き出しが左に突き出してしまう. balloon_x = screen_left + SCREEN_MARGIN_OF_BALLOON + balloon_width / 2.0f; } else if (balloon_x + balloon_width / 2.0f > screen_right - SCREEN_MARGIN_OF_BALLOON) { // 吹き出しが右に突き出してしまう. balloon_x = screen_right - SCREEN_MARGIN_OF_BALLOON - balloon_width / 2.0f; } // -------------------------------------------------------- // // 画面の上下からのはみ出しをチェック. // キャラの上に出すか、下に出すかを選ぶ(原則頭上). bool knob_below = true; float balloon_y = screenPointTop.y + BALLOON_OBJECT_SPACE + UIUnderlay.KNOB_SIZE + balloon_height / 2.0f; if (balloon_y + balloon_height / 2.0f > screen_top + SCREEN_MARGIN_OF_BALLOON) { // 吹き出しが上に突き出してしまう場合は足下. balloon_y = screenPointBottom.y - (BALLOON_OBJECT_SPACE + UIUnderlay.KNOB_SIZE + balloon_height / 2.0f); // ベロは上. knob_below = false; } // -------------------------------------------------------- // this.balloon_control.setPosition(new Vector2(balloon_x, balloon_y)); this.balloon_control.drawKnob(knob_below, knob_x - balloon_x, baseObject.getDialogBackgroundColor()); this.balloon_control.show(); // 会話文表示のときはサウンドを鳴らす. dialog_sound_source.Play(); }
private BalloonControl BalloonControlScript; // reference to the BalloonControl script - contains all important data about balloon // Use this for initialization void Start() { BalloonControlScript = GetComponent <BalloonControl>(); }
// Use this for initialization void Start() { BalloonControlScript = GetComponent <BalloonControl>(); scoreDistribution = GetComponent <AngleControl>().distributionCurve; }