Example #1
0
 void Throw()
 {
     source.PlayOneShot(throwSound);
     state        = knifeState.THROWING;
     currentKnife = Instantiate(knife, transform.position + Camera.main.transform.forward + new Vector3(0, 1f), Quaternion.Euler(transform.rotation.eulerAngles + new Vector3(0, 90, 270)));
     currentKnife.GetComponent <KnifeBehaviour>().SetOwner(this.gameObject);
     currentKnife.GetComponent <Rigidbody>().velocity = 20 * Camera.main.transform.forward;
 }
Example #2
0
 void Update()
 {
     if (Input.GetMouseButtonDown(0) && state == knifeState.INHAND)
     {
         Throw();
         GameObject.Find("Cursor").GetComponent <Image>().color = Color.red;
     }
     else
     if (Input.GetMouseButtonDown(0) && state == knifeState.INGROUND)
     {
         Destroy(currentKnife);
         state = knifeState.INHAND;
     }
 }
Example #3
0
 public void SetState(knifeState state)
 {
     this.state = state;
 }
Example #4
0
 public bool CheckIfState(knifeState state)
 {
     return(this.state == state);
 }