IEnumerator AOEBuff(Vector3 pos, float range, float duration, BuffStat buff, _ModifierType modType, float delay) { yield return(new WaitForSeconds(delay)); LayerMask maskTower = 1 << LayerManager.LayerTower(); Collider[] cols = Physics.OverlapSphere(pos, range, maskTower); foreach (Collider col in cols) { UnitTower unitTower = col.gameObject.GetComponent <UnitTower>(); if (unitTower != null) { if (modType == _ModifierType.percentage) { unitTower.AbilityBuffMod(buff, duration); } else if (modType == _ModifierType.value) { unitTower.AbilityBuffVal(buff, duration); } } } //~ List<UnitTower> tempBuffList = new List<UnitTower>(buffList.Length); //~ tempBuffList.AddRange(buffList); }
public void BuffChangesStat(int initialValue, int additionalvalue) { var stats = new Stat[1]; var stat = new Stat(); stats[0] = stat; stat.id = 0; stat.value = initialValue; var buffs = new Buff[1]; var buff = new Buff(); buffs[0] = buff; var buffStats = new BuffStat[1]; buff.stats = buffStats; var buffStat = new BuffStat(); buffStat.statId = 0; buffStat.value = additionalvalue; buffStats[0] = buffStat; var statModels = StatsCreator.CreateDefaultStats(stats); StatsCreator.CreateBuffs(statModels, buffs, false); Assert.True(statModels[0].Value > initialValue); }
public static void WriteSingleBuffMask(PacketWriter pw, BuffStat buffStat) { WriteBuffMask(pw, new List <BuffStat>() { buffStat }); }
private List <Buff> MockBuffs() { //Бафф прибавляем 25 к здоровью BuffStat[] hpBuff = new BuffStat[1]; hpBuff[0].statId = 0; hpBuff[0].value = 25; //Уменьшает броню на 25 BuffStat[] armorBuff = new BuffStat[1]; hpBuff[0].statId = 1; hpBuff[0].value = -25; List <Buff> res = new List <Buff> { new Buff() { id = 0, stats = hpBuff }, new Buff() { id = 1, stats = armorBuff } }; return(res); }
public static void RemoveBuff(string[] split, MapleClient c) { int buffBit = int.Parse(split[1]); BuffStat buffstat = new BuffStat(buffBit); c.SendPacket(Buff.RemoveBuffTestPacket(buffstat)); }
IEnumerator RegenHPRoutine(BuffStat buff) { while (activeBuffList.Contains(buff)) { GainHP(Time.deltaTime * buff.regenHP); yield return(null); } }
public static void GetBuff(string[] split, MapleClient c) { int buffBit = int.Parse(split[1]); int value = int.Parse(split[2]); bool stacking = split.Length > 3 && split[3] == "1"; BuffStat buffstat = new BuffStat(buffBit, false, stacking); c.SendPacket(Buff.GiveBuffTestPacket(buffstat, value)); }
public MonsterBuffApplication(BuffStat buffStat, int buffValue, int prop, int durationMS) { Buffs = new Dictionary <BuffStat, int>() { { buffStat, buffValue } }; Prop = prop; Duration = durationMS; }
void CheckAndAddBuffStat(BuffStat buff, CharacterSkillStat stat) { int val; if (Info.TryGetValue(stat, out val)) { BuffInfo.Add(buff, val); } }
private static BuffStat JsonDataToGameData(BuffStatData data) { var buffStatStruct = new BuffStat ( (StatType)data.statId, data.value ); return(buffStatStruct); }
public BuffStat Clone() { BuffStat clone=new BuffStat(); clone.buffID=buffID; clone.damageBuff=damageBuff; clone.cooldownBuff=cooldownBuff; clone.rangeBuff=rangeBuff; clone.regenHP=regenHP; return clone; }
private void ModifyStat(BuffStat statMod) { foreach (var stat in _playerData.Stats.Stats) { if (stat.Value.id == statMod.statId) { stat.Value.value += statMod.value; return; } } }
public MonsterBuff(int ownerId, int skillId, int durationMS, BuffStat buffStat, int buffValue, MapleMonster victim, byte stacks = 0) { OwnerId = ownerId; SkillId = skillId; Duration = durationMS; BuffStat = buffStat; BuffValue = buffValue; Victim = victim; Stacks = stacks; if (buffStat != MonsterBuffStat.POISON) //Poison will remove itself after all ticks { RemoveSchedule = Scheduler.ScheduleRemoveMonsterStatusEffect(this, (uint)durationMS); } }
/// <summary> /// Начать игру с заданным баффом /// </summary> /// <param name="statId">Id характеристики</param> /// <param name="value">Значение баффа</param> public void StartWithMockBuff(int statId, float value) { BuffStat[] newBuff = new BuffStat[] { new BuffStat() { statId = statId, value = value } }; List <Buff> res = new List <Buff> { new Buff() { id = 0, stats = newBuff } }; _player.BeginPlay(MockStats(), res); _enemy.BeginPlay(MockStats(), res); }
public void Buff(BuffStat newBuff) { if (activeBuffList.Contains(newBuff)) { return; } activeBuffList.Add(newBuff); if (unitCreepAttack != null) { unitCreepAttack.damage = unitCreepAttack.damage * (1 + newBuff.damageBuff); unitCreepAttack.range = unitCreepAttack.range * (1 + newBuff.rangeBuff); unitCreepAttack.cooldown = unitCreepAttack.cooldown * (1 - newBuff.cooldownBuff); } if (newBuff.regenHP > 0) { StartCoroutine(RegenHPRoutine(newBuff)); } }
public void ApplyStatusEffect(int sourceSkillId, BuffStat buffStat, int buffValue, int durationMS, MapleCharacter applicant) { lock (Buffs) { List <MonsterBuff> toRemove = new List <MonsterBuff>(); foreach (MonsterBuff buff in Buffs) { if (buff.BuffStat == buffStat) //Mob already has this buff { toRemove.Add(buff); } } foreach (var buff in toRemove) { buff.Dispose(true); } MonsterBuff newEffect = new MonsterBuff(applicant.Id, sourceSkillId, durationMS, buffStat, buffValue, this); Buffs.Add(newEffect); Map.BroadcastPacket(newEffect.GetApplicationPacket()); } }
public void Buff(int buff, BuffStat stat) { switch (stat) { case BuffStat.Power: PowerBuff += buff; break; case BuffStat.Armor: ArmorBuff += buff; break; case BuffStat.Damage: DamageBuff += buff; break; case BuffStat.Speed: SpeedBuff += buff; break; } }
/// <summary> /// Called to Buff/DeBuff an unit /// </summary> /// <param name="uniteDamageable">unit target by the methode</param> /// <param name="state">use to check if its a buff or a debuff</param> private void SetASBuff(IDamageable uniteDamageable, BuffStat state) { if (uniteDamageable == null) { Debug.Log("Something wrong happened"); return; } switch (state) { case BuffStat.Buff: { uniteDamageable.AddBuff("SupportTowerBuffAS", aSModifier, BuffType.ASBoost); } break; case BuffStat.DeBuff: { uniteDamageable.RemoveBuff("SupportTowerBuffAS", aSModifier, BuffType.ASBoost); } break; } }
/// <summary> /// Fonction called to boost/unboost AttackSpeed of an ally /// </summary> /// <param name="ally">the Unit that is buffed/unbuffed</param> /// <param name="state">specify if it's a buff or a debuff</param> private void SetASBuff(Unit ally, BuffStat state) { if (ally == null || ally.isDead) { Debug.Log("Something wrong happened"); return; } switch (state) { case BuffStat.Buff: { ally.AddBuff("SupportTowerBuffAS", aSModifier, BuffType.ASBoost); } break; case BuffStat.DeBuff: { ally.RemoveBuff("SupportTowerBuffAS", aSModifier, BuffType.ASBoost); } break; } }
public void BeginPlay(List <Stat> startStats, List <Buff> startBuffs) { //Сброс _currentStats = new Dictionary <int, float>(); _buffs = new List <Buff>(startBuffs); _animator.SetBool(GameConst.AttackParameter, false); //Заполняем словарь начальными значениями startStats.ForEach(x => SetCurrentStat(x)); _animator.SetInteger(GameConst.HealthParameter, (int)HP); //Вычисляем влияние баффов for (int i = 0; i < startBuffs.Count; i++) { Buff buff = startBuffs[i]; for (int j = 0; j < buff.stats.Length; j++) { BuffStat buffStat = buff.stats[j]; //Находим стату по id и складываем float oldValue; if (_currentStats.TryGetValue(buffStat.statId, out oldValue)) { _currentStats[buffStat.statId] = oldValue + buffStat.value; _signalBus.Fire(new CharacterStatChangedSignal() { StatId = buffStat.statId, Value = _currentStats[buffStat.statId], character = this }); } } } //Переход в состояние покоя ChangeState(StatesEnum.Idle); }
public void AddBuff(BuffStat buffStat, int buffValue = 1) { Buffs.Add(buffStat, buffValue); }
//show to draw the selected tower info panel, which include the upgrade and sell button void SelectedTowerUI() { float startX = Screen.width - 260; float startY = Screen.height - 455 - bottomPanelRect.height; float widthBox = 250; float heightBox = 450; towerUIRect = new Rect(startX, startY, widthBox, heightBox); for (int i = 0; i < 3; i++) { GUI.Box(towerUIRect, ""); } startX = Screen.width - 260 + 20; startY = Screen.height - 455 - bottomPanelRect.height + 20; float width = 250 - 40; float height = 20; GUIStyle tempGUIStyle = new GUIStyle(); tempGUIStyle.fontStyle = FontStyle.Bold; tempGUIStyle.fontSize = 16; tempGUIStyle.normal.textColor = new Color(1, 1, 0, 1f); string towerName = currentSelectedTower.unitName; GUIContent guiContentTitle = new GUIContent(towerName); GUI.Label(new Rect(startX, startY, width, height), guiContentTitle, tempGUIStyle); tempGUIStyle.fontStyle = FontStyle.Bold; tempGUIStyle.fontSize = 13; tempGUIStyle.normal.textColor = new Color(1, 0, 0, 1f); GUI.Label(new Rect(startX, startY += height, width, height), "Level: " + currentSelectedTower.GetLevel().ToString(), tempGUIStyle); startY += 20; string towerInfo = ""; _TowerType type = currentSelectedTower.type; //display relevent information based on tower type if (type == _TowerType.SupportTower) { //show buff info only BuffStat buffInfo = currentSelectedTower.GetBuff(); string buff = ""; if (buffInfo.damageBuff != 0) { buff += "Buff damage by " + (buffInfo.damageBuff * 100).ToString("f1") + "%\n"; } if (buffInfo.rangeBuff != 0) { buff += "Buff range by " + (buffInfo.rangeBuff * 100).ToString("f1") + "%\n"; } if (buffInfo.cooldownBuff != 0) { buff += "Reduce CD by " + (buffInfo.cooldownBuff * 100).ToString("f1") + "%\n"; } if (buffInfo.regenHP != 0) { buff += "Renegerate HP by " + (buffInfo.regenHP).ToString("f1") + " per seconds\n"; } towerInfo += buff; } else if (type == _TowerType.TurretTower || type == _TowerType.AOETower) { //show the basic info for turret and aoeTower if (currentSelectedTower.GetDamage() > 0) { towerInfo += "Damage: " + currentSelectedTower.GetDamage().ToString("f1") + "\n"; } if (currentSelectedTower.GetCooldown() > 0) { towerInfo += "Cooldown: " + currentSelectedTower.GetCooldown().ToString("f1") + "sec\n"; } if (type == _TowerType.TurretTower && currentSelectedTower.GetAoeRadius() > 0) { towerInfo += "AOE Radius: " + currentSelectedTower.GetAoeRadius().ToString("f1") + "\n"; } if (currentSelectedTower.GetStunDuration() > 0) { towerInfo += "Stun target for " + currentSelectedTower.GetStunDuration().ToString("f1") + "sec\n"; } //if the tower have damage over time value, display it Dot dot = currentSelectedTower.GetDot(); float totalDot = dot.damage * (dot.duration / dot.interval); if (totalDot > 0) { string dotInfo = "Cause " + totalDot.ToString("f1") + " damage over the next " + dot.duration + " sec\n"; towerInfo += dotInfo; } //if the tower have slow value, display it Slow slow = currentSelectedTower.GetSlow(); if (slow.duration > 0) { string slowInfo = "Slow target by " + (slow.slowFactor * 100).ToString("f1") + "% for " + slow.duration.ToString("f1") + "sec\n"; towerInfo += slowInfo; } } //show the tower's description towerInfo += "\n\n" + currentSelectedTower.description; GUIContent towerInfoContent = new GUIContent(towerInfo); //draw all the information on screen float contentHeight = GUI.skin.GetStyle("Label").CalcHeight(towerInfoContent, 200); GUI.Label(new Rect(startX, startY += 20, width, contentHeight), towerInfoContent); //reset the draw position startY = Screen.height - 180 - bottomPanelRect.height; if (enableTargetPrioritySwitch) { if (currentSelectedTower.type == _TowerType.TurretTower) { //~ if(currentSelectedTower.targetingArea!=_TargetingArea.StraightLine){ GUI.Label(new Rect(startX, startY, 120, 30), "Targeting Priority:"); if (GUI.Button(new Rect(startX + 120, startY - 3, 100, 30), currentSelectedTower.targetPriority.ToString())) { if (currentSelectedTower.targetPriority == _TargetPriority.Nearest) { currentSelectedTower.SetTargetPriority(1); } else if (currentSelectedTower.targetPriority == _TargetPriority.Weakest) { currentSelectedTower.SetTargetPriority(2); } else if (currentSelectedTower.targetPriority == _TargetPriority.Toughest) { currentSelectedTower.SetTargetPriority(3); } else if (currentSelectedTower.targetPriority == _TargetPriority.Random) { currentSelectedTower.SetTargetPriority(0); } } startY += 30; //~ } } } //check if the tower can be upgrade bool upgradable = false; if (!currentSelectedTower.IsLevelCapped() && currentSelectedTower.IsBuilt()) { upgradable = true; } //reset the draw position startY = Screen.height - 50 - bottomPanelRect.height; //if the tower is eligible to upgrade, draw the upgrade button if (upgradable) { if (GUI.Button(new Rect(startX, startY, 100, 30), new GUIContent("Upgrade", "1"))) { //upgrade the tower, if false is return, player have insufficient fund if (!currentSelectedTower.Upgrade()) { Debug.Log("Insufficient Resource"); } } } //sell button if (currentSelectedTower.IsBuilt()) { if (GUI.Button(new Rect(startX + 110, startY, 100, 30), new GUIContent("Sell", "2"))) { currentSelectedTower.Sell(); } } //if the cursor is hover on the upgrade button, show the cost if (GUI.tooltip == "1") { int[] cost = currentSelectedTower.GetCost(); GUI.Label(new Rect(startX + 10, startY, 150, 25), " - " + cost[0].ToString() + "resource"); } //if the cursor is hover on the sell button, show the resource gain else if (GUI.tooltip == "2") { int[] sellValue = currentSelectedTower.GetTowerSellValue(); GUI.Label(new Rect(startX + 120, startY, 150, 25), " + " + sellValue[0].ToString() + "resource"); } }
private void UpgradeStat() { int levelM=level-1; if(type==_TowerType.TurretTower || type==_TowerType.DirectionalAOETower || type==_TowerType.AOETower){ damage=upgradeStat[levelM].damage; cooldown=upgradeStat[levelM].cooldown; clipSize=upgradeStat[levelM].clipSize; currentClip=clipSize; if(currentClip<=0) currentClip=-1; reloadDuration=upgradeStat[levelM].reloadDuration; range=upgradeStat[levelM].range; minRange=upgradeStat[levelM].minRange; aoeRadius=upgradeStat[levelM].aoeRadius; stunDuration=upgradeStat[levelM].stunDuration; slow=upgradeStat[levelM].slow; dot=upgradeStat[levelM].dot; } else if(type==_TowerType.SupportTower){ buff=upgradeStat[levelM].buff; buff.buffID=towerID; } else if(type==_TowerType.ResourceTower){ incomes=upgradeStat[levelM].incomes; cooldown=upgradeStat[levelM].cooldown; } if(upgradeStat[levelM].shootObject!=null) shootObject=upgradeStat[levelM].shootObject.gameObject; if(upgradeStat[levelM].turretObject!=null){ if(turretObject.childCount>0) turretObject.gameObject.SetActiveRecursively(false); else turretObject.gameObject.active=false; Transform turretTemp=(Transform)Instantiate(upgradeStat[levelM].turretObject); turretTemp.position=turretObject.position; turretTemp.rotation=turretObject.rotation; turretTemp.parent=thisT; turretObject=turretTemp; //turretObject=upgradeStat[levelM].turretObject; UpdateShootPoint(); } if(upgradeStat[levelM].barrelObject!=null){ barrelObject=upgradeStat[levelM].barrelObject; } if(upgradeStat[levelM].baseObject!=null){ if(baseObject.childCount>0) baseObject.gameObject.SetActiveRecursively(false); else baseObject.gameObject.active=false; Transform baseTemp=(Transform)Instantiate(upgradeStat[levelM].baseObject); baseTemp.position=baseObject.position; baseTemp.rotation=baseObject.rotation; baseTemp.parent=thisT; baseObject=baseTemp; //baseObject=upgradeStat[levelM].baseObject; } level+=1; UpdateTowerValue(); GameControl.TowerUpgradeComplete(this); }
public void Buff(BuffStat newBuff) { if(activeBuffList.Contains(newBuff) || type==_TowerType.SupportTower) return; activeBuffList.Add(newBuff); damage=damage*(1+newBuff.damageBuff); range=range*(1+newBuff.rangeBuff); cooldown=cooldown*(1-newBuff.cooldownBuff); if(newBuff.regenHP>0) StartCoroutine(RegenHPRoutine(newBuff)); //if(type==_TowerType.TurretTower) Debug.Log(unitName+" "+newBuff.buffID+" damage: "+damage+" range:"+range+" cooldown:"+cooldown); }
IEnumerator RegenHPRoutine(BuffStat buff) { while(activeBuffList.Contains(buff)){ //HPAttribute.HP=Mathf.Min(HPAttribute.fullHP, HP+); GainHP(Time.deltaTime*buff.regenHP); yield return null; } }
//initialise stat, call when tower is first built private void InitStat() { //level=1; cooldown=baseStat.cooldown; range=baseStat.range; if(type==_TowerType.TurretTower || type==_TowerType.DirectionalAOETower || type==_TowerType.AOETower || type==_TowerType.Mine){ damage=baseStat.damage; clipSize=baseStat.clipSize; currentClip=clipSize; if(currentClip<=0) currentClip=-1; reloadDuration=baseStat.reloadDuration; aoeRadius=baseStat.aoeRadius; stunDuration=baseStat.stunDuration; slow=baseStat.slow; dot=baseStat.dot; } else if(type==_TowerType.SupportTower){ buff=baseStat.buff; } else if(type==_TowerType.ResourceTower){ incomes=baseStat.incomes; } if(baseStat.shootObject!=null){ shootObject=baseStat.shootObject.gameObject; } else{ if(type==_TowerType.TurretTower){ GameObject tempObj = GameObject.CreatePrimitive(PrimitiveType.Sphere); tempObj.AddComponent<ShootObject>(); tempObj.active=false; shootObject=tempObj; } } if(baseStat.turretObject!=null){ turretObject=baseStat.turretObject; } if(baseStat.barrelObject!=null){ barrelObject=baseStat.barrelObject; } //since this is initialization, update shootpoint regardless of if there's a turretObject UpdateShootPoint(); if(baseStat.baseObject!=null){ baseObject=baseStat.baseObject; } UpdateTowerValue(); }
public void Buff(BuffStat newBuff) { if(activeBuffList.Contains(newBuff) || type==_TowerType.SupportTower) return; activeBuffList.Add(newBuff); damage=damage*(1+newBuff.damageBuff); range=range*(1+newBuff.rangeBuff); cooldown=cooldown*(1-newBuff.cooldownBuff); if(newBuff.regenHP>0) StartCoroutine(RegenHPRoutine(newBuff)); }
//~ public int ActivateAbility(Ability ability, Vector3 pos){ public int ActivateAbility(int ID, Vector3 pos) { Ability ability = abilityManager.activeAbilityList[ID]; if (checkedTrigger) { checkedTrigger = false; } else { Debug.Log("Check for a trigger position before you activate ability"); return(-1); } int status = ability.IsReady(abilityManager.energy); if (status != 0) { return(status); } if (ability.energy > 0) { energy -= ability.energy * energyCostModifier - energyCostValue; if (onUpdateEnergyE != null) { onUpdateEnergyE(energy); } } GameControl.SpendResource(ability.costs); //~ if(ability.costs!=null) GameControl.SpendResource(ability.costs); ability.cooldown = ability.cdDuration; //Debug.Log("AbilityManager: "+ability.name+" "+ability.cooldown+" "+ability.cdDuration); //~ Debug.Log(ability.effects.Count); ability.usedCount += 1; if (ability.visualEffect != null) { ObjectPoolManager.Spawn(ability.visualEffect, pos, Quaternion.identity); } foreach (AbilityEffect effect in ability.effects) { //Debug.Log(effect.type+" "+effect.value[0]+" "+effect.value[1]); if (effect.type == _AbilityEffects.AOEDamage) { StartCoroutine(AOEDamage(pos, ability.aoeRange, effect.value[0], 0, ability.launchDelay)); } if (effect.type == _AbilityEffects.AOESlow) { Slow slow = new Slow(); slow.duration = effect.value[0]; slow.slowFactor = effect.value[1]; StartCoroutine(AOESlow(pos, ability.aoeRange, slow, ability.launchDelay)); } if (effect.type == _AbilityEffects.AOEStun) { StartCoroutine(AOEStun(pos, ability.aoeRange, effect.value[0], ability.launchDelay)); } if (effect.type == _AbilityEffects.AOEDotUnit) { Dot dot = new Dot(); dot.duration = effect.value[0]; dot.interval = effect.value[1]; dot.modifier1 = effect.value[2]; StartCoroutine(AOEDotUnit(pos, ability.aoeRange, dot, ability.launchDelay)); } if (effect.type == _AbilityEffects.AOEDotArea) { Dot dot = new Dot(); dot.duration = effect.value[0]; dot.interval = effect.value[1]; dot.modifier1 = effect.value[2]; StartCoroutine(AOEDotArea(pos, ability.aoeRange, dot, ability.launchDelay)); } if (effect.type == _AbilityEffects.AOEArmorReduction) { //~ StartCoroutine(AOEArmorReduction(ability.launchDelay)); } //~ if(effect.type==_AbilityEffects.SingleDamage){ //~ UnitCreep creep=GetCreep(pos); //~ if(creep==null) return -1; //~ creep.ApplyDamage(effect.value[0], 0); //~ } //~ if(effect.type==_AbilityEffects.SingleSlow){ //~ UnitCreep creep=GetCreep(pos); //~ if(creep==null) return -1; //~ Slow slow=new Slow(); //~ slow.duration=effect.value[0]; //~ slow.slowFactor=effect.value[1]; //~ creep.ApplySlow(slow); //~ } //~ if(effect.type==_AbilityEffects.SingleStun){ //~ UnitCreep creep=GetCreep(pos); //~ if(creep==null) return -1; //~ creep.ApplyStun(effect.value[0]); //~ } //~ if(effect.type==_AbilityEffects.SingleDot){ //~ UnitCreep creep=GetCreep(pos); //~ if(creep==null) return -1; //~ Dot dot=new Dot(); //~ dot.duration=effect.value[1]; //~ dot.duration=effect.value[2]; //~ dot.modifier1=effect.value[3]; //~ creep.ApplyDot(dot, 0); //~ } if (effect.type == _AbilityEffects.AOEBoost) { BuffStat buff = new BuffStat(); buff.damageBuff = effect.value[1]; buff.cooldownBuff = effect.value[2]; buff.rangeBuff = effect.value[3]; buff.regenHP = effect.value[4]; StartCoroutine(AOEBuff(pos, ability.aoeRange, effect.value[0], buff, effect.modType, ability.launchDelay)); } if (effect.type == _AbilityEffects.AOERepair) { StartCoroutine(AOERepair(pos, ability.aoeRange, effect.value[0], ability.launchDelay)); } else if (effect.type == _AbilityEffects.AOEShield) { StartCoroutine(AOEShield(pos, ability.aoeRange, effect.value[0], ability.launchDelay)); } } selectedAbilityID = -1; return(0); }
private void UpgradeStat() { int levelM=level-1; if(type==_TowerType.TurretTower || type==_TowerType.DirectionalAOETower || type==_TowerType.AOETower){ damage=upgradeStat[levelM].damage; cooldown=upgradeStat[levelM].cooldown; clipSize=upgradeStat[levelM].clipSize; currentClip=clipSize; if(currentClip<=0) currentClip=-1; reloadDuration=upgradeStat[levelM].reloadDuration; range=upgradeStat[levelM].range; minRange=upgradeStat[levelM].minRange; aoeRadius=upgradeStat[levelM].aoeRadius; stunDuration=upgradeStat[levelM].stunDuration; slow=upgradeStat[levelM].slow; dot=upgradeStat[levelM].dot; } else if(type==_TowerType.SupportTower){ buff=upgradeStat[levelM].buff; buff.buffID=towerID; } else if(type==_TowerType.ResourceTower){ incomes=upgradeStat[levelM].incomes; cooldown=upgradeStat[levelM].cooldown; } if(upgradeStat[levelM].shootObject!=null) shootObject=upgradeStat[levelM].shootObject.gameObject; if(upgradeStat[levelM].turretObject!=null){ if(turretObject.childCount>0) turretObject.gameObject.SetActiveRecursively(false); else turretObject.gameObject.active=false; Transform turretTemp=(Transform)Instantiate(upgradeStat[levelM].turretObject); turretTemp.position=turretObject.position; turretTemp.rotation=turretObject.rotation; turretTemp.parent=thisT; turretObject=turretTemp; //turretObject=upgradeStat[levelM].turretObject; UpdateShootPoint(); Animation tempAni=null; //search for turret build animation component //if there's a build animation clip //~ if(upgradeStat[levelM].turretBuildAnimation!=null){ //~ //if not on the baseObject itself //~ if(upgradeStat[levelM].turretBuildAnimationBody.gameObject!=upgradeStat[levelM].turretObject){ //~ foreach(Transform child in turretObject.transform){ //~ tempAni=(Animation)child.gameObject.GetComponent(typeof(Animation)); //~ if(tempAni!=null){ //~ if(tempAni.gameObject.name==upgradeStat[levelM].turretBuildAnimationBody.gameObject.name){ //~ turretBuildAnimationBody=tempAni; //~ } //~ } //~ } //~ } //~ else{ //~ tempAni=(Animation)turretObject.GetComponent(typeof(Animation)); //~ if(tempAni!=null) turretBuildAnimationBody=tempAni; //~ } //~ //if there's an animation component, assign the animation clip //~ if(tempAni!=null){ //~ turretBuildAnimation=upgradeStat[levelM].turretBuildAnimation; //~ turretBuildAnimationBody.AddClip(turretBuildAnimation, turretBuildAnimation.name); //~ } //~ } tempAni=null; //search for turret build animation component //if there's a build animation clip if(upgradeStat[levelM].turretFireAnimation!=null){ //if not on the baseObject itself if(upgradeStat[levelM].turretFireAnimationBody.gameObject!=upgradeStat[levelM].turretObject){ foreach(Transform child in turretObject.transform){ tempAni=(Animation)child.gameObject.GetComponent(typeof(Animation)); if(tempAni!=null){ if(tempAni.gameObject.name==upgradeStat[levelM].turretFireAnimationBody.gameObject.name){ turretFireAnimationBody=tempAni; } } } } else{ tempAni=(Animation)turretObject.GetComponent(typeof(Animation)); if(tempAni!=null) turretFireAnimationBody=tempAni; } //if there's an animation component, assign the animation clip if(tempAni!=null){ turretFireAnimation=upgradeStat[levelM].turretFireAnimation; turretFireAnimationBody.AddClip(turretFireAnimation, turretFireAnimation.name); } } } if(upgradeStat[levelM].barrelObject!=null){ barrelObject=upgradeStat[levelM].barrelObject; } if(upgradeStat[levelM].baseObject!=null){ if(baseObject.childCount>0) baseObject.gameObject.SetActiveRecursively(false); else baseObject.gameObject.active=false; Transform baseTemp=(Transform)Instantiate(upgradeStat[levelM].baseObject); baseTemp.position=baseObject.position; baseTemp.rotation=baseObject.rotation; baseTemp.parent=thisT; baseObject=baseTemp; //baseObject=upgradeStat[levelM].baseObject; Animation tempAni=null; //search for base animation component //if there's a build animation clip //~ if(upgradeStat[levelM].baseBuildAnimation!=null){ //~ //if not on the baseObject itself //~ if(upgradeStat[levelM].baseBuildAnimationBody.gameObject!=upgradeStat[levelM].baseObject){ //~ foreach(Transform child in baseObject.transform){ //~ tempAni=(Animation)child.gameObject.GetComponent(typeof(Animation)); //~ if(tempAni!=null){ //~ if(tempAni.gameObject.name==upgradeStat[levelM].baseBuildAnimationBody.gameObject.name){ //~ baseBuildAnimationBody=tempAni; //~ } //~ } //~ } //~ } //~ else{ //~ tempAni=(Animation)baseObject.GetComponent(typeof(Animation)); //~ if(tempAni!=null) baseBuildAnimationBody=tempAni; //~ } //~ if(tempAni!=null){ //~ baseBuildAnimation=upgradeStat[levelM].baseBuildAnimation; //~ baseBuildAnimationBody.AddClip(baseBuildAnimation, baseBuildAnimation.name); //~ } //~ } tempAni=null; //search for base animation component //if there's a build animation clip if(upgradeStat[levelM].baseFireAnimation!=null){ //if not on the baseObject itself if(upgradeStat[levelM].baseFireAnimationBody.gameObject!=upgradeStat[levelM].baseObject){ foreach(Transform child in baseObject.transform){ tempAni=(Animation)child.gameObject.GetComponent(typeof(Animation)); if(tempAni!=null){ if(tempAni.gameObject.name==upgradeStat[levelM].baseFireAnimationBody.gameObject.name){ baseFireAnimationBody=tempAni; } } } } else{ tempAni=(Animation)baseObject.GetComponent(typeof(Animation)); if(tempAni!=null) baseFireAnimationBody=tempAni; } if(tempAni!=null){ baseFireAnimation=upgradeStat[levelM].baseFireAnimation; baseFireAnimationBody.AddClip(baseFireAnimation, baseFireAnimation.name); } } } //~ if(upgradeStat[levelM].turretBuildAnimationBody!=null) turretBuildAnimationBody=upgradeStat[levelM].turretBuildAnimationBody; //~ if(upgradeStat[levelM].turretBuildAnimation!=null) turretBuildAnimation=upgradeStat[levelM].turretBuildAnimation; //~ if(upgradeStat[levelM].baseBuildAnimationBody!=null) baseBuildAnimationBody=upgradeStat[levelM].baseBuildAnimationBody; //~ if(upgradeStat[levelM].baseBuildAnimation!=null) baseBuildAnimation=upgradeStat[levelM].baseBuildAnimation; //~ if(upgradeStat[levelM].turretFireAnimationBody!=null) turretFireAnimationBody=upgradeStat[levelM].turretFireAnimationBody; //~ if(upgradeStat[levelM].turretFireAnimation!=null) turretFireAnimation=upgradeStat[levelM].turretFireAnimation; //~ if(upgradeStat[levelM].baseFireAnimationBody!=null) baseFireAnimationBody=upgradeStat[levelM].baseFireAnimationBody; //~ if(upgradeStat[levelM].baseFireAnimation!=null) baseFireAnimation=upgradeStat[levelM].baseFireAnimation; //~ if(turretBuildAnimationBody!=null && turretBuildAnimation!=null) turretBuildAnimationBody.AddClip(turretBuildAnimation, turretBuildAnimation.name); //~ if(baseBuildAnimationBody!=null && baseBuildAnimation!=null) baseBuildAnimationBody.AddClip(baseBuildAnimation, baseBuildAnimation.name); //~ if(turretFireAnimationBody!=null && turretFireAnimation!=null) turretFireAnimationBody.AddClip(turretFireAnimation, turretFireAnimation.name); //~ if(baseFireAnimationBody!=null && baseFireAnimation!=null) baseFireAnimationBody.AddClip(baseFireAnimation, baseFireAnimation.name); level+=1; UpdateTowerValue(); GameControl.TowerUpgradeComplete(this); }