/// <summary> /// Routine to perfome a attack animation /// </summary> /// <returns>IEnumerator is needed for co-routines.<</returns> /// <param name="target">The BUnit whom is the attack target.</param> /// <param name="attack">The attack which will be performed.</param> /// <param name="efficeny">0 = not effectiv, 1 = normal efficeny, 2 = very effectiv</param> /// <param name="damage">The amount of damage dealt by this attack.</param> public IEnumerator AttackRoutine(UnitAttackedEvent e, BMapTile target, BUnit[] victims, BCombatMenu bCombatMenu) { meshContainer.transform.LookAt(target.transform.position); bCombatMenu.Hide(); // sound effect attackSound.Play(); // animation animator.SetTrigger("AttackTrigger"); // wait some time before starting the attack effect yield return(new WaitForSeconds(e.attack.effectDelay)); // caluclate the direction of the attack and project it on one of the 4 vectors: (0,1),(1,0),(0,-1),(-1,0) Vector direction = new Vector(Mathf.FloorToInt(target.transform.position.x - this.transform.position.x), Mathf.FloorToInt(target.transform.position.z - this.transform.position.z)); direction.NormalizeTo4Direction(); BParticleManager.PlayEffect(e.attack.attackName, target.transform.position, new Vector3(direction.x, 0, direction.y)); // wait some time before trigger the hit animtion/effect yield return(new WaitForSeconds(e.attack.hitDelay)); for (int i = 0; i < victims.Length; i++) { victims[i].PlayHitAnimation(e.efficiency, e.damage[i]); victims[i].unitUI.ShowDamage(e.damage[i]); } // wait the rest of the time for the animation before contuine with next event yield return(new WaitForSeconds(e.attack.fullAnimationTime - e.attack.effectDelay - e.attack.hitDelay)); EventProxyManager.FireEvent(this, new EventDoneEvent()); }
/// <summary> /// Change color of all MapTile to default. /// </summary> public void CleanMap() { // reset color state of all maptiles for (int i = 0; i < bMap.lengthX; i++) { for (int j = 0; j < bMap.lengthY; j++) { bMap[i, j].ChangeColorState(BMapTile.ColorState.DEFAULT); } } BParticleManager.DisbaleEffect("FieldMarker"); }
void Awake() { for (int k = 0; k < particles.Length; k++) { Queue <GameObject> particleQueue = new Queue <GameObject>(); particleQueue.Enqueue(particles[k]); // create copies of the particle game object and add them to an queue for (int i = 0; i < particleCloneCounts[k] - 1; i++) { GameObject handle = (GameObject)Instantiate(particles[k]); handle.transform.parent = this.transform; particleQueue.Enqueue(handle); } particleSystems.Add(particles[k].name, particleQueue); } instance = this; }
public IEnumerator DamageFlashRoutine() { BParticleManager.PlayEffect("HitEffect", this.transform.position); animator.SetTrigger("DamagedTrigger"); yield return(new WaitForSeconds(0.5f)); }
/// <summary> /// Place a marker on the given BMapTile /// </summary> /// <param name="bMapTile">BMapTile.</param> public void SetFieldMarker(BMapTile bMapTile) { BParticleManager.PlayEffect("FieldMarker", bMapTile.transform.position); }
public static void PlayEffect(string particleName, Vector3 pos) { BParticleManager.PlayEffect(particleName, pos, new Vector3(1, 0)); }