Advertisement
Guest User

allowUsToUseKnifeBoris

a guest
May 21st, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.92 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class allowToUseKnifeBoris : MonoBehaviour
  6. {
  7.     public GameObject boris;
  8.     bool allowKnife;
  9.     public GameObject knife;
  10.     public GameObject player;
  11.     Animator anim;
  12.     CharacterControllerScript controller;
  13.     Boris borisController;
  14.     // Start is called before the first frame update
  15.     void Start()
  16.     {
  17.         anim = player.GetComponent<Animator>();
  18.         allowKnife = false;
  19.         controller = player.GetComponent<CharacterControllerScript>();
  20.         borisController = boris.GetComponent<Boris>();
  21.     }
  22.  
  23.     // Update is called once per frame
  24.     void Update()
  25.     {
  26.         if (allowKnife)
  27.         {
  28.             if (Input.GetKeyDown(KeyCode.V))
  29.             {
  30.                 StartCoroutine(OnAnimationComplete());
  31.             }
  32.         }
  33.     }
  34.  
  35.     void OnTriggerEnter(Collider other)
  36.     {
  37.         //player
  38.         if (other.gameObject.tag.Equals("Player") && !borisController.isDead && !CharacterControllerScript.isDead)
  39.         {
  40.             allowKnife = true;
  41.             ShowMessage.id = 1;
  42.         }
  43.  
  44.     }
  45.  
  46.     private void OnTriggerExit(Collider other)
  47.     {
  48.         if (other.gameObject.tag.Equals("Player"))
  49.         {
  50.             allowKnife = false;
  51.             ShowMessage.id = 0;
  52.         }
  53.  
  54.     }
  55.  
  56.  
  57.     void deactivateKinife()
  58.     {
  59.         knife.SetActive(false);
  60.     }
  61.  
  62.     IEnumerator OnAnimationComplete()
  63.     {
  64.         borisController.stopEnemy();
  65.         Talk.id = 7;
  66.         float knife_waittime = 1.00f;
  67.         anim.SetBool("stabbing", true);
  68.         knife.SetActive(true);
  69.         controller.standStill();
  70.         yield return new WaitForSeconds(knife_waittime);
  71.         anim.SetBool("stabbing", false);
  72.         knife.SetActive(false);
  73.         borisController.bodyHit=true;
  74.         controller.setStandardWalkSpeed();
  75.         yield return true;
  76.     }
  77.  
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement