public void UnitInit(MapElementInfo mei, string type, int town, int player, CalculatedData calc) { this.type = type; DataUnit u = L.b.units[type]; BaseInit(mei, u, calc); townId = town; playerId = player; }
public void BuildingInit(MapElementInfo mei, string type, int town, CalculatedData calc) { this.type = type; DataBuilding b = L.b.buildings[type]; BaseInit(mei, b, calc); townId = town; BuildingUpdate(); }
private void BaseInit(MapElementInfo mei, BaseDataBuildingUnit d, CalculatedData calc) { action = new ActionHolders(d.action); sprite = d.Icon; name = d.Name(); hp = calc.hp; hpMax = calc.hp; ap = calc.ap; apMax = calc.ap; atk = d.atk; def = d.def; visibilityRange = d.visibilityRange; data = new Dictionary <string, string>(); items = new Dictionary <string, string>(); modi = new Dictionary <string, string>(); spells = new MapElementSpells(); info = new MapElementInfoInfoMgmt(); info.mapElementInfo = mei; }
/// <summary> /// Calculate the ap & hp based on this material /// </summary> /// <param name="ele"></param> /// <param name="cost"></param> /// <returns></returns> public static CalculatedData Calc(BaseDataBuildingUnit ele, Dictionary <string, int> cost) { float hp = ele.hp; float ap = ele.ap; decimal buildTime = 0; int buildCount = 0; foreach (var r in cost) { var res = L.b.res[r.Key]; hp += res.hp * r.Value; ap += res.ap * r.Value; if (res.modi.ContainsKey(C.BuildRes)) { buildTime += ConvertHelper.Proc(res.modi[C.BuildRes]) * r.Value; buildCount += r.Value; } } if (buildCount > 0) { buildTime = buildTime / buildCount * ele.buildTime; } else { buildTime = ele.buildTime; } var data = new CalculatedData(); data.hp = (int)Math.Round(hp); data.ap = (int)Math.Round(ap); data.buildTime = (int)Math.Round(buildTime); return(data); }