public override void OnTouch(Collider collider)
 {
     if (frozen)
     {
         return;
     }
     if (liveMixin.IsAlive() && Time.time > timeLastBite + biteInterval)
     {
         damagingTarget = collider.GetComponent <LiveMixin>();
         if (damagingTarget == null || damagingTarget.maxHealth < 100f)
         {
             return;
         }
         Player player = collider.gameObject.GetComponent <Player>();
         if (player != null && !player.CanBeAttacked())
         {
             return;
         }
         animator.SetTrigger(animationTriggerName);
         source.clip = clipPool.GetRandomClip();
         source.Play();
         Invoke("DamageTarget", 0.6f);
         timeLastBite = Time.time;
     }
 }
        private void GrabVehicle(Vehicle vehicle, VehicleType vehicleType)
        {
            vehicle.GetComponent <Rigidbody>().isKinematic = true;
            vehicle.collisionModel.SetActive(false);
            heldVehicle     = vehicle;
            heldVehicleType = vehicleType;
            if (heldVehicleType == VehicleType.Exosuit)
            {
                SafeAnimator.SetBool(vehicle.mainAnimator, "reaper_attack", true);
                Exosuit component = vehicle.GetComponent <Exosuit>();
                if (component != null)
                {
                    component.cinematicMode = true;
                }
            }
            timeVehicleGrabbed     = Time.time;
            vehicleInitialRotation = vehicle.transform.rotation;
            vehicleInitialPosition = vehicle.transform.position;
            if (heldVehicleType == VehicleType.GenericSub)
            {
                vehicleGrabSound.clip = seamothSounds.GetRandomClip();
            }
            else if (heldVehicleType == VehicleType.Exosuit)
            {
                vehicleGrabSound.clip = exosuitSounds.GetRandomClip();
            }
            else
            {
                ECCLog.AddMessage("Unknown Vehicle Type detected");
            }
            vehicleGrabSound.Play();
            InvokeRepeating("DamageVehicle", 1f, 1f);
            float attackLength = 6f + UnityEngine.Random.value;

            Invoke("ReleaseVehicle", attackLength);
            if (Player.main.GetVehicle() == heldVehicle)
            {
                MainCameraControl.main.ShakeCamera(4f, attackLength, MainCameraControl.ShakeMode.BuildUp, 1.2f);
            }
        }
 public override void OnTouch(Collider collider)
 {
     if (frozen)
     {
         return;
     }
     if (liveMixin.IsAlive() && Time.time > timeLastBite + biteInterval)
     {
         Creature component = GetComponent <Creature>();
         if (component.Aggression.Value >= 0.1f)
         {
             GameObject target = GetTarget(collider);
             if (!playerDeathCinematic.IsCinematicModeActive())
             {
                 Player player = target.GetComponent <Player>();
                 if (player != null)
                 {
                     if (Time.time > timeCinematicAgain && player.CanBeAttacked() && player.liveMixin.IsAlive() && !player.cinematicModeActive)
                     {
                         float num = DamageSystem.CalculateDamage(biteDamage, DamageType.Normal, player.gameObject, null);
                         if (player.liveMixin.health - num <= 0f)
                         {
                             Invoke("KillPlayer", 2.5f);
                             playerDeathCinematic.StartCinematicMode(player);
                             attackSource.clip = cinematicClipPool.GetRandomClip();
                             attackSource.Play();
                             timeCinematicAgain = Time.time + 5f;
                             timeLastBite       = Time.time;
                             return;
                         }
                     }
                 }
                 LiveMixin liveMixin = target.GetComponent <LiveMixin>();
                 if (liveMixin == null)
                 {
                     return;
                 }
                 if (!liveMixin.IsAlive())
                 {
                     return;
                 }
                 if (liveMixin == Player.main.liveMixin)
                 {
                     if (!player.CanBeAttacked())
                     {
                         return;
                     }
                 }
                 if (!CanAttackTargetFromPosition(target))
                 {
                     return;
                 }
                 liveMixin.TakeDamage(GetBiteDamage(target));
                 attackSource.clip = biteClipPool.GetRandomClip();
                 attackSource.Play();
                 timeLastBite = Time.time;
                 creature.GetAnimator().SetTrigger("bite");
                 component.Aggression.Value -= 0.15f;
             }
         }
     }
 }
Beispiel #4
0
        public override void OnTouch(Collider collider)
        {
            if (frozen)
            {
                return;
            }
            if (liveMixin.IsAlive() && Time.time > timeLastBite + biteInterval)
            {
                Creature component = GetComponent <Creature>();

                GameObject      target          = GetTarget(collider);
                GulperBehaviour gulperBehaviour = GetComponent <GulperBehaviour>();
                if (!gulperBehaviour.IsHoldingVehicle() && !playerDeathCinematic.IsCinematicModeActive())
                {
                    Player player = target.GetComponent <Player>();
                    if (player != null)
                    {
                        if (Time.time > timeCinematicAgain && player.CanBeAttacked() && player.liveMixin.IsAlive() && !player.cinematicModeActive)
                        {
                            Invoke("KillPlayer", 0.9f);
                            playerDeathCinematic.StartCinematicMode(player);
                            attackSource.clip = clipPool.GetRandomClip();
                            attackSource.Play();
                            timeCinematicAgain = Time.time + 4f;
                            timeLastBite       = Time.time;
                            return;
                        }
                    }
                    else if (gulperBehaviour.GetCanGrabVehicle() && component.Aggression.Value > 0.1f)
                    {
                        SeaMoth seamoth = target.GetComponent <SeaMoth>();
                        if (seamoth && !seamoth.docked)
                        {
                            gulperBehaviour.GrabGenericSub(seamoth);
                            component.Aggression.Value -= 0.5f;
                            return;
                        }
                        Exosuit exosuiit = target.GetComponent <Exosuit>();
                        if (exosuiit && !exosuiit.docked)
                        {
                            gulperBehaviour.GrabExosuit(exosuiit);
                            component.Aggression.Value -= 0.5f;
                            return;
                        }
                    }
                    LiveMixin liveMixin = target.GetComponent <LiveMixin>();
                    if (liveMixin == null)
                    {
                        return;
                    }
                    if (!liveMixin.IsAlive())
                    {
                        return;
                    }
                    if (!CanAttackTargetFromPosition(target))
                    {
                        return;
                    }
                    if (CanSwallowWhole(collider.gameObject, liveMixin))
                    {
                        Destroy(liveMixin.gameObject, 0.5f);
                        var suckInWhole = collider.gameObject.AddComponent <BeingSuckedInWhole>();
                        suckInWhole.animationLength = 0.5f;
                        suckInWhole.target          = throat;
                        creature.GetAnimator().SetTrigger("bite");
                        return;
                    }
                    else
                    {
                        if (component.Aggression.Value >= 0.2f && target.GetComponentInParent <Vehicle>() == null)
                        {
                            liveMixin.TakeDamage(GetBiteDamage(target));
                            timeLastBite      = Time.time;
                            attackSource.clip = clipPool.GetRandomClip();
                            attackSource.Play();
                            creature.GetAnimator().SetTrigger("bite");
                            component.Aggression.Value = 0f;
                            return;
                        }
                    }
                }
            }
        }