public void addVoiceBubble(BubbleSide bubbleSide, string recordPath, string sender, string senderID, string profileImgPath) { IVoiceBubble voiceBubble = null; if (bubbleSide == BubbleSide.LEFT) { voiceBubble = new LeftVoiceBubble(); (voiceBubble as LeftVoiceBubble).profileRightClicked += ChatBox_profileRightClicked; } else if (bubbleSide == BubbleSide.RIGHT) { voiceBubble = new RightVoiceBubble(); (voiceBubble as RightVoiceBubble).profileRightClicked += ChatBox_profileRightClicked; } if (chatPanel.Controls.Count != 0) { (voiceBubble as Control).Top = chatPanel.Controls[chatPanel.Controls.Count - 1].Top + chatPanel.Controls[chatPanel.Controls.Count - 1].Height; } chatPanel.Controls.Add(voiceBubble as Control); voiceBubble.setRecord(recordPath, sender, senderID, profileImgPath); chatPanel.ScrollControlIntoView(voiceBubble as Control); }
void SetSide(string input) { BubbleSide side = input == "left" ? BubbleSide.Left : BubbleSide.Right; float radius = 60f; SetSide(side, radius); }
public void addImgBubble(BubbleSide bubbleSide, string imgPath, string sender, string senderID, string profileImgPath) { IImgBubble imgBubble = null; if (bubbleSide == BubbleSide.LEFT) { imgBubble = new LeftImgBubble(); (imgBubble as LeftImgBubble).profileRightClicked += ChatBox_profileRightClicked; } else if (bubbleSide == BubbleSide.RIGHT) { imgBubble = new RightImgBubble(); (imgBubble as RightImgBubble).profileRightClicked += ChatBox_profileRightClicked; } if (chatPanel.Controls.Count != 0) { (imgBubble as Control).Top = chatPanel.Controls[chatPanel.Controls.Count - 1].Top + chatPanel.Controls[chatPanel.Controls.Count - 1].Height; } chatPanel.Controls.Add(imgBubble as Control); imgBubble.setImg(imgPath, sender, senderID, profileImgPath); chatPanel.ScrollControlIntoView(imgBubble as Control); }
public void SetSpeechThingPositionAndSide(string side, DynValue position) { CheckExists(); bubbleLastVar = position; try { bubbleSide = side != null ? (BubbleSide)Enum.Parse(typeof(BubbleSide), side.ToUpper()) : BubbleSide.NONE; } catch { throw new CYFException("The speech thing (tail) can only take \"RIGHT\", \"DOWN\" ,\"LEFT\" ,\"UP\" or \"NONE\" as a positional value, but you entered \"" + side.ToUpper() + "\"."); } if (bubbleSide != BubbleSide.NONE) { speechThing.gameObject.SetActive(true); speechThingShadow.gameObject.SetActive(true); speechThing.anchorMin = speechThing.anchorMax = speechThingShadow.anchorMin = speechThingShadow.anchorMax = new Vector2(bubbleSide == BubbleSide.LEFT ? 0 : bubbleSide == BubbleSide.RIGHT ? 1 : 0.5f, bubbleSide == BubbleSide.DOWN ? 0 : bubbleSide == BubbleSide.UP ? 1 : 0.5f); speechThing.rotation = speechThingShadow.rotation = Quaternion.Euler(0, 0, (int)bubbleSide); bool isSide = bubbleSide == BubbleSide.LEFT || bubbleSide == BubbleSide.RIGHT; int size = isSide ? (int)containerBubble.GetComponent <RectTransform>().sizeDelta.y - 20 : (int)containerBubble.GetComponent <RectTransform>().sizeDelta.x - 20; if (position == null) { speechThing.anchoredPosition = speechThingShadow.anchoredPosition = new Vector3(0, 0); } else { switch (position.Type) { case DataType.Number: { float number = (float)position.Number < 0 ? (float)position.Number : (float)position.Number - size / 2f; speechThing.anchoredPosition = speechThingShadow.anchoredPosition = new Vector3(isSide ? 0 : Mathf.Clamp(number, -size / 2f, size / 2f), !isSide ? 0 : Mathf.Clamp(number, -size / 2f, size / 2f)); break; } case DataType.String: { string str = position.String.Replace(" ", ""); if (str.Contains("%")) { try { float percentage = Mathf.Clamp01(ParseUtil.GetFloat(str.Replace("%", "")) / 100), x = isSide ? 0 : Mathf.Round(percentage * size) - size / 2f, y = !isSide ? 0 : Mathf.Round(percentage * size) - size / 2f; speechThing.anchoredPosition = speechThingShadow.anchoredPosition = new Vector3(x, y); } catch { throw new CYFException("If you use a '%' in your string, you should only have a number with it."); } } else { throw new CYFException("You need to use a '%' in order to exploit the string."); } break; } } } } else { speechThing.gameObject.SetActive(false); speechThingShadow.gameObject.SetActive(false); } }
public void DetachBubble(BubbleSide side) { if (side == BubbleSide.None) { return; } linked[(int)side] = null; }
public void LinkBubble(BubbleSide side, Bubble bubble) { if (side == BubbleSide.None || !bubble) { return; } linked[(int)side] = bubble; }
void SetSide(BubbleSide side, float radius) { Vector4 radiusRect = new Vector4(radius, radius, radius, radius); switch (side) { case BubbleSide.Right: radiusRect.y = 0.0f; break; default: radiusRect.x = 0.0f; break; } textBubbleShadow.GetComponent <FreeModifier>().Radius = radiusRect; textBubble.GetComponent <FreeModifier>().Radius = radiusRect; if (side == BubbleSide.Right) { transform.GetChild(0).SetAsLastSibling(); } }
public Bubble GetLinked(BubbleSide side) { return(side == BubbleSide.None ? null : linked[(int)side]); }