示例#1
0
        private void FireServer(Ray aimRay)
        {
            bool            hasHit             = false;
            Vector3         hitPoint           = Vector3.zero;
            float           hitDistance        = 0f;
            HealthComponent hitHealthComponent = null;
            var             bulletAttack       = new BulletAttack
            {
                bulletCount             = 1,
                aimVector               = aimRay.direction,
                origin                  = aimRay.origin,
                damage                  = YokoShootRifle.damageCoefficient * this.damageStat,
                damageColorIndex        = DamageColorIndex.Default,
                damageType              = DamageType.Generic,
                falloffModel            = BulletAttack.FalloffModel.DefaultBullet,
                maxDistance             = YokoShootRifle.range,
                force                   = YokoShootRifle.force,
                hitMask                 = LayerIndex.CommonMasks.bullet,
                minSpread               = 0f,
                maxSpread               = 0f,
                isCrit                  = base.RollCrit(),
                owner                   = base.gameObject,
                muzzleName              = muzzleString,
                smartCollision          = false,
                procChainMask           = default(ProcChainMask),
                procCoefficient         = procCoefficient,
                radius                  = 0.75f,
                sniper                  = false,
                stopperMask             = LayerIndex.CommonMasks.bullet,
                weapon                  = null,
                tracerEffectPrefab      = Modules.Assets.yokoRifleBeamEffect,
                spreadPitchScale        = 0f,
                spreadYawScale          = 0f,
                queryTriggerInteraction = QueryTriggerInteraction.UseGlobal,
                hitEffectPrefab         = Modules.Assets.yokoRifleHitSmallEffect,
            };

            if (maxRicochetCount > 0 && bulletAttack.isCrit)
            {
                bulletAttack.hitCallback = delegate(BulletAttack bulletAttackRef, ref BulletHit hitInfo)
                {
                    var result = BulletAttack.defaultHitCallback(bulletAttackRef, ref hitInfo);
                    hasHit      = true;
                    hitPoint    = hitInfo.point;
                    hitDistance = hitInfo.distance;
                    if (hitInfo.hitHurtBox)
                    {
                        hitHealthComponent = hitInfo.hitHurtBox.healthComponent;
                    }
                    return(result);
                };
            }
            bulletAttack.filterCallback = delegate(BulletAttack bulletAttackRef, ref BulletAttack.BulletHit info)
            {
                return((!info.entityObject || info.entityObject != bulletAttack.owner) && BulletAttack.defaultFilterCallback(bulletAttackRef, ref info));
            };
            bulletAttack.Fire();
            if (hasHit)
            {
                this.Explode(hitPoint, bulletAttack.isCrit, (hitHealthComponent) ? hitHealthComponent.gameObject : null);
                if (hitHealthComponent != null)
                {
                    if (bulletAttack.isCrit)
                    {
                        CritRicochetOrb critRicochetOrb = new CritRicochetOrb();
                        critRicochetOrb.bouncesRemaining    = maxRicochetCount - 1;
                        critRicochetOrb.resetBouncedObjects = resetBouncedObjects;
                        critRicochetOrb.damageValue         = bulletAttack.damage;
                        critRicochetOrb.isCrit             = base.RollCrit();
                        critRicochetOrb.teamIndex          = TeamComponent.GetObjectTeam(base.gameObject);
                        critRicochetOrb.attacker           = base.gameObject;
                        critRicochetOrb.attackerBody       = base.characterBody;
                        critRicochetOrb.procCoefficient    = bulletAttack.procCoefficient;
                        critRicochetOrb.duration           = 0.1f;
                        critRicochetOrb.bouncedObjects     = new List <HealthComponent>();
                        critRicochetOrb.range              = Mathf.Max(30f, hitDistance);
                        critRicochetOrb.tracerEffectPrefab = Modules.Assets.yokoRifleBeamEffect;
                        critRicochetOrb.hitEffectPrefab    = Modules.Assets.yokoRifleHitSmallEffect;
                        critRicochetOrb.hitSoundString     = "TTGLTokoRifleCrit";
                        critRicochetOrb.origin             = hitPoint;
                        critRicochetOrb.bouncedObjects.Add(hitHealthComponent);
                        var nextTarget = critRicochetOrb.PickNextTarget(hitPoint);
                        if (nextTarget)
                        {
                            critRicochetOrb.target = nextTarget;
                            OrbManager.instance.AddOrb(critRicochetOrb);
                        }
                    }
                }
            }
        }
示例#2
0
 private void Explode(CritRicochetOrb orb)
 {
     this.Explode(orb.target.transform.position, orb.isCrit, orb.target.gameObject);
 }