void Awake(){ instance = (ShootObject)target; if(!init) Init(); EditorUtility.SetDirty(instance); }
public virtual void Awake() { thisObj = gameObject; thisT = transform; if (shootPoints.Count == 0) { shootPoints.Add(thisT); } ResetBuff(); for (int i = 0; i < stats.Count; i++) { if (stats[i].shootObject != null) { stats[i].shootObjectT = stats[i].shootObject.transform; if (localShootObject == null) { localShootObject = stats[i].shootObject; } } if (stats[i].shootObjectT != null) { if (localShootObjectT == null) { localShootObjectT = stats[i].shootObjectT; } } } }
public override void Awake() { base.Awake(); instance = (ShootObject)target; InitLabel(); }
IEnumerator Shoot(AttackInfo aInfo) { float attackDelay = AnimPlayAttack(); if (attackDelay > 0) { yield return(new WaitForSeconds(attackDelay)); } for (int i = 0; i < shootPoint.Count; i++) { //GameObject sObj=(GameObject)Instantiate(shootObject.gameObject, shootPoint[i].position, Quaternion.identity); GameObject sObj = ObjectPoolManager.Spawn(shootObject.gameObject, shootPoint[i].position, Quaternion.identity); ShootObject soInstance = sObj.GetComponent <ShootObject>(); if (i == shootPoint.Count - 1) { soInstance.InitShoot(aInfo); } else { soInstance.InitShoot(aInfo.tgtUnit); } yield return(new WaitForSeconds(shootPointSpacing)); } }
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; } }
void Awake() { instance = (ShootObject)target; if (!init) { Init(); } EditorUtility.SetDirty(instance); }
public virtual void Awake() { thisObj=gameObject; thisT=transform; if(shootPoints.Count==0) shootPoints.Add(thisT); ResetBuff(); for(int i=0; i<stats.Count; i++){ if(stats[i].shootObject!=null){ stats[i].shootObjectT=stats[i].shootObject.transform; if(localShootObject==null) localShootObject=stats[i].shootObject; } if(stats[i].shootObjectT!=null){ if(localShootObjectT==null) localShootObjectT=stats[i].shootObjectT; } } }
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; } }
void Awake() { instance = (ShootObject)target; InitLabel(); }
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)); } } }