Exemplo n.º 1
0
 private void Aim()
 {
     if (!(currentGun == null) && !ragdoll.IsRagdoll() && animator.GetBool("Aiming"))
     {
         Vector3 vector = target.transform.position - base.transform.position;
         if (Vector3.Angle(base.transform.forward, vector) > 70f)
         {
             base.transform.rotation = Quaternion.Slerp(base.transform.rotation, Quaternion.LookRotation(vector), Time.deltaTime * hipSpeed);
         }
         head.transform.rotation     = Quaternion.Slerp(head.transform.rotation, Quaternion.LookRotation(vector), Time.deltaTime * headAndHandSpeed);
         rightArm.transform.rotation = Quaternion.Slerp(head.transform.rotation, Quaternion.LookRotation(vector), Time.deltaTime * headAndHandSpeed);
         leftArm.transform.rotation  = Quaternion.Slerp(head.transform.rotation, Quaternion.LookRotation(vector), Time.deltaTime * headAndHandSpeed);
         if (readyToShoot)
         {
             gunScript.Use(target.position);
             readyToShoot = false;
             Invoke("Cooldown", attackSpeed + Random.Range(attackSpeed, attackSpeed * 5f));
         }
     }
 }
Exemplo n.º 2
0
    private void OnTriggerEnter(Collider other)
    {
        int     layer      = other.gameObject.layer;
        Vector3 normalized = (other.transform.position - base.transform.position).normalized;
        float   num        = Vector3.Distance(other.transform.position, base.transform.position);

        if (other.gameObject.CompareTag("Enemy"))
        {
            if (other.gameObject.name != "Torso")
            {
                return;
            }
            RagdollController ragdollController = (RagdollController)other.transform.root.GetComponent(typeof(RagdollController));
            if ((bool)ragdollController && !ragdollController.IsRagdoll())
            {
                ragdollController.MakeRagdoll(normalized * 1100f);
                if (player)
                {
                    PlayerMovement.Instance.Slowmo(0.35f, 0.5f);
                }
                Enemy enemy = (Enemy)other.transform.root.GetComponent(typeof(Enemy));
                if ((bool)enemy)
                {
                    enemy.DropGun(Vector3.up);
                }
            }
            return;
        }
        Rigidbody component = other.gameObject.GetComponent <Rigidbody>();

        if ((bool)component)
        {
            if (num < 5f)
            {
                num = 5f;
            }
            component.AddForce(normalized * 450f / num, ForceMode.Impulse);
            component.AddTorque(new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f), Random.Range(-1f, 1f)) * 10f);
            if (layer == LayerMask.NameToLayer("Player"))
            {
                ((PlayerMovement)other.transform.root.GetComponent(typeof(PlayerMovement))).Explode();
            }
        }
    }