public StagePositionConfig Clone() { StagePositionConfig item = new StagePositionConfig(); /** 关卡编号 */ item.stageId = stageId; /** 建筑编号 */ item.index = index; /** 坐标 */ item.position = position.Clone(); /** 初始兵力 (-1通过公式计算;其他直接读配置) */ item.hp = hp; /** 势力ID */ item.legionId = legionId; /** 单位类型 */ item.unitType = unitType; /** 建筑类型 */ item.buildType = buildType; /** 建筑等级 */ item.level = level; /** 不同类型,建筑数据UID */ item.buildUid = buildUid; /** 英雄上阵优先级 */ item.settledPriority = settledPriority; item.name = name; item.stageName = stageName; return(item); }
static int ParseCsv(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); Games.Module.Wars.StagePositionConfig obj = (Games.Module.Wars.StagePositionConfig)LuaScriptMgr.GetNetObjectSelf(L, 1, "Games.Module.Wars.StagePositionConfig"); string[] objs0 = LuaScriptMgr.GetArrayString(L, 2); obj.ParseCsv(objs0); return(0); }
static int Clone(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); Games.Module.Wars.StagePositionConfig obj = (Games.Module.Wars.StagePositionConfig)LuaScriptMgr.GetNetObjectSelf(L, 1, "Games.Module.Wars.StagePositionConfig"); Games.Module.Wars.StagePositionConfig o = obj.Clone(); LuaScriptMgr.PushObject(L, o); return(1); }
public void AddStagePositionConfig(StagePositionConfig config) { List <StagePositionConfig> list = null; if (!stagePositionConfigs.TryGetValue(config.stageId, out list)) { list = new List <StagePositionConfig>(); stagePositionConfigs.Add(config.stageId, list); } // Debug.Log(string.Format("<color=yellow>config={0}</color>",config )); list.Add(config); }
static int _CreateGames_Module_Wars_StagePositionConfig(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 0) { Games.Module.Wars.StagePositionConfig obj = new Games.Module.Wars.StagePositionConfig(); LuaScriptMgr.PushObject(L, obj); return(1); } else { LuaDLL.luaL_error(L, "invalid arguments to method: Games.Module.Wars.StagePositionConfig.New"); } return(0); }
static int get_index(IntPtr L) { object o = LuaScriptMgr.GetLuaObject(L, 1); Games.Module.Wars.StagePositionConfig obj = (Games.Module.Wars.StagePositionConfig)o; if (obj == null) { LuaTypes types = LuaDLL.lua_type(L, 1); if (types == LuaTypes.LUA_TTABLE) { LuaDLL.luaL_error(L, "unknown member name index"); } else { LuaDLL.luaL_error(L, "attempt to index index on a nil value"); } } LuaScriptMgr.Push(L, obj.index); return(1); }
static int set_stageName(IntPtr L) { object o = LuaScriptMgr.GetLuaObject(L, 1); Games.Module.Wars.StagePositionConfig obj = (Games.Module.Wars.StagePositionConfig)o; if (obj == null) { LuaTypes types = LuaDLL.lua_type(L, 1); if (types == LuaTypes.LUA_TTABLE) { LuaDLL.luaL_error(L, "unknown member name stageName"); } else { LuaDLL.luaL_error(L, "attempt to index stageName on a nil value"); } } obj.stageName = LuaScriptMgr.GetString(L, 3); return(0); }
static int set_buildType(IntPtr L) { object o = LuaScriptMgr.GetLuaObject(L, 1); Games.Module.Wars.StagePositionConfig obj = (Games.Module.Wars.StagePositionConfig)o; if (obj == null) { LuaTypes types = LuaDLL.lua_type(L, 1); if (types == LuaTypes.LUA_TTABLE) { LuaDLL.luaL_error(L, "unknown member name buildType"); } else { LuaDLL.luaL_error(L, "attempt to index buildType on a nil value"); } } obj.buildType = (Games.Module.Wars.BuildType)LuaScriptMgr.GetNetObject(L, 3, typeof(Games.Module.Wars.BuildType)); return(0); }
/** 生成数据--墙 */ public void GenerationWalls() { foreach (KeyValuePair <int, StagePositionConfig> kvp in stageConfig.wallDict) { StagePositionConfig buildConfig = kvp.Value; UnitData unitData = new UnitData(); unitData.id = buildConfig.index; unitData.legionId = buildConfig.legionId; unitData.unitType = UnitType.Wall; unitData.level = buildConfig.level; unitData.position = buildConfig.position; unitData.positionConfig = buildConfig; unitData.wallConfig = War.model.GetBuildWallConfigg(buildConfig.buildUid); unitData.avatarId = unitData.wallConfig.avatarId; unitData.we_BuildConfigData = new WE_BuildConfigData(); unitData.we_BuildConfigData.buildConfig = unitData.wallConfig; // Debug.Log("buildConfig.buildUid=" + buildConfig.buildUid+ " unitData.wallConfig=" + unitData.wallConfig); wallDict.Add(buildConfig.index, unitData); } }
/** 生成数据--兵营 */ public void GenerationBuilds() { Dictionary <int, float[]> legionHeroTotals = new Dictionary <int, float[]>(); Dictionary <int, int> legionHeroCounts = new Dictionary <int, int>(); foreach (KeyValuePair <int, LegionData> legionKVP in legionDict) { LegionData legionData = legionKVP.Value; float[] heroTotals = new float[PropId.MAX]; int heroCount = 0; foreach (KeyValuePair <int, float[]> heroKVP in legionData.heroInitProp) { heroCount++; heroTotals.PropAdd(heroKVP.Value); } legionHeroTotals.Add(legionData.legionId, heroTotals); legionHeroCounts.Add(legionData.legionId, heroCount); } foreach (KeyValuePair <int, StageLegionConfig> kvp in stageConfig.legionDict) { StageLegionConfig legionConfig = kvp.Value; LegionData legionData = legionDict[legionConfig.legionId]; float[] soliderInitProp_Final = new float[PropId.MAX]; soliderInitProp_Final.PropAdd(legionData.soliderInitProp); soliderInitProp_Final.Calculate(); legionHeroTotals[legionData.legionId].Calculate(); //------------------ 生成势力 士兵属性(士兵模块提供攻击+参战武将战前攻击之和) -----------------------// // Debug.Log(legionData.legionId + " <color=green>F legionData.soliderData.Props</color>" + legionData.soliderInitProp.ToStrProp()); // legionData.soliderInitProp[PropId.InitAtk] = WarFormula.WF_Solider_Atk(legionData.levelData.intBattleForce, legionHeroTotals[legionData.legionId][PropId.Atk]); legionData.soliderInitProp[PropId.InitBattleForce] = WarFormula.WF_Solider_BattleForce(legionData.levelData.intBattleForce); legionData.soliderInitProp[PropId.InitMoveSpeed] = WarFormula.WF_Solider_MoveSpeed(legionData.levelData.intMoveSpeed, legionHeroTotals[legionData.legionId][PropId.MoveSpeed]); // Debug.Log(legionData.legionId + " <color=green>B legionData.soliderData.Props=</color>" + legionData.soliderInitProp.ToStrProp()); //------------------ 生成势力 兵营属性(产兵速度, 防御, 兵力上限) -----------------------// float[] props = new float[PropId.MAX]; // 战前兵营--产兵速度 props[PropId.InitProduceSpeed] = WarFormula.WF_Casern_ProduceSpeed(legionData.levelData.intProduceSpeed, legionHeroTotals[legionData.legionId][PropId.ProduceSpeed]); // 战前兵营--防御 // props[PropId.InitDef] = WarFormula.WF_Casern_Def(legionData.levelData.intBattleForce, legionHeroTotals[legionData.legionId][PropId.Def]); props[PropId.InitBattleForce] = WarFormula.WF_Casern_BattleForce(legionData.levelData.intBattleForce); // 战前兵营--兵力上限 props[PropId.InitMaxHp] = WarFormula.WF_Casern_MaxHP(legionHeroTotals[legionData.legionId][PropId.MaxHp]); // // 战前兵营--速攻 // props[PropId.InitSpeedAtk] = WarFormula.WF_Casern_SpeedAtk(legionData.levelData.intBattleForce, legionHeroTotals[legionData.legionId][PropId.SpeedAtk]); //Debug.Log ("legionData.legionId=" + legionData.legionId + " " + props.ToStrProp()); // 设置势力--兵营战前属性 legionData.buildInitProp = props; } // 兵营初始兵力(血量Hp) foreach (KeyValuePair <int, StagePositionConfig> kvp in stageConfig.buildDict) { StagePositionConfig buildConfig = kvp.Value; LegionData legionData = legionDict[buildConfig.legionId]; float[] full = new float[PropId.MAX]; full.PropAdd(legionData.buildInitProp); float hero_InitSpeedAtk = 0f; // HeroData heroData; // if(herosByBuild.TryGetValue(buildConfig.index, out heroData)) // { // hero_InitSpeedAtk = legionData.heroInitProp[heroData.heroId][PropId.InitSpeedAtk]; // } // 初始兵力--计算 // Debug.Log(string.Format("<color=yellow>buildConfig.index={0}, buildConfig.hp={1}</color>, full[PropId.MaxHp]={2}, hasHero={3} heroMaxHp={4}", buildConfig.index, buildConfig.hp, full[PropId.MaxHp],herosByBuild.ContainsKey(buildConfig.index), heroMaxHp)); // float hp = WarFormula.WF_Casern_Hp(buildConfig.hp, legionData.buildInitProp[PropId.InitMaxHp], herosByBuild.ContainsKey(buildConfig.index), heroMaxHp); float hp = WarFormula.WF_Casern_Hp(buildConfig.hp, legionData.levelData.initHP); float[] firstProp = new float[PropId.MAX]; firstProp[PropId.HpAdd] = hp; // 兵营初始属性[Hp] float[] initProp = new float[PropId.MAX]; initProp[PropId.InitHp] = hp; buildFirstProp.Add(buildConfig.index, firstProp); buildInitProp.Add(buildConfig.index, initProp); } int casernCount = 0; int turretCount = 0; int spotCount = 0; // 生成兵营UnitData foreach (KeyValuePair <int, StagePositionConfig> kvp in stageConfig.buildDict) { StagePositionConfig positionConfig = kvp.Value; UnitData unitData = new UnitData(); unitData.id = positionConfig.index; unitData.legionId = positionConfig.legionId; unitData.unitType = UnitType.Build; unitData.buildType = positionConfig.buildType; unitData.level = positionConfig.level; unitData.position = positionConfig.position; unitData.buildConfig = positionConfig.buildConfig; unitData.we_BuildConfigData = new WE_BuildConfigData(); unitData.we_BuildConfigData.hp = (int)positionConfig.hp; unitData.we_BuildConfigData.settledPriority = positionConfig.settledPriority; unitData.we_BuildConfigData.buildConfig = unitData.buildConfig; buildDict.Add(positionConfig.index, unitData); switch (unitData.buildType) { case BuildType.Casern: casernCount++; break; case BuildType.Turret: turretCount++; break; case BuildType.Spot: spotCount++; break; } } legionTotalMaxHP = casernCount * ConstConfig.GetFloat(ConstConfig.ID.War_StageLegionTotalMaxHP_Ratio_Casern) + turretCount * ConstConfig.GetFloat(ConstConfig.ID.War_StageLegionTotalMaxHP_Ratio_Turret) + spotCount * ConstConfig.GetFloat(ConstConfig.ID.War_StageLegionTotalMaxHP_Ratio_Spot); foreach (KeyValuePair <int, LegionData> kvp in legionDict) { kvp.Value.totalMaxHP = legionTotalMaxHP; } }