private void Equip(string id, string category, Button button) { if (_info.Town() == null) { UIHelper.ShowOk(S.T("itemEquipNew"), S.T("townNo")); return; } WindowBuilderSplit wbs = WindowBuilderSplit.Create(S.T("itemEquipNew"), "Equip"); wbs.Add(new ItemNoSelectSplitInfo(_info, button, id)); foreach (var item in L.b.items.GetAllByCategory(category)) { //has already? if (_info.data.items.ContainsValue(item.id)) { continue; } if (_info.Town().GetRes(item.id) >= 1) { wbs.Add(new ItemSelectSplitInfo(_info, button, id, item)); } } wbs.Finish(); }
public override void Add(Info noti) { base.Add(noti); if (mapElementInfo.Town() != null) { mapElementInfo.Town()?.info.Add(noti); } else { mapElementInfo.Player().info.Add(noti); } }
protected override int ValueAct(Player player, MapElementInfo onMap, string element, string sett, NVector pos) { //has it? if (onMap != null) { return(onMap.Town()?.level ?? 0); } //has the field it? UnitInfo u = S.Unit().At(pos); if (u != null) { return(u.Town()?.level ?? 0); } //has the field it? BuildingInfo b = S.Building().At(pos); if (b != null) { return(b.Town()?.level ?? 0); } //get the nearest town Town t = S.Towns().NearestTown(player, pos, false); return(t?.level ?? 0); }
protected void RemoveOld() { //remove old? if (_info.data.items.ContainsKey(id)) { _info.Town().AddRes(_info.data.items[id], 1, ResType.Equip); L.b.items[_info.data.items[id]].action.Removes(ActionEvent.Quest, S.ActPlayer(), _info, _info.Pos()); } }
/// <summary> /// /// </summary> /// <returns>true == under construction</returns> public bool NextRound() { Town t = _info.Town(); foreach (KeyValuePair <string, int> cost in _data.construction.ToDictionary(entry => entry.Key, entry => entry.Value)) { //buildtime? if (cost.Key == C.BuildRes) { continue; } //normal ress? if (t.GetRes(cost.Key) >= cost.Value) { t.AddRes(cost.Key, -cost.Value, ResType.Construction); _data.construction.Remove(cost.Key); } else if (t.GetRes(cost.Key) >= 1) { int val = t.GetRes(cost.Key); _data.construction[cost.Key] -= val; t.AddRes(cost.Key, -val, ResType.Construction); _info.SetLastInfo($"Need {_data.construction[cost.Key]} more {L.b.res[cost.Key].Name()} for construction of {_data.name}."); } else { _info.SetLastInfo($"Need {_data.construction[cost.Key]} more {L.b.res[cost.Key].Name()} for construction of {_data.name}."); } } //buildtime if (_data.construction[C.BuildRes] > 0) { _data.construction[C.BuildRes] -= 1; //set opacity GetComponent <SpriteRenderer>().color = new Color(GetConstructionProcent(), 1, GetConstructionProcent(), 0.5f + GetConstructionProcent() / 2); } //finish? if (_data.construction.Count == 1 && _data.construction[C.BuildRes] == 0) { _data.construction = null; _data.buildTime = 0; _info.FinishConstruct(); return(false); } return(true); }
private void Build(bool up, MapElementInfo info, NVector pos, ActionHolder holder) { //Debug.Log($"Old {pos}"); //Debug.Log($"Old {info.Pos()}"); if (up) { Debug.Log($"New {pos.DiffLevel(1)}"); BuildingInfo n = S.Building().Create(info.Town().id, "stair", pos.DiffLevel(1)); n.FinishConstruct(); n.SetSprite(holder.data["stair"]); n.data.data["level"] = "-1"; } else { Debug.Log($"New {pos.DiffLevel(-1)}"); info.SetSprite(holder.data["stair"]); BuildingInfo n = S.Building().Create(info.Town().id, info.data.type, pos.DiffLevel(-1)); n.FinishConstruct(); n.data.data["level"] = "1"; } info.data.data["level"] = up ? "1" : "-1"; }
private void ShowTown() { //remove actions UIHelper.ClearChild(infoButtons); //has element? MapElementInfo mei = OnMapUI.Get().GetActive(); if (mei == null) { return; } Debug.Log("show town"); Debug.Log(mei); //has town? Town town = mei.Town(); if (town == null) { return; } //open town var button = UIElements.CreateImageButton(town.GetIcon(), infoButtons.transform, town.ShowDetails); button.transform.GetChild(0).GetComponent <Image>().color = town.Coat().color; UIHelper.HoverEnter(button, () => ShowPanelMessage(S.T("townDetails", mei.name, town.name)), () => ShowPanelMessage("")); //todo limit res int max = 10; // show res foreach (var r in L.b.res.Values()) { if (!town.KnowRes(r.id) || r.special) { continue; } int count = town.GetRes(r.id); var img = UIElements.CreateImageCounter(infoButtons.transform, count, r.Icon); UIHelper.HoverEnter(img, () => ShowPanelMessage(S.T("townRes", town.name, r.Text(count))), () => ShowPanelMessage("")); } }
protected bool ProduceOneRes(ActionEvent evt, MapElementInfo info, NVector pos, int val, string res) { //Debug.Log(res+" "+val+" "+GameMgmt.Get().data.map.ResGenContains(pos, res)); //remove? if (val > 0 && GameMgmt.Get().data.map.ResGenContains(pos, res)) { int rval = GameMgmt.Get().data.map.ResGen(pos, res); if (rval < 200 && Random.Range(0, 200) > rval) { val = 1; } if (rval <= 0) { info.SetLastInfo(S.T("produceDepositEmpty", res)); return(false); } if (rval < 20) { info.SetLastInfo(S.T("produceDepositNearlyEmpty", res)); } GameMgmt.Get().data.map.ResGenAdd(pos, res, -val); } ResType r = evt == ActionEvent.NextRound ? ResType.Produce : evt == ActionEvent.FinishConstruct ? ResType.Construction : ResType.Gift; double v = val; //add modi? if (r == ResType.Produce && val > 0) { v = L.b.modifiers[C.ProduceModi].CalcModi(v, info.Player(), info.Pos()); } //todo right comb? info.Town().AddRes(res, v, r); return(true); }
protected override void Perform(ActionEvent evt, Player player, MapElementInfo info, NVector pos, ActionHolder holder) { SelectDest(player, holder, info.Town()); }
protected override void Perform(ActionEvent evt, Player player, MapElementInfo info, NVector pos, ActionHolder holder) { new ActionTradeWindow(info.Town(), holder.data["trade"]); }
protected override int ValueAct(Player player, MapElementInfo onMap, string element, string sett, NVector pos) { return(onMap.Town().GetRes(element)); }
protected override void Perform(ActionEvent evt, Player player, MapElementInfo info, NVector pos, ActionHolder holder) { info.Town().Evolve(ConvertHelper.Int(holder.data["level"])); }