private void Shop(int count) { int b = Convert.ToInt32(Math.Ceiling(count * 1d * L.b.res[_buy].price / L.b.res[_buy].price)); _town.AddRes(_sell, -b, ResType.Trade); _town.AddRes(_buy, count, ResType.Trade); }
/// <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 GenItem(Town t, Player p, NVector pos) { var i = L.b.items.Random(); t.AddRes(i.id, 1, ResType.Gift); p.info.Add(new Info(S.T("chestGenItem", i.Name()), i.Icon).CameraMove(pos)); }
private void GenRes(Town t, Player p, NVector pos) { Resource r; do { r = L.b.res.Random(); } while (r.special || L.b.items.ContainsKey(r.id)); int a = Random.Range(5, 15); t.AddRes(r.id, a, ResType.Gift); p.info.Add(new Info(S.T("chestGenRes", a, r.Name()), r.Icon).CameraMove(pos)); }
protected override void Run(Player player) { //create it WindowPanelBuilder p = WindowPanelBuilder.Create("Debug Window"); p.panel.AddButton("Give 500 gold", () => { Town t = S.Towns().GetByActPlayer().First(); t.AddRes("gold", 500, ResType.Gift); }); p.panel.AddButton("Trade", () => { ActionHolder ah = new ActionHolder(); ah.data["trade"] = null; LClass.s.GetNewAction("trade").PerformCheck(ActionEvent.Direct, S.ActPlayer(), ah); }); p.panel.AddButton("Give research", () => { Town t = S.Towns().GetByActPlayer()[0]; t.AddRes("research", 100, ResType.Gift); }); p.panel.AddButton("Finish all research", () => { foreach (Research r in L.b.researches.Values()) { S.ActPlayer().research.Set(r.id, true); } }); p.panel.AddButton("Unfinish all research", () => { foreach (Research r in L.b.researches.Values()) { S.ActPlayer().research.Set(r.id, false); } }); p.panel.AddButton("Switch Fog", () => { foreach (TileMapConfig16 t in S.ActPlayer().fog.tileMap) { t.gameObject.SetActive(!t.gameObject.activeSelf); } }); p.panel.AddButton("Show player features", () => { WindowPanelBuilder wp = WindowPanelBuilder.Create("features"); foreach (var fp in L.b.playerOptions.Values()) { wp.panel.AddLabel(fp.Name() + ": " + S.ActPlayer().GetFeature(fp.id) + " (" + fp.standard + ")"); } wp.Finish(); }); p.panel.AddButton("Show game features", () => { WindowPanelBuilder wp = WindowPanelBuilder.Create("features"); foreach (var fp in L.b.gameOptions.Values()) { wp.panel.AddLabel(fp.Name() + ": " + fp.Value() + " (" + fp.standard + ")"); } wp.Finish(); }); p.panel.AddButton("Reload game library", () => { GameMgmt.Get().ReloadGameLib(); p.Close(); }); p.panel.AddButton("Give unit", () => { WindowPanelBuilder wp = WindowPanelBuilder.Create("units"); if (S.Towns().GetByActPlayer().Count > 0 && S.Unit().Free(S.Towns().GetByActPlayer()[0].pos)) { foreach (var du in L.b.units.Values()) { wp.panel.AddImageTextButton(du.Name(), du.Sprite(), (() => { S.Unit().Create(S.ActPlayerID(), du.id, S.Towns().GetByActPlayer()[0].pos).FinishConstruct(); wp.Close(); p.Close(); })); } } else { wp.panel.AddLabel("Field is blocked"); } wp.Finish(); }); p.panel.AddButton("Reset round", () => { S.Players().ResetRound(); }); p.panel.AddLabel("DPI: " + Screen.dpi); p.Finish(); }
private void Shop(int count) { _town.AddRes(_sell, -count, ResType.Trade); _dest.AddRes(_sell, count, ResType.Trade); }