public void DamageEnemy() { for (int j = 0; j < targets.Count; j++) { LevelAgent pc = targets[j]; if (pc != null) { int damage = skillDamages[j].damage; int heal = skillDamages[j].heal; IAlignmentProvider alignment = skillDamages[j].alignment; if (heal > 0) { pc.Cure(heal, pc.position, alignment); } else { if (isAOE) { IsAOE(pc, damage, alignment); } else { pc.OnSkillDamageTaken(damage, pc.position, alignment, true, null, ""); } } } } if (isOver != null) { isOver(this); } }
public DamageInfo(int damage, int heal, List <BuffInfo> buffInfos, IAlignmentProvider alignment) { this.damage = damage; this.heal = heal; this.buffInfos = buffInfos; this.alignment = alignment; }
/// <summary> /// 伤害 /// </summary> public bool Damage(float damageValue, Vector3 damagePoint, IAlignmentProvider alignment) { // We don't want to enable this state if the FSM is dead //GotHitState gotHitState = GetState<GotHitState>(); //if ( gotHitState != null && gotHitState.CanGetHit(this) ) //{ //SubtractHealthValue(totalDamage); //if ( gotHitState.CoolDownFinished() ) //{ // ChangeActiveState(gotHitState); //} //} if (alignment.CanHarm(this.configuration.alignmentProvider)) { this.TakeDamage(damageValue, damagePoint, alignment); } else { Debug.Log("不可伤害,因为是友方单位"); } return(this.isDead); }
/// <summary> /// Use the alignment to see if adding damage is a valid action /// </summary> /// <param name="damageAddition"> /// The damage to add /// </param> /// <param name="damageAlignment"> /// The alignment of the other combatant /// </param> /// <param name="output"> /// The output data if there is damage taken /// </param> /// <returns> /// <value>true if this instance added damage</value> /// <value>false if this instance was already dead, or the alignment did not allow the damage</value> /// </returns> public bool CheckDamage(int damageAddition, IAlignmentProvider damageAlignment, Vector3 hitPosition, out HitInfo output) { var info = new DamageChangeInfo { alignment = damageAlignment, damageable = this, newDamage = CurrentDamage, oldDamage = CurrentDamage }; output = new HitInfo { damageChangeInfo = info, damagePoint = hitPosition }; if (damageAlignment == null || AlignmentProvider == null) { return(false); } bool canDamage = damageAlignment.CanHarm(AlignmentProvider); //if (!IsAlive || !canDamage) if (IsAlive == false || canDamage == false) { return(false); } AddDamage(+damageAddition, output); SafelyDoAction(Damaged, output); return(true); }
/// <summary> /// Use the alignment to see if taking damage is a valid action /// </summary> /// <param name="damage"> /// The damage to take /// </param> /// <param name="damageAlignment"> /// The alignment of the other combatant /// </param> /// <param name="output"> /// The output data if there is damage taken /// </param> /// <returns> /// <value>true if this instance took damage</value> /// <value>false if this instance was already dead, or the alignment did not allow the damage</value> /// </returns> public bool TakeDamage(float damage, IAlignmentProvider damageAlignment, out HealthChangeInfo output) { output = new HealthChangeInfo { damageAlignment = damageAlignment, damageable = this, newHealth = currentHealth, oldHealth = currentHealth }; bool canDamage = damageAlignment == null || alignmentProvider == null || damageAlignment.CanHarm(alignmentProvider); if (isDead || !canDamage) { return(false); } ChangeHealth(-damage, output); SafelyDoAction(damaged, output); if (isDead) { SafelyDoAction(died, output); } return(true); }
protected virtual bool IsLegalTarget(Transform targetable, SearchType searchType) { if (targetable == null) { return(false); } if (targetable.GetComponent <Targetable>() == null) { return(false); } bool isLegalTarget = true; IAlignmentProvider targetAlignment = targetable.GetComponent <Targetable>().configuration.alignmentProvider; IAlignmentProvider selfAlignment = alignment.GetInterface(); if (searchType == SearchType.All) { isLegalTarget = true; } else if (searchType == SearchType.Enemy) { isLegalTarget = selfAlignment == null || targetAlignment == null || selfAlignment.CanHarm(targetAlignment); } else if (searchType == SearchType.Friend) { isLegalTarget = selfAlignment == null || targetAlignment == null || selfAlignment.IsFriend(targetAlignment); } return(isLegalTarget); }
/// <summary> /// Damagable will tell damager that it has successful hurt the damagable /// </summary> public void HasDamaged(Vector3 point, IAlignmentProvider otherAlignment) { if (hasDamaged != null) { hasDamaged(point); } }
public void CheckDamage(int damageAddition, IAlignmentProvider damageAlignment, Vector3 hitPosition) { DamageChangeInfo info = new DamageChangeInfo(); HitInfo hitInfo = new HitInfo(info, hitPosition); CheckDamage(damageAddition, damageAlignment, hitPosition, out hitInfo); }
/// <summary> /// Initialises the Effects attached to this object /// </summary> public virtual void Initialize(Tower tower, LayerMask enemyMask, IAlignmentProvider alignment) { mask = enemyMask; foreach (Affector effect in Affectors) { effect.Initialize(alignment, mask); } m_ParentTower = tower; }
public void Initialize(Tower target, LayerMask enemyMask, IAlignmentProvider alignment) { mask = enemyMask; m_ParentTower = target; foreach (Affector effect in Affectors) { effect.Initialize(alignment, enemyMask); } }
/// <summary> /// Initialises the attack affector with a layer mask /// </summary> public override void Initialize(IAlignmentProvider affectorAlignment, LayerMask mask) { base.Initialize(affectorAlignment, mask); SetUpTimers(); towerTargetter.ResetTargetter(); towerTargetter.alignment = affectorAlignment; towerTargetter.acquiredTarget += OnAcquiredTarget; towerTargetter.lostTarget += OnLostTarget; }
/// <summary> /// Initialises the Effects attached to this object /// </summary> public virtual void Initialize(Starcraft tower, LayerMask enemyMask, IAlignmentProvider alignment) { mask = enemyMask; //foreach (Affector effect in Affectors) //{ // effect.Initialize(alignment, mask); //} m_ParentTower = tower; }
/// <summary> /// Gets whether the given alignment is in our known list of opponents /// </summary> public bool CanHarm(IAlignmentProvider other) { if (other == null) { return(true); } var otherAlignment = other as TeamAlignment; return(otherAlignment != null && opponents.Contains(otherAlignment)); }
/// <summary> /// 治疗 /// </summary> public void Cure(float addCureValue, Vector3 damagePoint, IAlignmentProvider alignment) { if (alignment.IsFriend(this.configuration.alignmentProvider)) { this.TakeCure(addCureValue, damagePoint, alignment); } else { Debug.Log("不可治疗,因为是敌方单位"); } }
/// <summary> /// Gets whether the given alignment is in our known list of enemys /// </summary> public bool CanHarm(IAlignmentProvider other) { if (other == null) { return(true); } var otherAlignment = other as SimpleAlignment; return(otherAlignment != null && enemys.Contains(otherAlignment)); }
public bool IsFriend(IAlignmentProvider other) { if (other == null) { return(true); } var otherAlignment = other as SimpleAlignment; return(otherAlignment != null && friends.Contains(otherAlignment)); }
protected virtual void Start() { targetsInRange = new List <Targetable>(); attachedCollider = GetComponent <SphereCollider>(); targetsInRange.Clear(); alignment = transform.parent.parent.GetComponent <Tower>().configuration.alignmentProvider; // Reset turret facing. if (turret != null) { turret.localRotation = Quaternion.identity; } }
/// <summary> /// Takes the damage and also provides a position for the damage being dealt /// </summary> /// <param name="damageValue">Damage value.</param> /// <param name="damagePoint">Damage point.</param> /// <param name="alignment">Alignment value</param> public virtual void TakeDamage(float damageValue, Vector3 damagePoint, IAlignmentProvider alignment) { HealthChangeInfo info; configuration.TakeDamage(damageValue, alignment, out info); var damageInfo = new HitInfo(info, damagePoint); if (hit != null) { hit(damageInfo); } }
/// <summary> /// Checks if the targetable is a valid target /// </summary> /// <param name="targetable"></param> /// <returns>true if targetable is vaild, false if not</returns> protected virtual bool IsTargetableValid(Targetable targetable) { if (targetable == null) { return(false); } IAlignmentProvider targetAlignment = targetable.configuration.alignmentProvider; bool canDamage = alignment == null || targetAlignment == null || alignment.CanHarm(targetAlignment); return(canDamage); }
public virtual void TakeDamage(float damageValue, Vector3 damagePoint, IAlignmentProvider alignment) { bool info; configuration.TakeDamage(damageValue, alignment, out info); if (info) { if (hit != null) { hit(); } } }
public void AddNormalAttackToBattleOrder(AttackData attackData) { LevelAgent attacker = attackData.fsm.levelAgent; LevelAgent target = attackData.target.GetComponent <LevelAgent>(); IAlignmentProvider alignment = attacker.configuration.alignmentProvider; List <BuffInfo> buffInfos = new List <BuffInfo>(); //buffInfos.Add(new BuffInfo(eBuffType.damage, 10, 10f, "PoisonFX")); DamageInfo damageInfo = new DamageInfo(10, 0, buffInfos, alignment); BattleOrder bo = new BattleOrder(); bo.Construct(attacker, target, damageInfo); battle_order.Add(bo); }
void IsAOE(LevelAgent target, int damage, IAlignmentProvider alignment) { Collider[] cols = Physics.OverlapSphere(target.position, radius); foreach (Collider col in cols) { // If target can receive damage LevelAgent pc = col.gameObject.GetComponent <LevelAgent>(); if (pc != null && target.configuration.alignmentProvider.IsFriend(pc.configuration.alignmentProvider)) { Vector3 targetDir = pc.transform.position - target.transform.position; float proportion = 1 - targetDir.sqrMagnitude / (radius * radius); int finalDamage = (int)(damage * proportion); pc.OnSkillDamageTaken(finalDamage, pc.position, alignment, true, null, ""); } } }
/// <summary> /// /// </summary> /// <param name="blKapingKey">是否技能打击的关键目标(决定卡屏结束时间)</param> /// <param name="hurtHP"></param> /// <param name="blJS">true 为技能的最后一击</param> public void OnSkillDamageTaken(int damageValue, Vector3 damagePoint, IAlignmentProvider alignment, bool blJS = false, GameObject hitEffect = null, string targetTag = "") { if (this.isDead) { return; } if (hitEffect != null) { EffectDelayPlay edp = FightDefin.LoadSkill(hitEffect, this, eSkillDirection.orignal, false, false); edp.m_blIgnoreScaleTime = true; } //最后一击 if (blJS && targetTag != "") { // AddHUDText(targetTag, eScoreFlashType.SkillUp); } Damage(damageValue, damagePoint, alignment); }
public virtual void TakeDamage(float damage, IAlignmentProvider damageAlignment, out bool output) { float effectivDamage = damage * (1 - resistance); bool canDamage = damageAlignment == null || alignmentProvider == null || damageAlignment.CanHarm(alignmentProvider); if (isDead || !canDamage) { output = false; return; } ChangeHealth(-effectivDamage); output = true; if (isDead) { died(); } }
public bool CanKnockback(IAlignmentProvider attackerAlignment) { return(damageableBehaviour.CanKnockback(attackerAlignment)); }
/// <summary> /// Checks if you can harm a victim /// </summary> /// <param name="victim">The Alignment you're trying to harm</param> public bool CanHarm(IAlignmentProvider victim) { Alignment victimAlignment = victim as Alignment; return(victimAlignment != null && opponents.Contains(victimAlignment)); }
public bool CanKnockback(IAlignmentProvider attackerAlignment) { var returnVal = attackerAlignment.CanHarm(configuration.AlignmentProvider); return(returnVal); }
/// <summary> /// Initializes the effect with search data /// </summary> /// <param name="affectorAlignment"> /// The alignment of the effect for search purposes /// </param> /// <param name="mask"> /// The physics layer of to search for /// </param> public virtual void Initialize(IAlignmentProvider affectorAlignment, LayerMask mask) { alignment = affectorAlignment; enemyMask = mask; }
/// <summary> /// Initializes the effect with search data /// </summary> /// <param name="affectorAlignment"> /// The alignment of the effect for search purposes /// </param> public virtual void Initialize(IAlignmentProvider affectorAlignment) { Initialize(affectorAlignment, -1); }
/// <summary> /// Initializes the attack affector /// </summary> public override void Initialize(IAlignmentProvider affectorAlignment) { Initialize(affectorAlignment, -1); }