GameFramework.EntityInfo.SetAttackerInfo C# (CSharp) Method

SetAttackerInfo() public method

public SetAttackerInfo ( int attackId, bool isKiller, bool isNormalAttack, bool isCritical, int hpDamage, int npDamage ) : void
attackId int
isKiller bool
isNormalAttack bool
isCritical bool
hpDamage int
npDamage int
return void
        public void SetAttackerInfo(int attackId, bool isKiller, bool isNormalAttack, bool isCritical, int hpDamage, int npDamage)
        {
            if (isKiller)
                KillerId = attackId;
            long curTime = TimeUtility.GetLocalMilliseconds();
            LastAttackedTime = curTime;
            AttackerInfo info;
            if (!AttackerInfos.TryGetValue(attackId, out info)) {
                AttackerInfos.Add(attackId, new AttackerInfo { m_AttackTime = curTime, m_HpDamage = hpDamage, m_NpDamage = npDamage });
            } else {
                info.m_AttackTime = curTime;
                info.m_HpDamage += hpDamage;
                info.m_NpDamage += npDamage;
                AttackerInfos[attackId] = info;
            }
            EntityManager.FireDamageEvent(GetId(), attackId, isNormalAttack, isCritical, hpDamage, npDamage);
        }

Usage Example

示例#1
0
        internal void ImpactDamage(int srcObjId, int targetId, int impactId, int seq)
        {
            EntityInfo targetObj = m_Scene.EntityManager.GetEntityInfo(targetId);
            EntityInfo srcObj    = m_Scene.EntityManager.GetEntityInfo(srcObjId);

            if (null != targetObj && !targetObj.IsDead())
            {
                ImpactInfo impactInfo = targetObj.GetSkillStateInfo().GetImpactInfoBySeq(seq);
                if (null != impactInfo && impactId == impactInfo.ImpactId)
                {
                    TableConfig.Skill cfg = impactInfo.ConfigData;
                    int   targetType      = impactInfo.TargetType;
                    float damage          = impactInfo.DamageData.Damage;
                    int   addShield       = impactInfo.DamageData.AddShield;
                    int   hpRecover       = impactInfo.DamageData.HpRecover;

                    if (hpRecover != 0)
                    {
                        targetObj.SetHp(Operate_Type.OT_Relative, (int)impactInfo.DamageData.HpRecover);
                        targetObj.SetAttackerInfo(srcObjId, false, true, false, -impactInfo.DamageData.HpRecover, 0);
                    }
                    if (addShield != 0)
                    {
                        targetObj.SetShield(Operate_Type.OT_Relative, impactInfo.DamageData.AddShield);
                    }
                    if ((targetType == (int)SkillTargetType.Enemy || targetType == (int)SkillTargetType.RandEnemy) && damage != 0)
                    {
                        if (targetObj.EntityType == (int)EntityTypeEnum.Tower)
                        {
                            if (null != srcObj && srcObj.NormalSkillId != impactInfo.SkillId)
                            {
                                //技能打塔不产生伤害
                                return;
                            }
                        }
                        bool isKiller = false;
                        if (targetObj.Shield >= damage)
                        {
                            targetObj.SetShield(Operate_Type.OT_Relative, -(int)damage);
                        }
                        else if (targetObj.Shield > 0)
                        {
                            int leftDamage = (int)damage - targetObj.Shield;
                            targetObj.SetShield(Operate_Type.OT_Absolute, 0);
                            targetObj.SetHp(Operate_Type.OT_Relative, -(int)leftDamage);
                            if (targetObj.Hp <= 0)
                            {
                                isKiller = true;
                            }
                        }
                        else
                        {
                            targetObj.SetHp(Operate_Type.OT_Relative, -(int)damage);
                            if (targetObj.Hp <= 0)
                            {
                                isKiller = true;
                            }
                        }
                        if (isKiller)
                        {
                            targetObj.GetCombatStatisticInfo().AddDeadCount(1);
                            if (null != srcObj)
                            {
                                EntityInfo killer = srcObj;
                                if (killer.SummonerId > 0)
                                {
                                    killer = m_Scene.EntityManager.GetEntityInfo(killer.SummonerId);
                                }
                                if (targetObj.EntityType == (int)EntityTypeEnum.Tower)
                                {
                                    killer.GetCombatStatisticInfo().AddKillTowerCount(1);
                                }
                                else if (targetObj.EntityType == (int)EntityTypeEnum.Hero)
                                {
                                    killer.GetCombatStatisticInfo().AddKillHeroCount(1);
                                    killer.GetCombatStatisticInfo().AddMultiKillCount(1);
                                }
                                else
                                {
                                    killer.GetCombatStatisticInfo().AddKillNpcCount(1);
                                }
                            }
                        }
                        targetObj.SetAttackerInfo(srcObjId, isKiller, true, false, (int)damage, 0);
                    }
                }
            }
        }
All Usage Examples Of GameFramework.EntityInfo::SetAttackerInfo