Exemple #1
0
 private void Update()
 {
     if (!Screen.lockCursor)
     {
         Screen.lockCursor = true;
     }
     if (Input.GetMouseButtonDown(0))
     {
         this.currentItem.Use(this.weaponMode);
         RaycastHit hit;
         if (Physics.Raycast(this.cameraTransform.position, this.cameraTransform.forward, out hit))
         {
             Deformable deformable = hit.transform.GetComponent <Deformable>();
             if (deformable)
             {
                 deformable.Hit(hit, this.cameraTransform.forward);
             }
         }
     }
     if (Input.GetMouseButtonDown(1))
     {
         this.currentItem.UseAlternatively(this.weaponMode);
     }
     if (Input.GetKeyDown(KeyCode.Tab))
     {
         this.weaponMode = !this.weaponMode;
     }
     if ((this.scroll = Input.GetAxis("Mouse ScrollWheel")) != 0)
     {
         if (this.scroll > 0)
         {
             this.NextItem();
         }
         else
         {
             this.PreviousItem();
         }
     }
     if (Input.GetKeyDown("e"))
     {
         this.Pick();
     }
     if (Input.GetKeyDown("q"))
     {
         this.Throw();
     }
 }
Exemple #2
0
 private void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         RaycastHit hit;
         if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit))
         {
             Debug.DrawLine(Camera.main.transform.position, hit.point, Color.red);
             Actable actable = hit.transform.GetComponentInChildren <Actable>();
             if (actable)
             {
                 actable.Act(new string[] { "Foo" });
             }
             Deformable deformable = hit.transform.GetComponentInChildren <Deformable>();
             if (deformable)
             {
                 deformable.Hit(hit, Camera.main.transform.forward * 4.0f);
             }
             Destroyable destroyable = hit.transform.GetComponentInChildren <Destroyable>();
             if (destroyable)
             {
                 destroyable.Explode(hit.point);
             }
             Terminatable terminatable = hit.transform.GetComponentInChildren <Terminatable>();
             if (terminatable)
             {
                 terminatable.Hit(Random.Range(0, 47), this.transform);
             }
             Damageable damageable;
             if ((damageable = hit.transform.GetComponent <Damageable>()) != null || (damageable = hit.transform.root.GetComponent <Damageable>()) != null)
             {
                 damageable.Damage(hit);
             }
             Rigidbody rigidbody = hit.transform.GetComponentInChildren <Rigidbody>();
             if (rigidbody)
             {
                 rigidbody.AddForceAtPosition(Camera.main.transform.forward * 100.0f, hit.point);
             }
         }
     }
 }