private void ShowListHandler() { if (unitItemPool == null) { return; } if (!unitEnumerator.MoveNext()) { unitEnumerator.Dispose(); return; } int unitId = unitEnumerator.Current.Key; UnitItem unitItem = unitItemPool.GetObject(); unitItem.transform.SetParent(unitGroup, false); unitItem.transform.localPosition = Vector3.zero; unitItem.transform.localScale = Vector3.zero; UnitsProto.Unit unitData = controller.GetUnitData(unitId); unitItem.id = unitId; unitItem.icon = unitData.Icon_bust; unitItem.unitName = unitData.Name; unitItem.number = unitEnumerator.Current.Value; unitItem.RefreshItem(); unitItem.onClickEvent = OnClickEnterUnitDetailsCallBack; unitItem.transform.DOScale(Vector3.one, 0.05f).SetEase(Ease.OutCirc, 0.05f).OnComplete(ShowListHandler); unitCacheList.Add(unitItem); }
private void RefreshView() { RefreshButton(); curUnitData = controller.GetUnitProto(unitId); controller.CalculateData(curUnitData); string str = curUnitData.Name; string [] str2 = str.Split('/'); if (str2.Length == 2) { unitNameText.text = string.Format("<color=#1a8af1>{0}</color> {1}", str2[0], str2[1]); } ProfessionType type = ( ProfessionType )curUnitData.ProfessionType; ShowUnitTypeImage(type); if (type == ProfessionType.TramcarType || type == ProfessionType.DemolisherType) { unitBuy.gameObject.SetActive(false); attackDescriptionButton.gameObject.SetActive(false); skillDescriptionButton.gameObject.SetActive(false); } else { unitBuy.gameObject.SetActive(true); attackDescriptionButton.gameObject.SetActive(true); skillDescriptionButton.gameObject.SetActive(true); int[] prices = controller.GetUnitCost(unitId); diamondCostText.text = prices[0].ToString(); goldCostText.text = prices[1].ToString(); } int unitNumber = 0; currentUnits.TryGetValue(unitId, out unitNumber); numberTextBg.gameObject.SetActive(unitNumber != 0); numberText.text = string.Format(" 已拥有\t<color=#00FF00>X{0}</color>", unitNumber); DestroyShowModel(); if (curUnitData.show_model_res > 0) { DataManager.GetInstance().AddMainMenuCacheId(curUnitData.show_model_res); DataManager.GetInstance().AddMainMenuCacheId(curUnitData.show_effect_res); loadManager.LoadAssetAsync <GameObject, int>(curUnitData.show_model_res, LoadModel, curUnitData.show_model_res); loadManager.LoadAssetAsync <GameObject, int>(curUnitData.show_effect_res, LoadModelEffect, curUnitData.show_model_res); } else { DebugUtils.Log(DebugUtils.Type.UI, "No character models were found, id:" + curUnitData.show_model_res); } }
public void CalculateData(UnitsProto.Unit data) { float health = data.Health; infoDataDict[UnitDetailsType.Health].textValue = Round(health); infoDataDict[UnitDetailsType.Health].progressValue = TextToProgress(UnitDetailsType.Health, health); float attack = data.PhysicalAttack; infoDataDict[UnitDetailsType.Attack].textValue = Round(attack); infoDataDict[UnitDetailsType.Attack].progressValue = TextToProgress(UnitDetailsType.Attack, attack); float armor = data.Armor; infoDataDict[UnitDetailsType.Armor].textValue = Round(armor); infoDataDict[UnitDetailsType.Armor].progressValue = TextToProgress(UnitDetailsType.Armor, armor); float speed = data.MoveSpeed; infoDataDict[UnitDetailsType.Speed].textValue = Round(speed); infoDataDict[UnitDetailsType.Speed].progressValue = TextToProgress(UnitDetailsType.Speed, speed); float criticalChance = data.CriticalChance; infoDataDict[UnitDetailsType.CriticalChance].textValue = Round(criticalChance); infoDataDict[UnitDetailsType.CriticalChance].progressValue = TextToProgress(UnitDetailsType.CriticalChance, criticalChance); float attackDistance = data.AttackRange; infoDataDict[UnitDetailsType.AttackDistance].textValue = Round(attackDistance); infoDataDict[UnitDetailsType.AttackDistance].progressValue = TextToProgress(UnitDetailsType.AttackDistance, attackDistance); float magicAttack = data.MagicAttack; infoDataDict[UnitDetailsType.MagicAttack].textValue = Round(magicAttack); infoDataDict[UnitDetailsType.MagicAttack].progressValue = TextToProgress(UnitDetailsType.MagicAttack, magicAttack); float magicDefense = data.MagicResist; infoDataDict[UnitDetailsType.MagicDefense].textValue = Round(magicDefense); infoDataDict[UnitDetailsType.MagicDefense].progressValue = TextToProgress(UnitDetailsType.MagicDefense, magicDefense); float attackPerSecond = data.AttackInterval; infoDataDict[UnitDetailsType.AttackPerSecond].textValue = Round(attackPerSecond); infoDataDict[UnitDetailsType.AttackPerSecond].progressValue = TextToProgress(UnitDetailsType.AttackPerSecond, attackPerSecond); float critDamage = data.CriticalDamage; infoDataDict[UnitDetailsType.CritDamage].textValue = Round(critDamage); infoDataDict[UnitDetailsType.CritDamage].progressValue = TextToProgress(UnitDetailsType.CritDamage, critDamage); SetInfoValue(); }
private void PreloadedResources() { GameResourceLoadManager.GetInstance().LoadAssetAsync <GameObject>("UnitModelParent", delegate(GameObject go) { DataManager.GetInstance().AddMainMenuCacheObj(go.name, go); }); UnitsProto.Unit unit = DataManager.GetInstance().unitsProtoData.Find(p => p.ID == GameConstants.PRELOADED_SHOW_UNIT_ID); DataManager.GetInstance().AddMainMenuCacheId(unit.Icon_bust); DataManager.GetInstance().AddMainMenuCacheId(unit.show_model_res); DataManager.GetInstance().AddMainMenuCacheId(unit.show_effect_res); GameResourceLoadManager.GetInstance().LoadAssetAsync <GameObject>(unit.Icon_bust); GameResourceLoadManager.GetInstance().LoadAssetAsync <GameObject>(unit.show_model_res); GameResourceLoadManager.GetInstance().LoadAssetAsync <GameObject>(unit.show_effect_res); }
public override void OnExit(bool isGoBack) { base.OnExit(isGoBack); if (goUnitParent != null) { GameObject.Destroy(goUnitParent); goUnitParent = null; } shakeCamera = null; DestroyShowModel(); curUnitData = null; curShowSummonData = null; goUnitModelGameObject = null; controller.PostShowMainBackground(true); }
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); } }
public int GetSpecialCost(SpecialCardType specialIndex, out int limitNum) { //Locked building mode drag deployment code. Dwayne. /*if ( instituteCost == 0 ) * { * instituteCost = instituteProtoData.Find( p => p.ID == Constants.GameConstants.INSTITUTE_ID ).DeploymentCost; * * if ( towerProtoData.Count > 0 ) * { * towerCost = towerProtoData[0].DeploymentCost; * } * else * { * DebugUtils.LogError( DebugUtils.Type.UI, "There can't find towerPorotoData,check table and logic." ); * } * }*/ if (tramCarCost == 0) { UnitsProto.Unit unit = dataManager.unitsProtoData.Find(p => p.ID == Constants.GameConstants.UNIT_TRAMCAR_METAID); tramCarCost = unit.DeploymentCost; tramCarLimitNum = unit.MaxMembers; } if (demolisherCost == 0) { UnitsProto.Unit unit = dataManager.unitsProtoData.Find(p => p.ID == Constants.GameConstants.UNIT_DEMOLISHER_METAID); demolisherCost = unit.DeploymentCost; demolisherLimitNum = unit.MaxMembers; } int cost = 0; switch (specialIndex) { //Locked building mode drag deployment code. Dwayne. /* * case SpecialCardType.Institute: * { * cost = instituteCost; * limitNum = GameConstants.INSTITUTE_DEPLOYMENT_LIMIT; * break; * } * case SpecialCardType.Tower: * { * cost = towerCost; * limitNum = GameConstants.TOWER_DEPLOYMENT_LIMIT; * break; * }*/ case SpecialCardType.Tramcar: { cost = tramCarCost; limitNum = tramCarLimitNum; break; } case SpecialCardType.Demolisher: { cost = tramCarCost; limitNum = demolisherLimitNum; break; } default: { DebugUtils.LogError(DebugUtils.Type.UI, string.Format("Can't handle this SpecialCardType {0} now", specialIndex)); limitNum = -1; break; } } return(cost); }
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); } } }
public SquadData(UnitsProto.Unit protoData, int index) { this.protoData = protoData; this.index = index; }
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); } }