public InGameGUI(LevelState parent) { this.parent = parent; if (prices == null) { prices = new PriceDisplay[3]; } for (int i = 0; i < windowIsActive.Length; i++) { windowIsActive[i] = false; } blackFadeOverlay = 0.0f; keyFoundPic = AnimationLib.getFrameAnimationSet("keyPic"); keyNotFoundPic = AnimationLib.getFrameAnimationSet("keyEmptyPic"); coinAnim = AnimationLib.getFrameAnimationSet("testCoin"); medAnim = AnimationLib.getFrameAnimationSet("itemHealth"); ammoAnim = AnimationLib.getFrameAnimationSet("itemBattery"); arrowPointer = AnimationLib.getFrameAnimationSet("compassArrow"); mapIcon = TextureLib.getLoadedTexture("mapPda.png"); testWin = new BoxWindow("foo", 100, 100, 200, "GamePad code overflowing with madness"); flickerTime = 0.0f; playerOutOfSight = false; }
private BoxWindow AddWindow(Box box) { if (box.invisible) { return(null); } var obj = BoxWindow.Instantiate(boxWindowPrefab.gameObject, windowViewObject, box); if (box.parentBox.Count > 0) { BoxWindow parentWindow = SearchBoxWindow(box.parentBox[0]); if (parentWindow != null) { RectTransform objTrans = obj.GetComponent <RectTransform>(); RectTransform prentTrans = parentWindow.GetComponent <RectTransform>(); int a = parentWindow.box.childBox.Count; int b = (a % 2 == 0) ? -1 : 1; int x = a / 2 * b; objTrans.anchoredPosition = new Vector2(prentTrans.anchoredPosition.x + x * 300, prentTrans.anchoredPosition.y - prentTrans.sizeDelta.y - 300); } } boxWindows.Add(obj); return(obj); }
internal void OutRefresh() { if (BoxWindow != null) { BoxWindow.OutRefresh(); } Buffer.CopyRect(Terminal.ScreenBuffer, ScreenLeft, ScreenTop, Buffer, BufferLeft, BufferTop, Width, Height); }
void OnTriggerEnter2D(Collider2D other) { if (other.tag == "box") { BoxWindow bw = other.GetComponent <BoxWindow>(); if (bw != null && bw.dragAttribute.isDraging && this.dragAttribute.isDraging) { BoxViewModel.instance.Connect(bw.box, this.box); } } }
internal void DoUpdate() { if (Visible) { if (BoxWindow != null) { BoxWindow.DoUpdate(); } else { DoUpdate(0, 0, Width, Height); } } }
private void drawBox(ref BoxWindow box, SpriteBatch sb) { if (box.animationState == BoxWindow.State.Show) { sb.Draw(Game1.whitePixel, new Vector2(box.x, box.y), null, boxColor, 0.0f, Vector2.Zero, new Vector2(box.width, box.height), SpriteEffects.None, 0.5f); sb.DrawString(Game1.font, box.text, new Vector2(box.x, box.y), textColor); } else if (box.animationState == BoxWindow.State.Opening) { sb.Draw(Game1.whitePixel, new Vector2(box.x, box.y), null, boxColor, 0.0f, Vector2.Zero, new Vector2(box.width, box.height * box.animationLocation), SpriteEffects.None, 0.5f); } else if (box.animationState == BoxWindow.State.Closing) { sb.Draw(Game1.whitePixel, new Vector2(box.x, box.y), null, boxColor, 0.0f, Vector2.Zero, new Vector2(box.width, box.height * (1.0f - box.animationLocation)), SpriteEffects.None, 0.5f); } }
public void pushBox(BoxWindow box) { for (int i = 0; i < windowIsActive.Length; i++) { if (windowIsActive[i]) { continue; } windowIsActive[i] = true; boxWindows[i] = box; boxWindows[i].animationState = BoxWindow.State.Opening; boxWindows[i].animationLocation = 0.0f; break; } }
public static BoxWindow Instantiate(GameObject prefab, GameObject parent, Box box) { BoxWindow obj = Instantiate(prefab, parent.transform).GetComponent <BoxWindow>(); obj.box = box; if (box.color != "") { Color c = box.color.ToColor(); obj.defaultColor = c; } else if (box is BaseBox) { obj.defaultColor = obj.baseBoxColor; } obj.SetColor(obj.defaultColor); obj.removeButton.SetActive(box.optional); obj.titleText.text = box.title; obj.description.text = box.text; obj.icon.sprite = ImageIO.GetIcon(box.iconName); obj.SetContents(); foreach (Box b in box.parentBox) { obj.ConnectLine(b); } obj.box.parentBox .ObserveAdd() .Subscribe(x => obj.ConnectLine(x.Value)); obj.box.parentBox .ObserveRemove() .Subscribe(x => obj.DisconnectLine(x.Value)); //obj.HideConnector(); return(obj); }
// Use this for initialization void Start() { battleComponent = GetComponent <UIPanel>().ui; boxButton = battleComponent.GetChild("boxButton").asButton; boxButton.visible = false; boxButton.onClick.Add(() => { boxWindow = new BoxWindow(box); boxWindow.Show(); }); // 坦克将碰撞到的盒子传递过来,通过判断盒子是否为空表示远离或接近 Box.boxDelegate += (Box box) => { boxButton.visible = box == null ? false : true; // 远离盒子时关闭窗口 if (!boxButton.visible && boxWindow != null) { boxWindow.Hide(); boxWindow.Dispose(); boxWindow = null; boxButton.selected = false; } this.box = box; }; Tank.goodsDelegate += (List <Goods> goodsList) => { // 清除旧窗口 if (goodsWindow != null) { goodsWindow.Hide(); goodsWindow.Dispose(); goodsWindow = null; } // 新建新窗口 createGoodsWindow(goodsList); }; // 注册拖拽事件 GGroup footer = battleComponent.GetChild("footer").asGroup; mulGoodsList = battleComponent.GetChildInGroup(footer, "buttleList").asList; sinGoodsList = battleComponent.GetChildInGroup(footer, "goodsList").asList; GObject[] mulGoodsButtons = mulGoodsList.GetChildren(); GObject[] sinGoodsButtons = sinGoodsList.GetChildren(); getGoodsDelegate += getGoods; dragIcon = battleComponent.GetChild("dragIcon").asLoader; touchID = -1; bulletEmptyList = new List <GButton>(); medecineEmptyList = new List <GButton>(); for (int i = 0; i < mulGoodsButtons.Length; i++) { GButton btn = (GButton)mulGoodsButtons[i]; btn.visible = false; addDragAndDrop(btn); bulletEmptyList.Add(btn); } for (int i = 0; i < sinGoodsButtons.Length; i++) { GButton btn = (GButton)sinGoodsButtons[i]; btn.visible = false; addDragAndDrop(btn); // 包含药品、道具 medecineEmptyList.Add(btn); } coldDownTable = new Hashtable(); bulletColdDownTime = 0; medecineColdDownTime = 0; }