Example #1
0
    /// <summary>
    /// 处理命中时的伤害变化
    /// </summary>
    private void ProcessDirectDamage()
    {
        Assert.Should(m_tempTargeters != null);

        //  直接伤害:直线
        if (BulletTypeUtil.IsLine(Entity.model.bulletType))
        {
            foreach (var tar in m_tempTargeters)
            {
                var pos       = tar.GetCurrentPosition();
                var targeters = FindTargetersLine(pos.x, pos.y, 0.8f);  //  REMARK:这里直线宽度暂时设置为0.8个格子大小(可以适当调整)
                GameDamageManager.ProcessDamageMultiTargeters(targeters, Entity.model, Entity);
            }
        }
        //  直接伤害:扇形(包括360度环形)
        else if (Entity.model.attackAngle > 0)
        {
            foreach (var tar in m_tempTargeters)
            {
                var pos       = tar.GetCurrentPosition();
                var targeters = FindTargetersInAngle(pos.x, pos.y, Entity.model.attackAngle);
                GameDamageManager.ProcessDamageMultiTargeters(targeters, Entity.model, Entity);
            }
        }
        //  直接伤害:其他形状
        else
        {
            GameDamageManager.ProcessDamageMultiTargeters(m_tempTargeters, Entity.model, Entity);
        }
    }
Example #2
0
    private void ProcessExplode(bool fly)
    {
        //  伤害处理(溅射范围为0则针对单个目标,否则根据溅射范围计算。)
        if (Entity.model.splashRange > 0)
        {
            //  飞天陷阱根据body计算位置、普通陷阱获取自身位置。
            Vector2 p;
            if (fly)
            {
                var currPosition = Entity.view.body.position;
                p = new Vector2(currPosition.x, currPosition.z);
            }
            else
            {
                p = Entity.GetCurrentPositionCenter();
            }
            GameDamageManager.ProcessDamageMultiTargeters(FindTargetersInSplash(p.x, p.y), Entity.model, Entity);
        }
        else
        {
            GameDamageManager.ProcessDamageOneTargeter(m_currTraceTargeter, Entity.model, Entity);
        }

        //  爆炸显示效果
        GameEffectManager.Instance.AddEffect(Entity.model.hitEffectName, fly ? Entity.view.body.position : Entity.view.transform.position);

        //  自身死亡
        Entity.Die();

        //  改变数据
        Entity.buildingVO.trapBuildingVO.broken = true;
    }
Example #3
0
    /// <summary>
    /// 处理技能范围伤害
    /// </summary>
    /// <param name="skillModel"></param>
    /// <param name="hitX"></param>
    /// <param name="hitY"></param>
    public void ProcessAoeDamage(EntityModel skillModel, float hitX, float hitY)
    {
        var targeters = GetEntitiesByRange(null, OwnerType.Defender, hitX, hitY, skillModel.splashRange, 0.0f);

        if (targeters.Count == 0)
        {
            return;
        }
        GameDamageManager.ProcessDamageMultiTargeters(targeters, skillModel);
    }