Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void switchItemSlots(int index) {
- if(inventorySlots.Count > index) {
- if(switchRightHandItem) { //if it's right hands turn
- if(inventorySlots.IndexOf(currentItemRight) != index) { //if the chosen slot is different than our current item's slot.
- if(currentItemLeft == null) { //if there is nothing on the left hand
- if(currentItemRight != null) {
- currentItemRight.SetActive(false);
- }
- inventorySlots[index].SetActive(true);
- setCurrentItemRight(inventorySlots[index]);
- invGui.ChangeHighlight(currentItemRight);
- currentItemRight.GetComponent<Rigidbody> ().useGravity = false;
- foreach (BoxCollider col in currentItemRight.GetComponentsInChildren<BoxCollider>()) {
- col.enabled = false;
- }
- } else { //if left hand has something
- if(inventorySlots.IndexOf(currentItemLeft) != index) {
- if(currentItemRight != null) {
- currentItemRight.SetActive(false);
- }
- inventorySlots[index].SetActive(true);
- setCurrentItemRight(inventorySlots[index]);
- invGui.ChangeHighlight(currentItemRight);
- currentItemRight.GetComponent<Rigidbody> ().useGravity = false;
- foreach (BoxCollider col in currentItemRight.GetComponentsInChildren<BoxCollider>()) {
- col.enabled = false;
- }
- } else {
- tempSlot = currentItemLeft;
- currentItemLeft = currentItemRight;
- currentItemRight = tempSlot;
- }
- }
- } else { //if player tries to change current weapon to a same weapon (same slot) and has only one equipped.
- if(currentItemLeft == null) {
- currentItemLeft = currentItemRight;
- currentItemLeft.SetActive(true);
- currentItemRight = null;
- } else { //if player tries to change current weapon to a same weapon (same slot) and has both hands full.
- tempSlot = currentItemLeft;
- currentItemLeft = currentItemRight;
- currentItemRight = tempSlot;
- }
- }
- switchRightHandItem = false;
- } else if(!switchRightHandItem) {
- if(inventorySlots.IndexOf(currentItemLeft) != index) {
- if(currentItemRight == null) { //if there is nothing on the right hand
- if(currentItemLeft != null) {
- currentItemLeft.SetActive(false);
- }
- inventorySlots[index].SetActive(true);
- setCurrentItemLeft(inventorySlots[index]);
- invGui.ChangeHighlight(currentItemLeft);
- currentItemLeft.GetComponent<Rigidbody> ().useGravity = false;
- foreach (BoxCollider col in currentItemLeft.GetComponentsInChildren<BoxCollider>()) {
- col.enabled = false;
- }
- } else {
- if(inventorySlots.IndexOf(currentItemRight) != index) {
- if(currentItemLeft != null) {
- currentItemLeft.SetActive(false);
- }
- inventorySlots[index].SetActive(true);
- setCurrentItemLeft(inventorySlots[index]);
- invGui.ChangeHighlight(currentItemLeft);
- currentItemLeft.GetComponent<Rigidbody> ().useGravity = false;
- foreach (BoxCollider col in currentItemLeft.GetComponentsInChildren<BoxCollider>()) {
- col.enabled = false;
- }
- } else {
- tempSlot = currentItemLeft;
- currentItemLeft = currentItemRight;
- currentItemRight = tempSlot;
- }
- }
- } else { //if player tries to change current weapon to a same weapon (same slot) and has only one equipped.
- if(currentItemRight == null) {
- currentItemRight = currentItemLeft;
- currentItemRight.SetActive(true);
- currentItemLeft = null;
- } else { //if player tries to change current weapon to a same weapon (same slot) and has both hands full.
- tempSlot = currentItemLeft;
- currentItemLeft = currentItemRight;
- currentItemRight = tempSlot;
- }
- }
- switchRightHandItem = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment