void FinishAttack() { //Play the attack audio: AudioManager.PlayAudio(gameObject, AttackSound, false); AttackTimer = AttackReload; CanPlayAnim = true; //If this not the basic attack then revert back to the basic attack after done if (BasicAttack == false && MultipleAttacksMgr != null) { //If this feature is actually enabled: if (MultipleAttacksMgr.SwitchBackToBasic == true) { MultipleAttacksMgr.EnableAttackType(MultipleAttacksMgr.BasicAttackID); } } //Cooldown: StartCoolDown(); //Attack once? cancel attack to prevent source from attacking again if (AttackOnce == true) { CancelAttack(); } ReloadAttackDelay(); }
//a method to laucnh a direct attack void LaunchDirectAttack() { if (AreaDamage == true) { //launch area damage and provide all arguments: AttackMgr.LaunchAreaDamage(AttackTarget.transform.position, this); } else { //Custom event: if (GameMgr.Events) { GameMgr.Events.OnAttackPerformed(this, AttackTarget); } if (DealDamage == true) //Can this attack deal damage directly? { if (DoT.Enabled == true) { //only for units currently? if (TargetUnit) { ConfigureTargetDoT(TargetUnit, AttackManager.GetDamage(AttackTarget, CustomDamage, UnitDamage)); } } else { //if this is no areal damage and no DoT //deal damage to unit/building: if (TargetUnit) { TargetUnit.AddHealth(-AttackManager.GetDamage(AttackTarget, CustomDamage, UnitDamage), this.gameObject); //Spawning the damage effect object: AttackMgr.SpawnEffectObj(TargetUnit.DamageEffect, AttackTarget, 0.0f, true); //spawn attack effect object: units only currently AttackMgr.SpawnEffectObj(AttackEffect, AttackTarget, AttackEffectTime, false); } else if (TargetBuilding) { TargetBuilding.AddHealth(-AttackManager.GetDamage(AttackTarget, CustomDamage, BuildingDamage), this.gameObject); //Spawning the damage effect object: AttackMgr.SpawnEffectObj(TargetBuilding.DamageEffect, AttackTarget, 0.0f, true); } } } } //Play the attack audio: AudioManager.PlayAudio(gameObject, AttackSound, false); AttackTimer = AttackReload; CanPlayAnim = true; //If this not the basic attack then revert back to the basic attack after done if (BasicAttack == false && MultipleAttacksMgr != null) { MultipleAttacksMgr.EnableAttackType(MultipleAttacksMgr.BasicAttackID); } //Cooldown: StartCoolDown(); //Attack once? cancel attack to prevent source from attacking again if (AttackOnce == true) { CancelAttack(); } ReloadAttackDelay(); }