//Generate a week unit use for player kill. private void GenerateDollUnit() { Vector2 pos = mapData.GetTutorialCameraPos(TutorialModeStage.NormallyControlOperation_Stage, 2); pos.x += 3; mainCamera.SetCameraVector2PositionLerp(pos, 0.75f); BattleUnit model = new BattleUnit(); aiHoldSoldierID.Add(inputHandler.SpawnSoldierInMap(ForceMark.TopRedForce, 30001, mapData.GetTutorialPathPointPosition()[1], model)); Soldier weekUnit; logicWorld.soldiers.TryGetValue(aiHoldSoldierID[0], out weekUnit); if (weekUnit != null) { weekUnit.physicalAttack = Mathf.RoundToInt(weekUnit.physicalAttack * 0.5f); //This unit just have 50% physicalAttack. } //When TutorialModeStage.NormallyControlOperation_Stage all unit can't use skill if (tutorialStage == TutorialModeStage.NormallyControlOperation_Stage) { ClosedAllUnitSkill(); } }
private BattleUnit UnitLevelPropertyRatio(BattleUnit unitData, TrainingWavesProto.TrainingWaves currentWave) { //TODO:If need change init unit value.Need modify waveTable like endlessWaveTable int waveLV = 0; for (int i = 0; i < unitData.props.Count; i++) { if (unitData.props[i].propertyType == PropertyType.MaxHealth) { unitData.props[i].propertyValue = unitData.props[i].propertyValue * currentWave.UnitLevel_PropertyRatio * waveLV; } else if (unitData.props[i].propertyType == PropertyType.HealthRecover) { unitData.props[i].propertyValue = unitData.props[i].propertyValue * currentWave.UnitLevel_PropertyRatio * waveLV; } else if (unitData.props[i].propertyType == PropertyType.PhysicalAttack) { unitData.props[i].propertyValue = unitData.props[i].propertyValue * currentWave.UnitLevel_PropertyRatio * waveLV; } //else if( unitData.props[ i ].propertyType == PropertyType.RangedDmgBase ) //{ // unitData.props[ i ].propertyValue += unitData.props[ i ].propertyValue * currentWave.UnitLevel_PropertyRatio * waveLV; //} else if (unitData.props[i].propertyType == PropertyType.AttackRange) { unitData.props[i].propertyValue = unitData.props[i].propertyValue * currentWave.UnitLevel_RangeRatio * waveLV; } //else if( unitData.props[ i ].propertyType == PropertyType.AttackRadius ) //{ // unitData.props[ i ].propertyValue += unitData.props[ i ].propertyValue * currentWave.UnitLevel_DamageRadiusRatio * waveLV; //} else if (unitData.props[i].propertyType == PropertyType.Speed) { unitData.props[i].propertyValue = unitData.props[i].propertyValue * currentWave.UnitLevel_SpeedRatio * waveLV; } else { DebugUtils.Log(DebugUtils.Type.Training, "This prop not need modify value about TrainingWaves table"); continue; } } return(unitData); }
public void SetTutorialPlayerUnits(List <BattleUnit> battleUnits) { List <int> unitIds = new List <int>() { 30001, 30005, 30006 }; for (int j = 0; j < 3; j++) { for (int i = 0; i < unitIds.Count; i++) { BattleUnit unit = new BattleUnit(); unit.metaId = unitIds[i]; unit.count = 1; battleUnits.Add(unit); } } }
public void GetPlayerBattleUnitByType(BattleType type, List <BattleUnit> battleUnits) { int armyIndex = GetArmyIndexByBattleType(type); ArmyInfo army = player.battleArmyList.ArmyList.Find(p => p.listId == (armyIndex)); Dictionary <int, float[]> runeDic = GetRunePageAttribute((GetRuneIndexByBattleType(type))); for (int i = 0; i < army.unitIds.Count; i++) { BattleUnit unit = battleUnits.Find(p => p.metaId == army.unitIds[i]); SoldierInfo s = player.army.soldiers.Find(p => p.metaId == army.unitIds[i]); UnitsProto.Unit soldierProto = unitsProtoData.Find(p => p.ID == s.metaId); unit = new BattleUnit(); unit.metaId = army.unitIds[i]; unit.count = 1; foreach (KeyValuePair <int, float[]> item in runeDic) { PropertyInfo temp = new PropertyInfo(); temp.propertyType = ( PropertyType )item.Key; if (temp.propertyType == PropertyType.ArmorPro) { temp.propertyValue = soldierProto.Armor * (1 + item.Value[1]) + item.Value[0]; } else if (temp.propertyType == PropertyType.AttackRange) { temp.propertyValue = soldierProto.AttackRange * (1 + item.Value[1]) + item.Value[0]; } else if (temp.propertyType == PropertyType.AttackSpeed) { temp.propertyValue = soldierProto.AttackInterval * (1 + item.Value[1]) + item.Value[0]; } else if (temp.propertyType == PropertyType.CriticalChance) { temp.propertyValue = soldierProto.CriticalChance * (1 + item.Value[1]) + item.Value[0]; } else if (temp.propertyType == PropertyType.CriticalDamage) { temp.propertyValue = soldierProto.CriticalDamage * (1 + item.Value[1]) + item.Value[0]; } else if (temp.propertyType == PropertyType.HealthRecover) { temp.propertyValue = soldierProto.HealthRegen * (1 + item.Value[1]) + item.Value[0]; } else if (temp.propertyType == PropertyType.MagicAttack) { temp.propertyValue = soldierProto.MagicAttack * (1 + item.Value[1]) + item.Value[0]; } else if (temp.propertyType == PropertyType.MagicResist) { temp.propertyValue = soldierProto.MagicResist * (1 + item.Value[1]) + item.Value[0]; } else if (temp.propertyType == PropertyType.MaxHealth) { temp.propertyValue = soldierProto.Health * (1 + item.Value[1]) + item.Value[0]; } else if (temp.propertyType == PropertyType.PhysicalAttack) { temp.propertyValue = soldierProto.PhysicalAttack * (1 + item.Value[1]) + item.Value[0]; } else if (temp.propertyType == PropertyType.Speed) { temp.propertyValue = soldierProto.MoveSpeed * (1 + item.Value[1]) + item.Value[0]; } else { DebugUtils.LogError(DebugUtils.Type.Battle, "Can't find this proptyType" + temp.propertyType); } unit.props.Add(temp); } // fill unit's gear data //for ( int j = 0; j < s.items.Count; j++ ) //{ // // itemType == 1 means this item is a GearItem // if ( s.items[j].itemType == 1 ) // { // unit.gearMetaId.Add( (int)s.items[j].metaId ); // } //} //fill unit's propertyInfo //for ( int j = 0; j < s..Count; j++ ) //{ // PropertyInfo p = new PropertyInfo(); // p.propertyType = s.props[j].propertyType; // p.propertyValue = s.props[j].propertyValue; //} //unit.level = s.level; //unit.star = s.star; battleUnits.Add(unit); } }
private long CreateSoldier(int soldierType, BattleUnit unitInfo = null) { long id = inputHandler.SpawnSoldierInMap(ForceMark.TopRedForce, soldierType, aiUnitBornPosition, unitInfo); return(id); }
private void EndLessModeWaveLogic(float deltaTime) { endLessModeTimer += deltaTime; if (endLessModeTimer >= currentWaveDelayTime && isWaitingForComplete == false) { EndlessWavesProto.EndlessWaves currentWave; endlessModeWavesData.TryGetValue(currentWaveId, out currentWave); if (currentWave != null) { for (int i = 0; i < currentWaveQuantity; i++) { int rangeInt = Random.Range(1, 101); long id = 0; int currentWaveUnitID; currentWaveUnitID = GetWavesUnitID(rangeInt, currentWave); endlessModeUnitData.TryGetValue(currentWaveUnitID, out unit); if (unit != null && currentWaveUnitID != -1) { unit = UnitLevelPropertyRatio(unit, currentWave); id = CreateSoldier(currentWaveUnitID, unit); DebugUtils.Assert(id != 0, "Endless Mode: Soldier ID is 0!"); aiSoldierIDList.Add(id); } else { DebugUtils.LogError(DebugUtils.Type.Endless, "Can not find this ID : " + currentWaveUnitID + "unit in EndlessModeUnitData"); } int pathMask = NavMeshAreaType.WALKABLE; //Walkable if (rangeInt >= currentWave.Deploy_Lane) { pathMask = NavMeshAreaType.BOTTOMPATH; //BottomPath } DebugUtils.Log(DebugUtils.Type.Endless, "rangeInt is " + rangeInt + "pathMask is " + pathMask); ConscriptSoldier conscriptSoldier = null; for (int j = 0; j < conscriptSoldierCache.Count; j++) { if (conscriptSoldierCache[j].isExpired) { conscriptSoldier = conscriptSoldierCache[j]; conscriptSoldier.Reset(); conscriptSoldier.soldierID = id; conscriptSoldier.navArea = pathMask; break; } } if (conscriptSoldier == null) { conscriptSoldier = new ConscriptSoldier(); conscriptSoldier.soldierID = id; conscriptSoldier.navArea = pathMask; conscriptSoldier.readyFightTimer = 0f; conscriptSoldierCache.Add(conscriptSoldier); } } } else { DebugUtils.LogError(DebugUtils.Type.Endless, "Can not find EndlessMode AI unit data"); } // For the PVE statistics datamanager.AddPveWaveNumber(); currentWaveId = currentWave.NextWave; currentWaveDelayTime = currentWave.NextDelay; currentWaveQuantity = currentWave.NextQuantity; if (currentWave.WaitForComplete == true) { isWaitingForComplete = true; } endLessModeTimer = 0; } }
private void InitEndlessModeUnitData(EndlessWavesProto.EndlessWaves sampleData) { List <int> EndlessModeUnitUIDList = new List <int>(); List <UnitsProto.Unit> unitsTempDatas = DataManager.GetInstance().unitsProtoData; EndlessModeUnitUIDList.Add(sampleData.UnitID_1); EndlessModeUnitUIDList.Add(sampleData.UnitID_2); EndlessModeUnitUIDList.Add(sampleData.UnitID_3); EndlessModeUnitUIDList.Add(sampleData.UnitID_4); EndlessModeUnitUIDList.Add(sampleData.UnitID_5); EndlessModeUnitUIDList.Add(sampleData.UnitID_6); EndlessModeUnitUIDList.Add(sampleData.UnitID_7); EndlessModeUnitUIDList.Add(sampleData.UnitID_8); EndlessModeUnitUIDList.Add(sampleData.UnitID_9); EndlessModeUnitUIDList.Add(sampleData.UnitID_10); for (int i = 0; i < EndlessModeUnitUIDList.Count; i++) { if (EndlessModeUnitUIDList[i] > 0) { BattleUnit model = new BattleUnit(); UnitsProto.Unit data = DataManager.GetInstance().unitsProtoData.Find(p => p.ID == EndlessModeUnitUIDList[i]); if (data == null) { DebugUtils.LogError(DebugUtils.Type.Training, string.Format("The Endless mode unit id error, can't find this unit id {0} unit, please check this.", EndlessModeUnitUIDList[i])); } PropertyInfo physicalAttack = new PropertyInfo(); physicalAttack.propertyType = PropertyType.PhysicalAttack; physicalAttack.propertyValue = data.PhysicalAttack; model.props.Add(physicalAttack); PropertyInfo magicAttackValue = new PropertyInfo(); magicAttackValue.propertyType = PropertyType.MagicAttack; magicAttackValue.propertyValue = data.MagicAttack; model.props.Add(magicAttackValue); PropertyInfo armor = new PropertyInfo(); armor.propertyType = PropertyType.ArmorPro; armor.propertyValue = data.Armor; model.props.Add(armor); PropertyInfo magicResist = new PropertyInfo(); magicResist.propertyType = PropertyType.MagicResist; magicResist.propertyValue = data.MagicResist; model.props.Add(magicResist); PropertyInfo criticalChance = new PropertyInfo(); criticalChance.propertyType = PropertyType.CriticalChance; criticalChance.propertyValue = data.CriticalChance; model.props.Add(criticalChance); PropertyInfo criticalDamage = new PropertyInfo(); criticalDamage.propertyType = PropertyType.CriticalDamage; criticalDamage.propertyValue = data.CriticalDamage; model.props.Add(criticalDamage); PropertyInfo moveSpeed = new PropertyInfo(); moveSpeed.propertyType = PropertyType.Speed; moveSpeed.propertyValue = data.MoveSpeed; model.props.Add(moveSpeed); PropertyInfo rangedMitigation = new PropertyInfo(); rangedMitigation.propertyType = PropertyType.AttackSpeed; rangedMitigation.propertyValue = data.AttackInterval; model.props.Add(rangedMitigation); PropertyInfo attackRange = new PropertyInfo(); attackRange.propertyType = PropertyType.AttackRange; attackRange.propertyValue = data.AttackRange; model.props.Add(attackRange); PropertyInfo health = new PropertyInfo(); health.propertyType = PropertyType.MaxHealth; health.propertyValue = data.Health; model.props.Add(health); PropertyInfo healthRegen = new PropertyInfo(); healthRegen.propertyType = PropertyType.HealthRecover; healthRegen.propertyValue = data.HealthRegen; model.props.Add(healthRegen); endlessModeUnitData.Add(EndlessModeUnitUIDList[i], model); } } }
// so SpawnUnitOnMap( MatchSide side, Vector3 bornPosition ) used for pve public long SpawnUnitOnMap(ForceMark mark, int unitMetaId, Vector3 bornPosition, BattleUnit unitInfo) { return(logicWorld.SpawnUnit(logicWorld.forces[mark].id, unitMetaId, bornPosition, unitInfo)); }
private void TrainingModeWaveLogic(float deltatime) { trainingModeTimer += deltatime; if (trainingModeTimer >= currentWaveDelayTime && isWaitingForComplete == false) { TrainingWavesProto.TrainingWaves currentWave; trainingModeWavesData.TryGetValue(currentWaveId, out currentWave); if (currentWave != null) { //TODO: there will change about designer, maybe need waiting a short time spacing to spwan new soldier for (int i = 0; i < currentWaveQuantity; i++) { int rangeInt = Random.Range(1, 101); long id = 0; int currenWavetUnitID; currenWavetUnitID = GetWavesUnitID(rangeInt, currentWave); trainingModeUnitData.TryGetValue(currenWavetUnitID, out unit); if (unit != null && currenWavetUnitID != -1) { unit = UnitLevelPropertyRatio(unit, currentWave); id = CreateSoldiers(currenWavetUnitID, unit); DebugUtils.Assert(id != 0, "Training Mode: Soldier ID is 0!"); aiSoldierIDList.Add(id); } else { DebugUtils.LogError(DebugUtils.Type.Training, "Can not find this ID : " + currenWavetUnitID + "unit in TrainingModeUnitData"); } int pathMask = NavMeshAreaType.WALKABLE;//walkable if (rangeInt >= currentWave.Deploy_Lane) { pathMask = NavMeshAreaType.BOTTOMPATH;//BottomPath } DebugUtils.Log(DebugUtils.Type.Training, "rangeInt is " + rangeInt + "pathMask is " + pathMask); ConscriptSoldier conscriptSoldier = null; for (int j = 0; j < conscriptSoldierCache.Count; j++) { if (conscriptSoldierCache[j].isExpired) { conscriptSoldier = conscriptSoldierCache[j]; conscriptSoldier.Reset(); conscriptSoldier.soldierID = id; conscriptSoldier.navArea = pathMask; break; } } if (conscriptSoldier == null) { conscriptSoldier = new ConscriptSoldier(); conscriptSoldier.soldierID = id; conscriptSoldier.navArea = pathMask; conscriptSoldier.readyFightTimer = 0f; conscriptSoldierCache.Add(conscriptSoldier); } } } // For the PVE statistics datamanager.AddPveWaveNumber(); currentWaveId = currentWave.NextWave; currentWaveDelayTime = currentWave.NextDelay; currentWaveQuantity = currentWave.NextQuantity; if (currentWave.WaitForComplete == true) { isWaitingForComplete = true; } trainingModeTimer = 0; } else { DebugUtils.Log(DebugUtils.Type.Training, "TrainingModeTiming... Not need to do anything"); } }
private void InitTrainingModeUnitData(object sampleData, TrainingGenerateType dataType) { List <int> trainingModeUnitUIDList = new List <int>(); List <UnitsProto.Unit> unitsTempDatas = DataManager.GetInstance().unitsProtoData; if (dataType == TrainingGenerateType.Normaly) { TrainingWavesProto.TrainingWaves data = (TrainingWavesProto.TrainingWaves)sampleData; trainingModeUnitUIDList.Add(data.UnitID_1); trainingModeUnitUIDList.Add(data.UnitID_2); trainingModeUnitUIDList.Add(data.UnitID_3); trainingModeUnitUIDList.Add(data.UnitID_4); trainingModeUnitUIDList.Add(data.UnitID_5); trainingModeUnitUIDList.Add(data.UnitID_6); trainingModeUnitUIDList.Add(data.UnitID_7); trainingModeUnitUIDList.Add(data.UnitID_8); trainingModeUnitUIDList.Add(data.UnitID_9); trainingModeUnitUIDList.Add(data.UnitID_10); } else if (dataType == TrainingGenerateType.Tutorial) { //TODO: Need add tutorial table data. } else { DebugUtils.LogError(DebugUtils.Type.Training, string.Format("Training can't know this type {0}", dataType)); } for (int i = 0; i < trainingModeUnitUIDList.Count; i++) { if (trainingModeUnitUIDList[i] == 0 || trainingModeUnitUIDList[i] == -1) { continue; } BattleUnit model = new BattleUnit(); UnitsProto.Unit data = DataManager.GetInstance().unitsProtoData.Find(p => p.ID == trainingModeUnitUIDList[i]); if (data == null) { DebugUtils.LogError(DebugUtils.Type.Training, string.Format("The Training mode unit id error, can't find this unit id {0} unit, please check this.", trainingModeUnitUIDList[i])); } PropertyInfo physicalAttack = new PropertyInfo(); physicalAttack.propertyType = PropertyType.PhysicalAttack; physicalAttack.propertyValue = data.PhysicalAttack; model.props.Add(physicalAttack); PropertyInfo magicAttackValue = new PropertyInfo(); magicAttackValue.propertyType = PropertyType.MagicAttack; magicAttackValue.propertyValue = data.MagicAttack; model.props.Add(magicAttackValue); PropertyInfo armor = new PropertyInfo(); armor.propertyType = PropertyType.ArmorPro; armor.propertyValue = data.Armor; model.props.Add(armor); PropertyInfo magicResist = new PropertyInfo(); magicResist.propertyType = PropertyType.MagicResist; magicResist.propertyValue = data.MagicResist; model.props.Add(magicResist); PropertyInfo criticalChance = new PropertyInfo(); criticalChance.propertyType = PropertyType.CriticalChance; criticalChance.propertyValue = data.CriticalChance; model.props.Add(criticalChance); PropertyInfo criticalDamage = new PropertyInfo(); criticalDamage.propertyType = PropertyType.CriticalDamage; criticalDamage.propertyValue = data.CriticalDamage; model.props.Add(criticalDamage); PropertyInfo moveSpeed = new PropertyInfo(); moveSpeed.propertyType = PropertyType.Speed; moveSpeed.propertyValue = data.MoveSpeed; model.props.Add(moveSpeed); PropertyInfo rangedMitigation = new PropertyInfo(); rangedMitigation.propertyType = PropertyType.AttackSpeed; rangedMitigation.propertyValue = data.AttackInterval; model.props.Add(rangedMitigation); PropertyInfo attackRange = new PropertyInfo(); attackRange.propertyType = PropertyType.AttackRange; attackRange.propertyValue = data.AttackRange; model.props.Add(attackRange); PropertyInfo health = new PropertyInfo(); health.propertyType = PropertyType.MaxHealth; health.propertyValue = data.Health; model.props.Add(health); PropertyInfo healthRegen = new PropertyInfo(); healthRegen.propertyType = PropertyType.HealthRecover; healthRegen.propertyValue = data.HealthRegen; model.props.Add(healthRegen); trainingModeUnitData.Add(trainingModeUnitUIDList[i], model); } }