public override void Click(NVector pos) { //known click? if (pos.Equals(LastClickPos)) { ClickSecond(); OnMapUI.Get().SetActiveAction(null, false); return; } //new Click? LastClickPos = pos; if (S.Unit().At(pos) != null) { NAudio.PlayCancel(); ClickFirstCancel(); } else { ClickFirst(); } }
public virtual void Click(NVector pos) { //known click? if (pos.Equals(LastClickPos)) { ClickSecond(); OnMapUI.Get().SetActiveAction(null, false); return; } //new Click? LastClickPos = pos; if (Points.Count(p => p.x == LastClickPos.x && p.y == LastClickPos.y) == 0) { NAudio.PlayCancel(); ClickFirstCancel(); } else { ClickFirst(); } }
public void AddInfoButton(Info info) { Button button = UIElements.CreateImageButton(SpriteHelper.Load(info.overviewIcon), infoButtons.transform, null); Action del = () => { NAudio.PlayCancel(); infoText.text = ""; info.read = true; Destroy(button.gameObject); //show res? if (infoButtons.GetComponentsInChildren <Transform>().Length <= 3) { UpdatePanel(); } }; if (info.action == null) { button.onClick.AddListener(() => { del(); //todo add desc? UIHelper.ShowOk("Notification", TextHelper.RichText(info.title, info.desc)); }); } else { button.onClick.AddListener(info.CallAction); } button.gameObject.AddComponent <ClickableObject>(); button.GetComponent <ClickableObject>().right = del; UIHelper.HoverEnter(button, () => ShowPanelMessage(info.title), () => ShowPanelMessage("")); }
public override void PreRun() { //calc size int diff = 1; //string moveTyp = ((UnitInfo) mapElementInfo).dataUnit.movement; //collect move for (int x = Math.Max(0,initPos.x-diff); x <= Math.Min(GameMgmt.Get().data.map.width-1,initPos.x+diff); x++) { for (int y = Math.Max(0,initPos.y-diff); y <= Math.Min(GameMgmt.Get().data.map.height-1,initPos.y+diff); y++) { //check enemy and fog //TODO combine with unit check NVector dPos = new NVector(x, y, initPos.level); if (!player.fog.Visible(dPos)) { continue; } //terrain ok? //TODO not hardcoded if (GameMgmt.Get().newMap.Terrain(dPos).category == "unknown") continue; //action possible? foreach (var action in mapElementInfo.data.action.actions) { FDataAction data = action.DataAction(); if (!data.mapElement || data.field != "near") continue; if (!action.req.Check(S.ActPlayer(), mapElementInfo, dPos, true)) { continue; } //Debug.Log($"{data.name}: {dPos}"); // if (Points.Count(p => p.x == x && p.y == y) > 0) // { // Points.RemoveAll(Points.Where(p => p.x == x && p.y == y)); // } if (!S.Unit().Free(dPos)) { //TODO color own? if (S.Unit().At(dPos).Owner(S.ActPlayerID())) { Color(dPos,2); } else { Color(dPos,1); } } else { Color(dPos,3); } break; } } } //nothing found? if (Points.Count == 0) { mapElementInfo.UI().ShowPanelMessageError("No interaction found."); OnMapUI.Get().SetActiveAction(null,mapElementInfo.IsBuilding()); NAudio.PlayCancel(); } }