protected override bool AddGoal(UnitInfo unit, ActionHolder holder, NVector pos) { if (unit.Player().fog.Visible(pos)) { return(false); } return(base.AddGoal(unit, holder, pos)); }
protected virtual bool AddGoal(UnitInfo unit, ActionHolder holder, NVector pos) { //found it and movable? int cost = GameMgmt.Get().newMap.PathFinding(unit.Pos().level).Cost(unit.Player(), unit.dataUnit.movement, unit.Pos(), pos); if (cost > 0) { Debug.Log("Set Goal " + cost + " " + unit.Pos() + " " + pos); holder.data["pos"] = pos.ToString(); return(true); } return(false); }
protected override bool AddGoal(UnitInfo unit, ActionHolder holder, NVector pos) { if (unit.Player().overlay.Get("res", pos) == 1) { return(false); } //has res? if (GameMgmt.Get().data.map.levels[pos.level].ResGenKey(pos.x, pos.y) == null) { return(false); } return(base.AddGoal(unit, holder, pos)); }
private void TryMoveUnit(UnitInfo info, NVector pos) { //is free? if (!S.Unit().Free(pos)) { OnMapUI.Get().unitUI.ShowPanelMessageError($"{info.name} can not move between the levels, the destination is blocked."); return; } //have enough ap? int cost = GameMgmt.Get().newMap[pos.level].PathFinding().Cost(info.Player(), info.dataUnit.movement, pos, pos); cost = Math.Max(cost, 10); // cost at least 10 ap if (cost > info.data.ap) { OnMapUI.Get().unitUI.ShowPanelMessageError($"{info.name} can not move between the levels. {info.name} need {cost} AP, but only have {info.data.ap} AP."); return; } info.data.ap -= cost; info.MoveTo(pos); }
/// <summary> /// Press the action /// </summary> /// <param name="key"></param> private void PressAction(InputKey key) { //which has this action? if (_aUnit != null) { BaseDataBuildingUnit data = _aUnit.baseData; //unit contains action? if (data.action.Contains(key.id)) { //TODO check more settings //can perform action? ActionHolder action = data.action.Get(key.id); OnMapUI.Get().unitUI.ShowPanelMessageError(data.action.Perform(action, ActionEvent.Direct, _aUnit.Player(), _aUnit, _aUnit.Pos())); return; } } if (_aBuilding != null) { BaseDataBuildingUnit data = _aBuilding.baseData; //unit contains action? if (data.action.Contains(key.id)) { //TODO check more settings //can perform action? ActionHolder action = data.action.Get(key.id); OnMapUI.Get().unitUI.ShowPanelMessageError(data.action.Perform(action, ActionEvent.Direct, _aBuilding.Player(), _aBuilding, _aBuilding.Pos())); return; } } //found nothing? OnMapUI.Get().unitUI.ShowPanelMessageError($"Action {L.b.actions[key.id].Name()} can not called, their is no unit or building, who can perform it."); }
protected override void ClickFirst() { //special field? if (!S.Unit().Free(LastClickPos)) { UnitInfo unit = S.Unit().At(LastClickPos); if (unit.Owner(S.ActPlayerID())) { mapElementInfo.UI().ShowPanelMessage($"You want to interact with {unit.name}? Click again!"); } else { mapElementInfo.UI().ShowPanelMessage($"You want to fight with {unit.name} from {unit.Player().name}? Click again!"); } return; } DataTerrain terr = GameMgmt.Get().newMap.Terrain(LastClickPos); mapElementInfo.UI().ShowPanelMessage($"You want to interact with {terr.Name()}? Click again!"); }