IEnumerator MineRoutine() { LayerMask maskTarget = 1 << TDTK.GetLayerCreep(); while (true) { if (!destroyed && !IsInConstruction()) { Collider[] cols = Physics.OverlapSphere(thisT.position, GetRange(), maskTarget); if (cols.Length > 0) { List <Unit> targetList = TDTK.GetUnitInRange(thisT.position, GetAOERadius(), maskTarget); for (int i = 0; i < targetList.Count; i++) { AttackInstance attInstance = new AttackInstance(this, targetList[i]); attInstance.Process(); targetList[i].ApplyEffect(attInstance); } SpawnEffectObject(); Destroyed(); } } yield return(new WaitForSeconds(0.1f)); } }
void Hit() { hit = true; if (hitEffect != null) { ObjectPoolManager.Spawn(hitEffect, targetPos, Quaternion.identity); } //thisT.position=targetPos; attInstance.impactPoint = targetPos; if (attInstance.srcUnit.GetAOERadius() > 0) { LayerMask mask = attInstance.srcUnit.GetTargetMask(); Collider[] cols = Physics.OverlapSphere(targetPos, attInstance.srcUnit.GetAOERadius(), mask); if (cols.Length > 0) { List <Unit> tgtList = new List <Unit>(); for (int i = 0; i < cols.Length; i++) { Unit unit = cols[i].gameObject.GetComponent <Unit>(); if (!unit.dead) { tgtList.Add(unit); } } if (tgtList.Count > 0) { for (int i = 0; i < tgtList.Count; i++) { if (tgtList[i] == target) { target.ApplyEffect(attInstance); } else { AttackInstance attInst = new AttackInstance(); attInst.srcUnit = attInstance.srcUnit; attInst.tgtUnit = tgtList[i]; attInst.Process(); tgtList[i].ApplyEffect(attInst); } } } } } else { if (target != null) { target.ApplyEffect(attInstance); } } ObjectPoolManager.Unspawn(thisObj); //Destroy(thisObj); }
public IEnumerator TurretRoutine() { for (int i = 0; i < shootPoints.Count; i++) { if (shootPoints[i] == null) { shootPoints.RemoveAt(i); i -= 1; } } if (shootPoints.Count == 0) { shootPoints.Add(thisT); } yield return(null); while (true) { while (target == null || stunned || IsInConstruction() || !targetInLOS) { yield return(null); } turretOnCooldown = true; float animationDelay = 0; if (playShootAnimation != null) { animationDelay = playShootAnimation(); } if (animationDelay > 0) { yield return(new WaitForSeconds(animationDelay)); } AttackInstance attInstance = new AttackInstance(); attInstance.srcUnit = this; attInstance.tgtUnit = target; attInstance.Process(); for (int i = 0; i < shootPoints.Count; i++) { _shootTf = (Transform)Instantiate(GetShootObjectT(), shootPoints[i].position, shootPoints[i].rotation); _shootObj = _shootTf.GetComponent <ShootObject>(); _shootObj.Shoot(attInstance, shootPoints[i]); if (delayBetweenShootPoint > 0) { yield return(new WaitForSeconds(delayBetweenShootPoint)); } } yield return(new WaitForSeconds(GetCooldown() - animationDelay - shootPoints.Count * delayBetweenShootPoint)); turretOnCooldown = false; } }
IEnumerator AOETowerRoutine() { if (targetMode == _TargetMode.Hybrid) { LayerMask mask1 = 1 << LayerManager.LayerCreep(); LayerMask mask2 = 1 << LayerManager.LayerCreepF(); maskTarget = mask1 | mask2; } else if (targetMode == _TargetMode.Air) { maskTarget = 1 << LayerManager.LayerCreepF(); } else if (targetMode == _TargetMode.Ground) { maskTarget = 1 << LayerManager.LayerCreep(); } while (true) { yield return(new WaitForSeconds(GetCooldown())); while (stunned || IsInConstruction()) { yield return(null); } Transform soPrefab = GetShootObjectT(); if (soPrefab != null) { Instantiate(soPrefab, thisT.position, thisT.rotation); } Collider[] cols = Physics.OverlapSphere(thisT.position, GetRange(), maskTarget); if (cols.Length > 0) { for (int i = 0; i < cols.Length; i++) { Unit unit = cols[i].transform.GetComponent <Unit>(); if (unit == null && !unit.dead) { continue; } AttackInstance attInstance = new AttackInstance(); attInstance.srcUnit = this; attInstance.tgtUnit = unit; attInstance.Process(); unit.ApplyEffect(attInstance); } } } }
void FPSHit(Unit hitUnit, Vector3 hitPoint) { if (attInstance.srcWeapon.GetAOERange() > 0) { LayerMask mask1 = 1 << TDTK.GetLayerCreep(); LayerMask mask2 = 1 << TDTK.GetLayerCreepF(); LayerMask mask = mask1 | mask2; Collider[] cols = Physics.OverlapSphere(hitPoint, attInstance.srcWeapon.GetAOERange(), mask); if (cols.Length > 0) { List <Unit> tgtList = new List <Unit>(); for (int i = 0; i < cols.Length; i++) { Unit unit = cols[i].gameObject.GetComponent <Unit>(); if (!unit.IsDestroyed()) { tgtList.Add(unit); } } if (tgtList.Count > 0) { for (int i = 0; i < tgtList.Count; i++) { AttackInstance attInst = new AttackInstance(); attInst.srcWeapon = attInstance.srcWeapon; attInst.tgtUnit = tgtList[i]; attInst.Process(); tgtList[i].ApplyEffect(attInst); } } } } else { if (hitUnit != null && hitUnit.IsCreep()) { attInstance.tgtUnit = hitUnit; attInstance.Process(); hitUnit.ApplyEffect(attInstance); } } }
IEnumerator MineRoutine() { LayerMask maskTarget = 1 << LayerManager.LayerCreep(); while (true) { if (!dead && !IsInConstruction()) { Collider[] cols = Physics.OverlapSphere(thisT.position, GetRange(), maskTarget); if (cols.Length > 0) { Collider[] colls = Physics.OverlapSphere(thisT.position, GetAOERadius(), maskTarget); for (int i = 0; i < colls.Length; i++) { Unit unit = colls[i].transform.GetComponent <Unit>(); if (unit == null && !unit.dead) { continue; } AttackInstance attInstance = new AttackInstance(); attInstance.srcUnit = this; attInstance.tgtUnit = unit; attInstance.Process(); unit.ApplyEffect(attInstance); } Transform soPrefab = GetShootObjectT(); if (soPrefab != null) { Instantiate(soPrefab, thisT.position, thisT.rotation); } Dead(); } } yield return(new WaitForSeconds(0.1f)); } }
IEnumerator AOETowerRoutine() { while (true) { yield return(new WaitForSeconds(GetCooldown())); while (stunned || IsInConstruction()) { yield return(null); } List <Unit> targetList = TDTK.GetUnitInRange(thisT.position, GetRange(), maskTarget); for (int i = 0; i < targetList.Count; i++) { AttackInstance attInstance = new AttackInstance(this, targetList[i]); attInstance.Process(); targetList[i].ApplyEffect(attInstance); } SpawnEffectObject(); } }
IEnumerator AOETowerRoutine() { if (targetMode == _TargetMode.Hybrid) { LayerMask mask1 = 1 << LayerManager.LayerCreep(); LayerMask mask2 = 1 << LayerManager.LayerCreepF(); maskTarget = mask1 | mask2; } else if (targetMode == _TargetMode.Air) { maskTarget = 1 << LayerManager.LayerCreepF(); } else if (targetMode == _TargetMode.Ground) { maskTarget = 1 << LayerManager.LayerCreep(); } UnitTower electricitySource; while (true) { yield return new WaitForSeconds(GetCooldown()); while (stunned || IsInConstruction()) yield return null; // disable shooting while there is no electricity electricitySource = getElectricitySource(GetElectricityNeedForShoot()); while (electricitySource == null) { // Paint deactivated towers black for (int i = 0; i < myRenderers.Length; i++) { myRenderers[i].material.color = new Color(0.2f, 0.2f, 0.2f); } electricitySource = getElectricitySource(GetElectricityNeedForShoot()); yield return null; } // Restore original color for (int i = 0; i < myRenderers.Length; i++) { myRenderers[i].material.color = myRenderersColors[i]; } Transform soPrefab = GetShootObjectT(); if (soPrefab != null) Instantiate(soPrefab, thisT.position, thisT.rotation); Collider[] cols = Physics.OverlapSphere(thisT.position, GetRange(), maskTarget); if (electricitySource != null && !electricitySource.dead && cols.Length > 0) { // target will shoot so take that energy electricitySource.electricityCurrentlyStored -= GetElectricityNeedForShoot(); for (int i = 0; i < cols.Length; i++) { Unit unit = cols[i].transform.GetComponent<Unit>(); if (unit == null && !unit.dead) continue; AttackInstance attInstance = new AttackInstance(); attInstance.srcUnit = this; attInstance.tgtUnit = unit; attInstance.Process(); unit.ApplyEffect(attInstance); } } } }
IEnumerator AOETowerRoutine() { if(targetMode==_TargetMode.Hybrid){ LayerMask mask1=1<<LayerManager.LayerCreep(); LayerMask mask2=1<<LayerManager.LayerCreepF(); maskTarget=mask1 | mask2; } else if(targetMode==_TargetMode.Air){ maskTarget=1<<LayerManager.LayerCreepF(); } else if(targetMode==_TargetMode.Ground){ maskTarget=1<<LayerManager.LayerCreep(); } while(true){ yield return new WaitForSeconds(GetCooldown()); while(stunned || IsInConstruction()) yield return null; Transform soPrefab=GetShootObjectT(); if(soPrefab!=null) Instantiate(soPrefab, thisT.position, thisT.rotation); Collider[] cols=Physics.OverlapSphere(thisT.position, GetRange(), maskTarget); if(cols.Length>0){ for(int i=0; i<cols.Length; i++){ Unit unit=cols[i].transform.GetComponent<Unit>(); if(unit==null && !unit.dead) continue; AttackInstance attInstance=new AttackInstance(); attInstance.srcUnit=this; attInstance.tgtUnit=unit; attInstance.Process(); unit.ApplyEffect(attInstance); } } } }
void Hit() { hit=true; if(hitEffect!=null) ObjectPoolManager.Spawn(hitEffect, targetPos, Quaternion.identity); //thisT.position=targetPos; attInstance.impactPoint=targetPos; if(attInstance.srcUnit.GetAOERadius()>0){ LayerMask mask=attInstance.srcUnit.GetTargetMask(); Collider[] cols=Physics.OverlapSphere(targetPos, attInstance.srcUnit.GetAOERadius(), mask); if(cols.Length>0){ List<Unit> tgtList=new List<Unit>(); for(int i=0; i<cols.Length; i++){ Unit unit=cols[i].gameObject.GetComponent<Unit>(); if(!unit.dead) tgtList.Add(unit); } if(tgtList.Count>0){ for(int i=0; i<tgtList.Count; i++){ if(tgtList[i]==target){ target.ApplyEffect(attInstance); if(attInstance.destroy && destroyEffect!=null) ObjectPoolManager.Spawn(destroyEffect, targetPos, Quaternion.identity); } else{ AttackInstance attInst=new AttackInstance(); attInst.srcUnit=attInstance.srcUnit; attInst.tgtUnit=tgtList[i]; attInst.Process(); tgtList[i].ApplyEffect(attInst); if(attInst.destroy && destroyEffect!=null) ObjectPoolManager.Spawn(destroyEffect, tgtList[i].thisT.position, Quaternion.identity); } } } } } else{ if(target!=null) target.ApplyEffect(attInstance); if(attInstance.destroy && destroyEffect!=null) ObjectPoolManager.Spawn(destroyEffect, targetPos, Quaternion.identity); } ObjectPoolManager.Unspawn(thisObj); //Destroy(thisObj); }
void FPSHit(Unit hitUnit, Vector3 hitPoint) { if(attInstance.srcWeapon.GetAOERange()>0){ LayerMask mask1=1<<LayerManager.LayerCreep(); LayerMask mask2=1<<LayerManager.LayerCreepF(); LayerMask mask = mask1 | mask2; Collider[] cols=Physics.OverlapSphere(hitPoint, attInstance.srcWeapon.GetAOERange(), mask); if(cols.Length>0){ List<Unit> tgtList=new List<Unit>(); for(int i=0; i<cols.Length; i++){ Unit unit=cols[i].gameObject.GetComponent<Unit>(); if(!unit.dead) tgtList.Add(unit); } if(tgtList.Count>0){ for(int i=0; i<tgtList.Count; i++){ AttackInstance attInst=new AttackInstance(); attInst.srcWeapon=attInstance.srcWeapon; attInst.tgtUnit=tgtList[i]; attInst.Process(); tgtList[i].ApplyEffect(attInst); } } } } else{ if(hitUnit!=null && hitUnit.IsCreep()){ attInstance.tgtUnit=hitUnit; attInstance.Process(); hitUnit.ApplyEffect(attInstance); } } }
IEnumerator AOETowerRoutine() { if (targetMode == _TargetMode.Hybrid) { LayerMask mask1 = 1 << LayerManager.LayerCreep(); LayerMask mask2 = 1 << LayerManager.LayerCreepF(); maskTarget = mask1 | mask2; } else if (targetMode == _TargetMode.Air) { maskTarget = 1 << LayerManager.LayerCreepF(); } else if (targetMode == _TargetMode.Ground) { maskTarget = 1 << LayerManager.LayerCreep(); } UnitTower electricitySource; while (true) { yield return(new WaitForSeconds(GetCooldown())); while (stunned || IsInConstruction()) { yield return(null); } // disable shooting while there is no electricity electricitySource = getElectricitySource(GetElectricityNeedForShoot()); while (electricitySource == null) { // Paint deactivated towers black for (int i = 0; i < myRenderers.Length; i++) { myRenderers[i].material.color = new Color(0.2f, 0.2f, 0.2f); } electricitySource = getElectricitySource(GetElectricityNeedForShoot()); yield return(null); } // Restore original color for (int i = 0; i < myRenderers.Length; i++) { myRenderers[i].material.color = myRenderersColors[i]; } Transform soPrefab = GetShootObjectT(); if (soPrefab != null) { Instantiate(soPrefab, thisT.position, thisT.rotation); } Collider[] cols = Physics.OverlapSphere(thisT.position, GetRange(), maskTarget); if (electricitySource != null && !electricitySource.dead && cols.Length > 0) { // target will shoot so take that energy electricitySource.electricityCurrentlyStored -= GetElectricityNeedForShoot(); for (int i = 0; i < cols.Length; i++) { Unit unit = cols[i].transform.GetComponent <Unit>(); if (unit == null && !unit.dead) { continue; } AttackInstance attInstance = new AttackInstance(); attInstance.srcUnit = this; attInstance.tgtUnit = unit; attInstance.Process(); unit.ApplyEffect(attInstance); } } } }
public IEnumerator TurretRoutine() { for(int i=0; i<shootPoints.Count; i++){ if(shootPoints[i]==null){ shootPoints.RemoveAt(i); i-=1; } } if(shootPoints.Count==0){ Debug.LogWarning("ShootPoint not assigned for unit - "+unitName+", auto assigned", this); shootPoints.Add(thisT); } for(int i=0; i<stats.Count; i++){ if(stats[i].shootObjectT!=null) ObjectPoolManager.New(stats[i].shootObjectT.gameObject, 3); } yield return null; float t = Time.time; while(true){ while (shootingTime == 0 || target==null || stunned || IsInConstruction() || !targetInLOS) yield return null; turretOnCooldown=true; Unit currentTarget=target; float animationDelay=0; if(playShootAnimation!=null) animationDelay=playShootAnimation(); if(animationDelay>0) yield return new WaitForSeconds(animationDelay); AttackInstance attInstance=new AttackInstance(); attInstance.srcUnit=this; attInstance.tgtUnit=currentTarget; attInstance.Process(); for(int i=0; i<shootPoints.Count; i++){ Transform sp=shootPoints[i]; Transform objT = null; if (usePoolForShootObjects) { objT = (Transform)ObjectPoolManager.Spawn(GetShootObjectT(), sp.position, sp.rotation); } else { objT = (Transform)Instantiate(GetShootObjectT(), sp.position, sp.rotation); } ShootObject shootObj=objT.GetComponent<ShootObject>(); shootObj.Shoot(attInstance, sp); if(delayBetweenShootPoint>0) yield return new WaitForSeconds(delayBetweenShootPoint); } yield return new WaitForSeconds(GetCooldown()-animationDelay-shootPoints.Count*delayBetweenShootPoint); if(GameControl.ResetTargetAfterShoot()) target=null; turretOnCooldown=false; } }
public IEnumerator TurretRoutine() { for (int i = 0; i < shootPoints.Count; i++) { if (shootPoints[i] == null) { shootPoints.RemoveAt(i); i -= 1; } } if (shootPoints.Count == 0) { Debug.LogWarning("ShootPoint not assigned for unit - " + unitName + ", auto assigned", this); shootPoints.Add(thisT); } for (int i = 0; i < stats.Count; i++) { if (stats[i].shootObject != null) { ObjectPoolManager.New(stats[i].shootObject.gameObject, 3); } } yield return(null); while (true) { while (target == null || stunned || IsInConstruction() || !targetInLOS) { yield return(null); } turretOnCooldown = true; Unit currentTarget = target; float animationDelay = PlayAnimAttack(); if (animationDelay > 0) { yield return(new WaitForSeconds(animationDelay)); } AttackInstance attInstance = new AttackInstance(); attInstance.srcUnit = this; attInstance.tgtUnit = currentTarget; attInstance.Process(); for (int i = 0; i < shootPoints.Count; i++) { Transform sp = shootPoints[i]; //Transform objT=(Transform)Instantiate(GetShootObjectT(), sp.position, sp.rotation); GameObject sObj = ObjectPoolManager.Spawn(GetShootObject().gameObject, sp.position, sp.rotation); ShootObject shootObj = sObj.GetComponent <ShootObject>(); shootObj.Shoot(attInstance, sp); if (delayBetweenShootPoint > 0) { yield return(new WaitForSeconds(delayBetweenShootPoint)); } } yield return(new WaitForSeconds(GetCooldown() - animationDelay - shootPoints.Count * delayBetweenShootPoint)); if (GameControl.ResetTargetAfterShoot()) { target = null; } turretOnCooldown = false; } }
public IEnumerator TurretRoutine() { for (int i = 0; i < shootPoints.Count; i++) { if (shootPoints[i] == null) { shootPoints.RemoveAt(i); i -= 1; } } if (shootPoints.Count == 0) { Debug.LogWarning("ShootPoint not assigned for unit - " + unitName + ", auto assigned", this); shootPoints.Add(thisT); } for (int i = 0; i < stats.Count; i++) { if (stats[i].shootObjectT != null) ObjectPoolManager.New(stats[i].shootObjectT.gameObject, 3); } yield return null; UnitTower electricitySource; while (true) { // disable shooting while there is no electricity electricitySource = getElectricitySource(GetElectricityNeedForShoot()); while (electricitySource == null) { // Paint deactivated towers black for (int i = 0; i < myRenderers.Length; i++) { myRenderers[i].material.color = new Color(0.2f, 0.2f, 0.2f); } electricitySource = getElectricitySource(GetElectricityNeedForShoot()); yield return null; } // Restore original color for (int i = 0; i < myRenderers.Length; i++) { myRenderers[i].material.color = myRenderersColors[i]; } // target will shoot so take that energy if (electricitySource != null) electricitySource.electricityCurrentlyStored -= GetElectricityNeedForShoot(); while (target == null || stunned || IsInConstruction() || !targetInLOS) yield return null; if (!electricitySource.dead) { Unit currentTarget = target; float animationDelay = 0; if (playShootAnimation != null) animationDelay = playShootAnimation(); if (animationDelay > 0) yield return new WaitForSeconds(animationDelay); AttackInstance attInstance = new AttackInstance(); attInstance.srcUnit = this; attInstance.tgtUnit = currentTarget; attInstance.Process(); for (int i = 0; i < shootPoints.Count; i++) { Transform sp = shootPoints[i]; Transform objT = (Transform)Instantiate(GetShootObjectT(), sp.position, sp.rotation); ShootObject shootObj = objT.GetComponent<ShootObject>(); shootObj.Shoot(attInstance, sp); if (delayBetweenShootPoint > 0) yield return new WaitForSeconds(delayBetweenShootPoint); } yield return new WaitForSeconds(GetCooldown() - animationDelay - shootPoints.Count * delayBetweenShootPoint); } } }
public IEnumerator TurretRoutine() { for (int i = 0; i < shootPoints.Count; i++) { if (shootPoints[i] == null) { shootPoints.RemoveAt(i); i -= 1; } } if (shootPoints.Count == 0) { Debug.LogWarning("ShootPoint not assigned for unit - " + unitName + ", auto assigned", this); shootPoints.Add(thisT); } for (int i = 0; i < stats.Count; i++) { if (stats[i].shootObjectT != null) { ObjectPoolManager.New(stats[i].shootObjectT.gameObject, 3); } } yield return(null); UnitTower electricitySource; while (true) { // disable shooting while there is no electricity electricitySource = getElectricitySource(GetElectricityNeedForShoot()); while (electricitySource == null) { // Paint deactivated towers black for (int i = 0; i < myRenderers.Length; i++) { myRenderers[i].material.color = new Color(0.2f, 0.2f, 0.2f); } electricitySource = getElectricitySource(GetElectricityNeedForShoot()); yield return(null); } // Restore original color for (int i = 0; i < myRenderers.Length; i++) { myRenderers[i].material.color = myRenderersColors[i]; } // target will shoot so take that energy if (electricitySource != null) { electricitySource.electricityCurrentlyStored -= GetElectricityNeedForShoot(); } while (target == null || stunned || IsInConstruction() || !targetInLOS) { yield return(null); } if (!electricitySource.dead) { Unit currentTarget = target; float animationDelay = 0; if (playShootAnimation != null) { animationDelay = playShootAnimation(); } if (animationDelay > 0) { yield return(new WaitForSeconds(animationDelay)); } AttackInstance attInstance = new AttackInstance(); attInstance.srcUnit = this; attInstance.tgtUnit = currentTarget; attInstance.Process(); for (int i = 0; i < shootPoints.Count; i++) { Transform sp = shootPoints[i]; Transform objT = (Transform)Instantiate(GetShootObjectT(), sp.position, sp.rotation); ShootObject shootObj = objT.GetComponent <ShootObject>(); shootObj.Shoot(attInstance, sp); if (delayBetweenShootPoint > 0) { yield return(new WaitForSeconds(delayBetweenShootPoint)); } } yield return(new WaitForSeconds(GetCooldown() - animationDelay - shootPoints.Count * delayBetweenShootPoint)); } } }
IEnumerator MineRoutine() { LayerMask maskTarget=1<<LayerManager.LayerCreep(); while(true){ if(!dead && !IsInConstruction()){ Collider[] cols=Physics.OverlapSphere(thisT.position, GetRange(), maskTarget); if(cols.Length>0){ Collider[] colls=Physics.OverlapSphere(thisT.position, GetAOERadius(), maskTarget); for(int i=0; i<colls.Length; i++){ Unit unit=colls[i].transform.GetComponent<Unit>(); if(unit==null && !unit.dead) continue; AttackInstance attInstance=new AttackInstance(); attInstance.srcUnit=this; attInstance.tgtUnit=unit; attInstance.Process(); unit.ApplyEffect(attInstance); } Transform soPrefab=GetShootObjectT(); if(soPrefab!=null) Instantiate(soPrefab, thisT.position, thisT.rotation); Dead(); } } yield return new WaitForSeconds(0.1f); } }