private void FixedUpdate()
    {
        // Update rotation
        this.rigidbody.rotation = Quaternion.LookRotation(velocity);

        // Try to hit something
        RaycastHit hit;

        if (Physics.Raycast(this.rigidbody.position, velocity, out hit, velocity.magnitude * Time.fixedDeltaTime))
        {
            IDamagable damagable = hit.collider.GetComponentInParent <IDamagable>();
            if (damagable != null)
            {
                damagable.Damage(damage);
            }

            ImpactEffect impact = hit.collider.GetComponentInParent <ImpactEffect>();
            if (impact)
            {
                impact.Impact(this, hit);
            }

            Destroy(this.gameObject);
        }

        // Move and update velocity
        rigidbody.MovePosition(rigidbody.position + (velocity * Time.fixedDeltaTime));

        velocity.y += (gravity * Time.fixedDeltaTime);
        velocity   *= (1f - (airResistance * Time.fixedDeltaTime));
    }
示例#2
0
    private Vector3 SoundDetection()
    {
        Ray ray = new Ray(transform.position, transform.forward);

        RaycastHit[] soundHit = Physics.SphereCastAll(ray, attractionDistance, attractionDistance, attractionMask);
        RaycastHit   hit;
        ImpactEffect impactEffect = null;

        foreach (var item in soundHit)
        {
            if (item.collider.GetComponent <ImpactEffect>())
            {
                impactEffect = item.collider.GetComponent <ImpactEffect>();
            }

            if (impactEffect && impactEffect.Impact)
            {
                impactEffect.Impact = false;

                if (Physics.Linecast(npcHeadPos, impactEffect.transform.position, out hit, searchMask, QueryTriggerInteraction.Collide))
                {
                    if (hit.collider.gameObject.GetComponent <ImpactEffect>())
                    {
                        return(impactEffect.gameObject.transform.position);
                    }
                }
            }
        }

        return(Vector3.zero);
    }
示例#3
0
        public override void Init(ICEWorldBehaviour _component)
        {
            base.Init(_component);

            ImpactSound.Init(_component);
            ImpactEffect.Init(_component);
            ImpactBehaviour.Init(_component);
        }
示例#4
0
    public GameObject GetParticle(ImpactEffect sName)
    {
        if (true == m_DictOfParticleSystems.ContainsKey(sName))
        {
            return(m_DictOfParticleSystems[sName]);
        }

        return(null);
    }
示例#5
0
    public void CreateEffect(Vector3 position, Vector3 direction, ImpactEffect effect)
    {
        GameObject obj = ParticleHolder.Singleton.GetParticle(effect);

        if (null != obj)
        {
            Quaternion rotation = Quaternion.LookRotation(direction);
            GameObject.Instantiate(obj, position, rotation);
        }
    }
示例#6
0
        private void Shoot(int spreadFactor)
        {
            var weaponFired = WeaponFired.Create(GlobalTargets.OnlyServer, ReliabilityModes.ReliableOrdered);

            weaponFired.WeaponId = weapon.Id;
            weaponFired.Entity   = weapon.Player;
            weaponFired.Send();

            var weaponSound = WeaponSound.Create(GlobalTargets.Everyone, ReliabilityModes.Unreliable);

            weaponSound.Position = transform.position;
            weaponSound.Label    = weapon.Label;
            weaponSound.Player   = player.entity;
            weaponSound.Send();

            var dir = Spread(spreadFactor);

            if (!Physics.Raycast(cameraTransform.transform.position, dir, out var hit, 100))
            {
                return;
            }

            if (hit.transform.CompareTag("Stalin"))
            {
                AudioSource soundSource = hit.transform.GetComponent <AudioSource>();
                if (!soundSource.isPlaying)
                {
                    soundSource.Play();
                }
            }

            var boltEntity = hit.transform.GetComponent <BoltEntity>();

            if (boltEntity != null && boltEntity.GetState <IPlayer>() != null)
            {
                var playerHit = PlayerHit.Create(GlobalTargets.OnlyServer);
                playerHit.Target        = boltEntity;
                playerHit.PlayerWhoShot = player.state.Username;
                playerHit.WeaponName    = weapon.Label;
                playerHit.Damage        = weapon.Damage;
                playerHit.Send();


                var applyHitIndicator = ApplyHitIndicator.Create(ReliabilityModes.Unreliable);
                applyHitIndicator.Message  = "Damage: " + weapon.Damage;
                applyHitIndicator.Position = hit.point;
                applyHitIndicator.Send();
            }
            else
            {
                var impactEffect = ImpactEffect.Create(ReliabilityModes.Unreliable);
                impactEffect.Position = hit.point;
                impactEffect.Send();
            }
        }
