private void PerformAction(ActionHolders holder, ActionHolder action, MapElementInfo info) { FDataAction da = action.DataAction(); //can use? if (!action.req.Check(info.Player(), info, info.Pos())) { //TODO not hardcoded //start interact action? if (da.mapElement && holder.Contains("interact") && da.field == "near") { PerformAction(holder, holder.Get("interact"), info); return; } ShowPanelMessageError(action.req.Desc(info.Player(), info, info.Pos())); return; } //check ap if (action.cost > info.data.ap) { ActionHelper.WaitRound(holder, action, info, info.Pos()); return; } string mess = holder.Perform(action, ActionEvent.Direct, S.ActPlayer(), info, info.Pos()); if (mess != null) { ShowPanelMessageError(mess); } }
public override void ShowDetail(PanelBuilder panel) { foreach (var action in info.data.action.actions) { action.PerformAction().BuildPanel(new ActionDisplaySettings(panel, info.Player(), info, info.Pos(), action)); } }
public override void Add(Info noti) { base.Add(noti); if (mapElementInfo.Town() != null) { mapElementInfo.Town()?.info.Add(noti); } else { mapElementInfo.Player().info.Add(noti); } }
public override void ShowDetail(PanelBuilder panel) { panel.AddSubLabel("Position", _mapElementInfo.Pos().ToString()); panel.AddHeaderLabel("HP"); panel.AddInput("HP", _mapElementInfo.data.hp, (s => { _mapElementInfo.data.hp = s; })); panel.AddHeaderLabel("AP"); panel.AddInput("AP", _mapElementInfo.data.ap, (s => { _mapElementInfo.data.ap = s; })); panel.AddButton("Set Finish", _mapElementInfo.FinishConstruct); //display all actions foreach (var act in _mapElementInfo.data.action.actions) { act.PerformAction().BuildPanel(new ActionDisplaySettings(panel, _mapElementInfo.Player(), _mapElementInfo, _mapElementInfo.Pos(), act)); } //display modis }
public virtual void Perform(MapElementInfo self, MapElementInfo nonSelf) { // calc damage int damage = CalcDamage(self, nonSelf); string a = $"{self.name} ({self.Player().name})"; string d = $"{nonSelf.name} ({nonSelf.Player().name})"; Debug.LogError("Damage:" + damage); // check it if (damage == 0) { OnMapUI.Get().unitUI.ShowPanelMessage(S.T("attackDamEqual", self.name, d)); NAudio.Play("defend"); //inform another player nonSelf.AddNoti($"Defended against {a}", self.baseData.Icon); return; } // counter fight if (damage < 0) { Perform(nonSelf, self); OnMapUI.Get().unitUI.ShowPanelMessage($"{d} fight back."); return; } // win ShowUnitAttack(self, nonSelf); nonSelf.AddHp(-damage); L.b.animations.Hp(-damage, nonSelf.Pos(), nonSelf); OnMapUI.Get().unitUI.ShowPanelMessage($"You won. {d} lose {damage} HP."); nonSelf.AddNoti($"{a} attacked you. {nonSelf.name} lose {damage} HP.", self.baseData.Icon); //int oX = defensor.getX(); //int oY = defensor.getY(); //UiHelper.textAnimation("-" + damage + " hp", oX, oY, true, Color.SALMON); //TODO add animation //defensor.getActor().addAction(Actions.sequence(Actions.color(Color.RED, 1), Actions.color(Color.WHITE, 1))); //getActor().addAction(Actions.parallel(Actions.sequence(Actions.moveTo(oX * 32, oY * 32, 1), Actions.moveTo(x * 32, y * 32, 1)), // Actions.sequence(Actions.color(Color.BLACK, 1), Actions.color(Color.WHITE, 1)))); }
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) { var unit = S.Unit().At(pos); if (!CreateBonus(unit.Player(), unit, pos, unit.Town())) { info.UI().ShowPanelMessageError(S.T("presentNone", info.data.name, unit.data.name)); return; } info.data.apMax += 1; info.UI().ShowPanelMessage(S.T("presentSuccessful", info.data.name, unit.data.name)); //gift self? add costs if (unit.Player() == info.Player()) { holder.cost += Random.Range(1, 1 + holder.cost / 4); info.AddNoti(S.T("presentOwn"), DataAction().Icon); } }
public override void ShowLexicon(PanelBuilder panel, MapElementInfo onMap, NVector pos) { if (onMap == null) { ShowIntern(panel, null, pos); ActionDisplaySettings sett = new ActionDisplaySettings(panel, S.ActPlayer(), null, pos, null); sett.compact = true; action.BuildPanelT(sett); return; } if (!onMap.Owner(S.ActPlayerID())) { ShowLexicon(panel); return; } pos = onMap.Pos(); ShowIntern(panel, onMap, pos); onMap.data.action.BuildPanelT(new ActionDisplaySettings(panel, onMap.Player(), onMap, pos, null)); }
protected override bool CheckMapElement(MapElementInfo mapElement, string sett) { return(mapElement.Player().elements.Contains(sett)); }
protected override bool CheckMapElement(MapElementInfo mapElement, string sett) { return(mapElement.Player().Nation().Ethos == sett); }