Advertisement
LittleAngel

Untitled

Mar 17th, 2011
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. if (currentInventoryItem != null) {
  2. SetToolTip (inventory[i]);
  3. if (GUI.Button (currentRect, new GUIContent("", currentToolTip), new GUIStyle ("label"))) {
  4. if (Event.current.button == 0 && Event.current.type == EventType.MouseDown) {
  5. Debug.Log ("MOUSE DOWN!");
  6. GUI.contentColor = Color.red;
  7. }
  8.  
  9. if (Event.current.button == 0) {
  10. Debug.Log ("MOUSE UP!");
  11. if (currentInventoryItem.itemType == ItemType.Consumable) {
  12. // Use it
  13. bool success = UseItem (currentInventoryItem);
  14. if (success) {
  15. inventory[i] = null;
  16. SummarizeEquippedItemBonuses (); //
  17. }
  18. } else if (currentInventoryItem.itemType == ItemType.Clothing || currentInventoryItem.itemType == ItemType.Weapon) {
  19. // Equip it
  20. openLootWindow = false;
  21. openCharacterWindow = true;
  22. bool success = EquipItem (currentInventoryItem);
  23. if (success) {
  24. inventory[i] = null;
  25. SummarizeEquippedItemBonuses ();
  26. }
  27. }
  28. } else if (Input.GetMouseButtonUp (1)) { // ... if that click is mouse button 1: delete it.
  29. // Drop it
  30. Debug.Log ("Removing " + inventory[i].itemName + " from Inventory");
  31. // messageManager.Message ("Display01", "Removing " + inventory[i].itemName + " from Inventory", Color.yellow);
  32. // Optionally Instantiate the discarded object:
  33. if (inventory[i].itemObject) {
  34. Rigidbody clone;
  35. clone = (Rigidbody)Instantiate(inventory[i].itemObject, playerTransform.position +
  36. new Vector3 (Random.Range (-1.0f, 1.0f), 1.0f,Random.Range (-1.0f, 1.0f)),
  37. Quaternion.Euler(Random.Range (-15.0f, 15.0f),Random.Range (-15.0f, 15.0f),Random.Range (-15.0f, 15.0f)));
  38. // Optionally add a velocity to "clone", etc.
  39. clone.velocity = playerTransform.TransformDirection (Vector3.forward) * 2;
  40. }
  41. inventory[i] = null;
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement