Exemple #1
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);
        }
Exemple #2
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);
                }
            }
        }
Exemple #3
0
        public void Fire(Transform _target)
        {
            if (_target != null && DebugLogIsEnabled)
            {
                PrintDebugLog(this, "Fire - " + _target.name + " (" + _target.position + ")");
            }

            if (Type == RangedWeaponAmmunitionType.Simulated && _target != null)
            {
                ICEWorldEntity.SendDamage(Owner, _target.gameObject, ImpactType, MethodDamage, MethodName, ForceType, UnityEngine.Random.Range(ForceMin, ForceMax), ExplosionRadius);
            }
            else if (Type == RangedWeaponAmmunitionType.Projectile || Type == RangedWeaponAmmunitionType.BallisticProjectile)
            {
                Vector3    _position = Vector3.zero;
                Quaternion _rotation = Quaternion.identity;


                if (Type == RangedWeaponAmmunitionType.Projectile)
                {
                    if (_target != null)
                    {
                        _position = _target.position;
                    }

                    if (ProjectileSpawnPoint != null)
                    {
                        Debug.DrawRay(ProjectileSpawnPoint.transform.position, ProjectileSpawnPoint.transform.forward * 100);
                        RaycastHit _hit;
                        if (Physics.Raycast(ProjectileSpawnPoint.transform.position, ProjectileSpawnPoint.transform.forward, out _hit, Mathf.Infinity, -1, WorldManager.TriggerInteraction))
                        {
                            _position = _hit.point;
                        }
                    }

                    GameObject _projectile = WorldManager.Instantiate(Projectile, _position, _rotation);
                    if (_projectile != null)
                    {
                        _projectile.name = Projectile.name;
                        _projectile.transform.localScale = new Vector3(ProjectileScale, ProjectileScale, ProjectileScale);

                        SystemTools.EnableColliders(_projectile.transform, false);

                        Rigidbody _rb = _projectile.GetComponent <Rigidbody>();
                        if (_rb != null)
                        {
                            _rb.useGravity  = false;
                            _rb.isKinematic = true;
                            _rb.constraints = RigidbodyConstraints.FreezeAll;
                        }

                        _projectile.transform.SetParent(_target, true);

                        ICECreatureProjectile _p = _projectile.GetComponent <ICECreatureProjectile>();
                        if (_p != null)
                        {
                            _p.Hit(_target.gameObject, _position);
                        }
                    }
                }
                else if (Type == RangedWeaponAmmunitionType.BallisticProjectile)
                {
                    if (ProjectileSpawnPoint != null)
                    {
                        _position = ProjectileSpawnPoint.transform.position;
                        _rotation = ProjectileSpawnPoint.transform.rotation;
                    }
                    else
                    {
                        _position = Owner.transform.position;
                        _rotation = Owner.transform.rotation;
                    }

                    GameObject _projectile = WorldManager.Instantiate(Projectile, _position, _rotation);
                    if (_projectile != null)
                    {
                        _projectile.name = Projectile.name;
                        _projectile.transform.localScale = new Vector3(ProjectileScale, ProjectileScale, ProjectileScale);

                        Rigidbody _rb = _projectile.GetComponent <Rigidbody>();
                        if (_rb != null)
                        {
                            _rb.AddForce(ProjectileSpawnPoint.transform.TransformDirection(new Vector3(0, 0, ProjectileMuzzleVelocity)));
                        }
                    }
                }
            }
        }