public void Set(ARLoader loader) { loader.TextTop.text = Message.Replace("~", "\n"); loader.TextTop.FontSizeVW = MessageFontSizeVW; loader.TextBottom.text = Note.Replace("~", "\n"); loader.TextBottom.FontSizeVW = NoteFontSizeVW; loader.Icon.sprite = Icon; ClickBox cb = loader.GetComponent <ClickBox>(); if (cb != null) { if (BackButton) { cb.OnClick = () => { loader.ARScene.App.MoveToCollections(); }; } else { cb.OnClick = null; } } }
//返回是否是 combobox public bool Click() { if (BattleManager.Instance.isBattle == false) { return(false); } ClickBox topbox = null; //是否触碰到box if (touchBox.Count > 0) { //获得最上面的box for (int i = 0; i < touchBox.Count; i++) { if (topbox != null) { if (touchBox[i] != null) { ClickBox curbox = touchBox[i].GetComponent <ClickBox>(); if (topbox.sprite.depth < curbox.sprite.depth) { topbox = curbox; } } } else { if (touchBox[i] != null) { topbox = touchBox[i].GetComponent <ClickBox>(); } if (topbox == null && touchBox[i].gameObject != null && touchBox[i].gameObject.transform.parent.gameObject != null) { topbox = touchBox[i].gameObject.transform.parent.gameObject.GetComponent <ClickBox>(); } } } //处理click事件 if (topbox != null && topbox.type != ClickBox.BoxType.ComboBox) { touchBox.Remove(topbox.gameObject); topbox.Click(topbox.type); } else if (topbox != null && topbox.type == ClickBox.BoxType.ComboBox) { dragBox = topbox.GetComponent <DragBox>(); return(true); } else //有时候touchbox 没清干净 { BattleManager.Instance.ClickBoxOver(ClickBox.BoxType.None); } } else //什么都没点到 { BattleManager.Instance.ClickBoxOver(ClickBox.BoxType.None); } return(false); }
private void Render() { var click = ClickBox.RenderClickBox(gameObject); horizontal.CalculateLayoutInputHorizontal(); horizontal.CalculateLayoutInputVertical(); horizontal.SetLayoutHorizontal(); horizontal.SetLayoutVertical(); renderedClicks.Add(click); }
private void AddDestoryList(List <GameObject> list) { for (int i = 0; i < list.Count; i++) { if (list[i] != null && box.bounds.Intersects(list[i].GetComponent <Collider2D>().bounds) && list[i].tag != Def.DragBox) { ClickBox b = list[i].GetComponent <ClickBox>(); if (b.type != ClickBox.BoxType.BombBox) { _destoryList.Add(b); } } } }
public void AddModel(ModelTexture modeltexture, string title) { GameObject textGO = MakeText(title); ClickBox clickBox = textGO.GetComponent <ClickBox>(); clickBox.AddEventListener("onclick", () => { if (OnSelect != null) { OnSelect(modeltexture); } }); Grid.AddElement(textGO); Grid.AddElement(Instantiate(HLine)); }
void Awake() { if (App != null) { App.AddEventListener("beforeshow", UpdateToggle); } ClickBox cb = GetComponent <ClickBox>(); if (cb != null) { cb.OnClick = App.MoveToARView; } UpdateToggle(); }
//[HideInInspector] //public int saveStage; // Use this for initialization void Start() { //problemcacnvas = GameObject.Find("level1s3/Canvas"); mainCamera = GameObject.FindGameObjectWithTag("MainCamera"); observeCamera = GameObject.FindGameObjectWithTag("ObserveCamera"); S3Camera = GameObject.FindGameObjectWithTag("MainCamera1"); diaryCamera = GameObject.Find("level1s3/observeDiaryCamera"); codeboxCanvas = GameObject.Find("CodeBox/Canvas").GetComponent <Canvas>(); trigger1 = GameObject.FindGameObjectWithTag("TriggerArea1"); //problemcacnvas.SetActive(false); codebox = GameObject.Find("CodeBox/Canvas").GetComponent <ClickBox>(); observeCamera.GetComponent <AudioListener>().enabled = false; observeCamera.GetComponent <Camera>().enabled = false; S3Camera.GetComponent <AudioListener>().enabled = false; S3Camera.GetComponent <Camera>().enabled = false; fps2.SetActive(false); }
//compares the input with what we have public void receiveClickFrom(ClickBox b) { if (!isActive) { return; } //add onen to index since its starting from 1 -> 12 if (b.letter == (currentBoxIndex + 1).ToString()) { AudioManager.instance.PlaySFX("Correct"); //inputted correct letter Highlight(boxArray[currentBoxIndex], Color.green); boxArray[currentBoxIndex].finished = true; //force it to stay green! boxArray[currentBoxIndex].isSelected(false); if (currentBoxIndex < 11 && boxArray[currentBoxIndex + 1]) { boxArray[currentBoxIndex + 1].isSelected(true); } //draw a line if (currentBoxIndex > 0 && currentBoxIndex < activeBoxes) { DrawLine(boxObjArray[currentBoxIndex - 1].transform.localPosition, boxObjArray[currentBoxIndex].transform.localPosition); } AudioManager.instance.PlaySFX("ConnectCircuit"); currentBoxIndex++; CheckGameIsDone(); } else { //failed input Flash(b, Color.red); AudioManager.instance.PlaySFX("Error"); } }
void GenerateSchedule() { int x = 0; // start at X-Axis int y = 14; // start at Y-Axis int n = 0; // box number bool bHeader = false; try { for (int d = 1; d <= 7; d++) { for (int h = 0; h <= 23; h++) { if (!bHeader) { var l = new Label(); l.Location = new Point(x + 1, 0); l.Margin = new Padding(0); l.Name = "lbl" + n; l.Text = n.ToString("D2"); // add leading zero when needed (2 digits) l.Size = new Size(20, 13); l.TextAlign = ContentAlignment.MiddleCenter; this.Invoke(new Action(() => this.BoxPanel.Controls.Add(l))); } ScheduleBox[n] = new ClickBox("box" + n, x, y); this.Invoke(new Action(() => this.BoxPanel.Controls.Add(ScheduleBox[n].box))); n++; x += 20; // X-Axis } bHeader = true; y += 20; // Y-Axis x = 0; // X-Axis } } catch (Exception ex) { DebugHelper.Exception(ex); } isDone = true; }
public void AddIcon(string text, List <Variant> products) { GameObject IconGO = Instantiate(ListIconPrefab); Text textComp = IconGO.GetComponent <Text>(); if (textComp != null) { textComp.text = text; } ClickBox cb = IconGO.GetComponent <ClickBox>(); if (cb != null) { cb.OnClick = () => { App.MoveToProducts(text, products); }; } GridElement.AddElement(IconGO); }
public Vector2 SetBoxSize() { Vector2 size = new Vector2(-1, -1); if (Text == null) { return(size); } //Get text bounding box and text rect transform RectTransform rect = Text.gameObject.GetComponent <RectTransform>(); if (rect == null) { return(size); } size = TextBBox; //Set text title, font size a rect size Text.text = Title; Text.fontSize = fontSize_px; Text.font = Font; rect.sizeDelta = size; if (ButtonBackground == null) { return(size); } if (clickBox == null) { clickBox = ButtonBackground.gameObject.GetComponent <ClickBox>(); if (clickBox != null) { clickBox.AddEventListener("onclick", () => { RunEvent("onclick"); }); } } size += 2 * buttonPadding_px; ButtonBackground.sizeDelta = size; return(size); }
//检测方块是否重叠 public float staticBoxMakeCheck(float x, ClickBox box) { float temp = x; float min = blockSize[0]; float max = 0; int index = 0; //在哪个位置 for (int i = 1; i < blockCount.Length - 1; i++) { if (x < blockSize[i]) { max = blockSize[i]; min = blockSize[i - 1]; index = i; break; } } if (blockCount[index] > 0) { //重新找一个位置 for (int i = index; i < blockCount.Length; i++) { if (blockCount[i] < 1) { temp = BattleManager.Instance.pop.leftPos.transform.position.x + (i * (max - min)); index = i; break; } } } else { temp = x; } blockCount[index]++; box.blockIndex = index; // Debug.Log("create"+index); return(temp); }
private Drawable createClickBox(TestType type) { switch (type) { case TestType.NonBlockingScroll: return(new NonBlockingScroll { RelativeSizeAxes = Axes.Both, Child = box = new ClickBox() }); case TestType.Scroll: return(new BasicScrollContainer { RelativeSizeAxes = Axes.Both, Child = box = new ClickBox() }); default: return(box = new ClickBox()); } }
public GameState() : base() { Instance = this; MapEntity = Entity.CreateInstance(_entityManager); new MapComponent(MapEntity); _connection = null; _messagePanel = new MessagePanel(this); _menuPanel = new MenuPanel(this); _movementTimer = 0.0f; this.AddControl(_messagePanel); this.AddControl(_menuPanel); ClickBox mapClickBox = new ClickBox(0, 0, Renderer.GetResoultion().X, Renderer.GetResoultion().Y, MouseButton.Right); mapClickBox.OnTrigger += MapClick; this.AddMouseListener(mapClickBox); }
public void Remove(GameObject go) { if (go == null) { Debug.Log("Remove null"); return; } else { ClickBox box = go.GetComponent <ClickBox>(); box.OverAnimPlay(); ClickBox.BoxType type = box.type; //处理点击事件a b if (type == ClickBox.BoxType.YellowBox || type == ClickBox.BoxType.BlueBox) { MakeEventAB(); blockCount[box.blockIndex]--; } Remove(go, type); clickCount++; } }
/* GetClickBoxesRecursive recursively searches for * active and unlocked clickBoxes in accending hierachical order */ public static List <ClickBox> GetClickBoxesRecursive(GameObject go) { List <ClickBox> cbs = new List <ClickBox>(); // Add click box of this object ClickBox cb = go.GetComponent <ClickBox>(); if (cb != null && !cb.Locked) { cbs.Add(cb); } // add clickboxes from children objects recursively foreach (Transform child in go.transform) { if (child.gameObject.activeSelf) { cbs.AddRange(GetClickBoxesRecursive(child.gameObject)); } } return(cbs); }
/* finds first clickBox that Contains both the starting * and ending click position, then runs it's event. */ private void runClickEvent(Vector2 start, Vector2 end) { List <ClickBox> cbs = ClickBoxes; ClickBox clickBox = null; // Search list of clickBoxes in decending hierachical order for (int i = cbs.Count - 1; i >= 0; i--) { ClickBox cb = cbs[i]; // Debug.Log($"{cb.gameObject.name}'s clickbox clicked."); if (cb.ContainsPoint(start) && cb.ContainsPoint(end)) { clickBox = cb; break; } } if (clickBox != null) { clickBox.Click(start, end); lastClickTime = GetMillis(); } }
void Awake() { // add home button click boxes foreach (ClickBox home in Home) { home.AddEventListener("onclick", () => { App.MoveToCollections(true); }); } // hide if in arview otherwise show App.AddEventListener("beforeshow", () => { if (App.nPage == App.ARView.gameObject) { hide = true; } else { if (App.nPage == Icons[0].page) { selectPage(Icons[0]); } hide = false; } }); if (MainClickBox == null) { MainClickBox = GetComponent <ClickBox>(); } if (MainClickBox != null) { MainClickBox.OnClick = onClicked; } selectPage(Icons[0]); }
private void GenerateSchedule() { int x = 0; // start at X-Axis int y = 14; // start at Y-Axis int n = 0; // box number bool bHeader = false; try { for (int d = 1; d <= 7; d++) { for (int h = 0; h <= 23; h++) { if (!bHeader) { var l = new Label(); l.Location = new Point(x + 1, 0); l.Margin = new Padding(0); l.Name = "lbl" + n; l.Text = n.ToString("D2"); // add leading zero when needed (2 digits) l.Size = new Size(20, 13); l.TextAlign = ContentAlignment.MiddleCenter; Invoke(new Action(() => BoxPanel.Controls.Add(l))); } ScheduleBox[n] = new ClickBox("box" + n, x, y); Invoke(new Action(() => BoxPanel.Controls.Add(ScheduleBox[n].box))); n++; x += 20; // X-Axis } bHeader = true; y += 20; // Y-Axis x = 0; // X-Axis } } catch (Exception ex) { DebugHelper.Exception(ex); } isDone = true; }
public void Remove(GameObject go, ClickBox.BoxType type) { ClickBox box = go.GetComponent <ClickBox>(); go.SetActive(false); switch (type) { case ClickBox.BoxType.YellowBox: yellowBoxCount--; attackBoxCount--; _yellowObjects.Remove(go); break; case ClickBox.BoxType.RedBox: redBoxCount--; moveBoxCount--; _redObjects.Remove(go); break; case ClickBox.BoxType.BombBox: bombBoxCount--; moveBoxCount--; _bombObjects.Remove(go); if (bombBoxCount < 0) { bombBoxCount = 0; } break; case ClickBox.BoxType.BlueBox: blueBoxCount--; attackBoxCount--; _blueObjects.Remove(go); break; case ClickBox.BoxType.ComboBox: comboBoxCount--; _comboObjects.Remove(go); break; case ClickBox.BoxType.BossBox: bossBoxCount--; moveBoxCount--; _bossObjects.Remove(go); break; case ClickBox.BoxType.FastBox: fastBoxCount--; moveBoxCount--; _fastObjects.Remove(go); break; case ClickBox.BoxType.GroundBox: groundBoxCount--; moveBoxCount--; _groundObjects.Remove(go); break; } if (moveBoxCount < 0) { moveBoxCount = 0; } Destroy(go); }
//固定块 public void Spawn(GameObject prefab, ClickBox.BoxType type, float width) { // if(!hasStatic) return; float min; float max; float x; float y; Vector3 pos = transform.position; min = BattleManager.Instance.pop.leftPos.transform.position.x; max = BattleManager.Instance.pop.rightPos.transform.position.x; x = Mathf.Lerp(min, max, UnityEngine.Random.value); y = centerY; GameObject go = Instantiate(prefab) as GameObject; int index = 0; int layer = 0; switch (type) { case ClickBox.BoxType.BlueBox: blueBoxIndex++; index = blueBoxIndex; blueBoxCount++; attackBoxCount++; layer = 100; _blueObjects.Add(go); break; case ClickBox.BoxType.YellowBox: yellowBoxIndex++; index = yellowBoxIndex; yellowBoxCount++; attackBoxCount++; layer = 1000; _yellowObjects.Add(go); break; case ClickBox.BoxType.ComboBox: comboBoxIndex += 3; index = comboBoxIndex; comboBoxCount++; layer = 10; _comboObjects.Add(go); break; } ClickBox box = go.GetComponent <ClickBox>(); go.transform.parent = this.transform; go.transform.localScale = new Vector3(1, 1, 1); x = staticBoxMakeCheck(x, box); //控制在横条内生成 Bounds bound = go.GetComponent <Collider2D>().bounds; float half = bound.size.x / 2; if (type == ClickBox.BoxType.ComboBox) { half += half * 0.3f; } float temp = min + half; if (x < temp) { x = temp; } temp = max - half; if (x > temp) { x = temp; } box.Init(half, layer + index); if (type == ClickBox.BoxType.ComboBox) { float tt = max + Math.Abs(min); x = min + (tt / 2); } //技能条重叠解决 //if (_comboObjects.Count > 0 && type != ClickBox.BoxType.ComboBox) //{ // foreach (GameObject d in _comboObjects) // { // DragBox drag = d.GetComponent<DragBox>(); // float haf = drag.childBox.bounds.size.x/2; // if (drag.childBox.bounds.Intersects(bound)) // { // x += drag.childBox.bounds.size.x; // } // } //} go.transform.position = new Vector3(x, y, 0); }
public void Flash(ClickBox b, Color c) { b.Flash(c); }
/// <summary> /// permanently sets the color of a block /// </summary> /// <param name="b"></param> /// <param name="c"></param> public void Highlight(ClickBox b, Color c) { b.Highlight(c); }