Exemplo n.º 1
0
    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);
        }
    }
Exemplo n.º 2
0
 public DamageInfo(int damage, int heal, List <BuffInfo> buffInfos, IAlignmentProvider alignment)
 {
     this.damage    = damage;
     this.heal      = heal;
     this.buffInfos = buffInfos;
     this.alignment = alignment;
 }
Exemplo n.º 3
0
    /// <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);
    }
Exemplo n.º 4
0
        /// <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);
        }
Exemplo n.º 5
0
        /// <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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
 /// <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);
     }
 }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
 /// <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;
 }
Exemplo n.º 10
0
 public void Initialize(Tower target, LayerMask enemyMask, IAlignmentProvider alignment)
 {
     mask          = enemyMask;
     m_ParentTower = target;
     foreach (Affector effect in Affectors)
     {
         effect.Initialize(alignment, enemyMask);
     }
 }
Exemplo n.º 11
0
        /// <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;
        }
Exemplo n.º 12
0
        /// <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;
        }
Exemplo n.º 13
0
        /// <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));
        }
Exemplo n.º 14
0
 /// <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("不可治疗,因为是敌方单位");
     }
 }
Exemplo n.º 15
0
        /// <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));
        }
Exemplo n.º 16
0
        public bool IsFriend(IAlignmentProvider other)
        {
            if (other == null)
            {
                return(true);
            }

            var otherAlignment = other as SimpleAlignment;

            return(otherAlignment != null && friends.Contains(otherAlignment));
        }
Exemplo n.º 17
0
 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;
     }
 }
Exemplo n.º 18
0
        /// <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);
            }
        }
Exemplo n.º 19
0
    /// <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);
    }
Exemplo n.º 20
0
    public virtual void TakeDamage(float damageValue, Vector3 damagePoint, IAlignmentProvider alignment)
    {
        bool info;

        configuration.TakeDamage(damageValue, alignment, out info);
        if (info)
        {
            if (hit != null)
            {
                hit();
            }
        }
    }
Exemplo n.º 21
0
        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);
        }
Exemplo n.º 22
0
    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, "");
            }
        }
    }
Exemplo n.º 23
0
    /// <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);
    }
Exemplo n.º 24
0
    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();
        }
    }
Exemplo n.º 25
0
 public bool CanKnockback(IAlignmentProvider attackerAlignment)
 {
     return(damageableBehaviour.CanKnockback(attackerAlignment));
 }
Exemplo n.º 26
0
        /// <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));
        }
Exemplo n.º 27
0
        public bool CanKnockback(IAlignmentProvider attackerAlignment)
        {
            var returnVal = attackerAlignment.CanHarm(configuration.AlignmentProvider);

            return(returnVal);
        }
Exemplo n.º 28
0
 /// <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;
 }
Exemplo n.º 29
0
 /// <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);
 }
Exemplo n.º 30
0
 /// <summary>
 /// Initializes the attack affector
 /// </summary>
 public override void Initialize(IAlignmentProvider affectorAlignment)
 {
     Initialize(affectorAlignment, -1);
 }