Пример #1
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;
    }
Пример #2
0
    /// <summary>
    /// [回调] 子弹命中目标 或 子弹命中目标点
    /// </summary>
    /// <param name="bullet"></param>
    private void OnBulletHitted(GameBullet bullet)
    {
        //  TODO:如果子弹命中回调时自身已经挂了的情况是否需要考虑??
        //if (this.Entity.IsDead())
        //    return;

        Vector2 hitPos       = Vector2.zero;
        float   randomRadius = 0.0f;

        switch (bullet.bulletType)
        {
        case EntityBulletType.Point:        //  对地点伤害
        {
            Assert.Should(bullet.targetEntity == null);
            ProcessDamagePoint(bullet.targetPosition);
            hitPos       = bullet.targetPosition;
            randomRadius = 0.3f;            //  REMARK:打目标点的按照半格计算
        }
        break;

        case EntityBulletType.Target:       //  对目标伤害
        {
            Assert.Should(bullet.targetEntity != null);
            if (Entity.model.splashRange > 0)
            {
                ProcessDamagePoint(bullet.targetEntity.GetCurrentPositionCenter());
            }
            else
            {
                GameDamageManager.ProcessDamageOneTargeter(bullet.targetEntity, Entity.model, Entity);
            }
            hitPos       = bullet.targetEntity.GetCurrentPositionCenter();
            randomRadius = Mathf.Max(0.3f, bullet.targetEntity.blockingRange / 6.0f);
        }
        break;

        default:
            Assert.Should(false, "invalid bullet type...");
            break;
        }

        //  命中效果(范围内随机设置个命中点)
        if (randomRadius > 0)
        {
            hitPos.x = BattleRandom.Range(hitPos.x - randomRadius, hitPos.x + randomRadius);
            hitPos.y = BattleRandom.Range(hitPos.y - randomRadius, hitPos.y + randomRadius);
        }
        GameEffectManager.Instance.AddEffect(Entity.model.hitEffectName, new Vector3(hitPos.x, 0, hitPos.y));
    }
Пример #3
0
    /// <summary>
    /// 针对地点进行伤害处理
    /// </summary>
    /// <param name="pos"></param>
    protected void ProcessDamagePoint(Vector2 pos)
    {
        List <TileEntity> targeters = FindTargetersInSplash(pos.x, pos.y);

        if (targeters.Count == 0)
        {
            return;
        }
        int targeterCount = 0;

        foreach (TileEntity targeter in targeters)
        {
            //  REMARK:溅射伤害系数修正
            if (++targeterCount <= Constants.SPLASH_FULL_DAMAGE_MAX)
            {
                GameDamageManager.ProcessDamageOneTargeter(targeter, Entity.model, Entity);
            }
            else
            {
                GameDamageManager.ProcessDamageOneTargeter(targeter, Entity.model, Entity, Constants.SPLASH_PARTIAL_DAMAGE_RATIO);
            }
        }
    }