示例#7
0
        public virtual void Hit(GameObject _target, Vector3 _hit_point)
        {
            if (Owner == null || Enabled == false)
            {
                return;
            }

            if (_target != null && ImpactBehaviour.RefusedByLayer(_target.layer))
            {
                return;
            }

            ICEWorldEntity.SendDamage(Owner, _target, ImpactType, DamageMethodValue, DamageMethodName, _hit_point, ForceType, UnityEngine.Random.Range(ForceMin, ForceMax), ExplosionRadius);
            ImpactSound.Play();
            ImpactEffect.Start(OwnerComponent);
        }
    void Start()
    {
        // go through the effects, add each effect's projectiles to the projectile lists
        foreach (Effect e in myEffects)
        {
            if (e is ProjectileEffect)
            {
                ProjectileEffect pe = (ProjectileEffect)e;
                if (pe.GetMuzzleParticles())
                {
                    muzzleParticlesPrefabs.Add(pe.GetMuzzleParticles());
                }
                if (pe.GetProjectileParticles())
                {
                    projectileParticlesPrefabs.Add(pe.GetProjectileParticles());
                }
            }
            else if (e is ImpactEffect)
            {
                ImpactEffect ie = (ImpactEffect)e;
                if (ie.GetImpactParticles())
                {
                    impactParticlesPrefabs.Add(ie.GetImpactParticles());
                }
            }
        }

        // Then create the projectiles for the start
        foreach (GameObject ppp in projectileParticlesPrefabs)
        {
            GameObject particles = Instantiate(ppp, transform.position, transform.rotation);
            particles.transform.parent = transform;
            projectileParticles.Add(particles);
        }
        if (muzzleParticlesPrefabs.Count > 0)
        {
            foreach (GameObject mpp in muzzleParticlesPrefabs)
            {
                GameObject particles = Instantiate(mpp, transform.position, transform.rotation);
                muzzleParticles.Add(particles);
                DestroyMuzzleParticles(1.5f); // destroy the particles after making them
            }
        }
    }
示例#9
0
        public override void Hit(GameObject _target, Vector3 _hit_point)
        {
            if (Owner == null || Enabled == false)
            {
                return;
            }

            if ((_target != null && ImpactBehaviour.RefusedByLayer(_target.layer)) || ImpactBehaviour.RefusedByHitCounter)
            {
                return;
            }

            ICEWorldEntity.SendDamage(Owner, _target, ImpactType, DamageMethodValue, DamageMethodName, _hit_point, ForceType, UnityEngine.Random.Range(ForceMin, ForceMax), ExplosionRadius);
            ImpactSound.Play();
            ImpactEffect.Start(OwnerComponent);

            if (ImpactBehaviour.Enabled)
            {
                // Handle Projectile Rigidbody
                Rigidbody _rb = Owner.GetComponent <Rigidbody>();
                if (_rb != null)
                {
                    _rb.useGravity  = false;
                    _rb.isKinematic = true;
                    _rb.constraints = RigidbodyConstraints.FreezeAll;
                }

                if (ImpactBehaviour.UseAttachOnHit)
                {
                    WorldManager.AttachToTransform(Owner, _target.transform, false);
                }

                if (ImpactBehaviour.UseHideOnHit)
                {
                    SystemTools.EnableRenderer(Owner.transform, false);
                }

                if (ImpactBehaviour.UseDestroyOnHit)
                {
                    WorldManager.Destroy(Owner, ImpactBehaviour.DestroyDelay);
                }
            }
        }
 public void ApplyEffect(ImpactEffect effect, ProjectileInfo projectile, PointInfo info)
 {
     effect.Execute(GO, projectile, info);
 }
示例#11
0
        public Task<SearchItemsResponse> SearchItems(ImpactEffect? impactEffects = null, GuardianAttribute? guardianAttributes = null, LightAbility? lightAbilities = null, DamageType? damageTypes = null, SourceCategory? sourcecat = null, long? sourcehash = null, bool? matchrandomsteps = null, bool? definitions = null, long? categories = null, SortOrder? order = null, WeaponPerformance? weaponPerformance = null, Rarity? rarity = null, int? page = null, string name = null, Count? count = null, bool? orderstathash = null, SortDirection? direction = null, long? step = null)
        {
            var model = new
            {
                impactEffects,
                guardianAttributes,
                lightAbilities,
                damageTypes,
                sourcecat,
                sourcehash,
                matchrandomsteps,
                definitions,
                categories,
                order,
                weaponPerformance,
                rarity,
                page,
                name,
                count,
                orderstathash,
                direction,
                step
            };

            return Request<SearchItemsResponse>(model);
        }
 public void RemoveEffect(ImpactEffect effect)
 {
     impactEffects.Remove(effect);
 }
 public void AddEffect(ImpactEffect effect)
 {
     impactEffects.Add(effect);
 }
示例#14
0
 public override void Reset()
 {
     ImpactSound.Reset();
     ImpactEffect.Reset();
     ImpactBehaviour.Reset();
 }
示例#15
0
        public override void OnEvent(ImpactEffect ie)
        {
            var impact = Instantiate(impactEffect, ie.Position, Quaternion.identity);

            Destroy(impact, 1f);
        }
示例#16
0
 public ImpactProperty(ImpactEffect impactEffect, Vector2 impactSide)
 {
     this.impactEffect = impactEffect;
     this.impactSide   = impactSide;
 }