Hello there , i need some help with logic. I have 5 weapons , i have only 3 slots for those. How can i set it to something like: if slot1 is full check slot2 , if its full too check 3 , if its full too then throw " all slots are full" and then click on weapon and after that click on slot to swap weapons.Could someone give me pseudocode? ive no idea how to do that
I have no idea what your actual setup is.
Perhaps something like this.
Just off the top of my head. (Probably nowhere near the result you want but just an idea)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ExampleScript : MonoBehaviour {
// Array of slots?
GameObject[] slots = new GameObject[2];
// Simple method which returns the first available slot
int IsSlotAvailable ()
{
bool foundSlot = false;
for (int i = 0; i < slots.Length; i++)
{
// create a simple IsFull method which returns true or false on the slot.
// I cant as I dont know your setup
// if slot is not full, return this one and break the loop.
if (slots[i].IsFull() == false && foundSlot == false)
{
foundSlot = true;
return i;
}
else
break;
}
// If no slot is available return -1. No slot.
return -1;
}
}
I have no setup yet, i want to have something to start with , just for training and learning purposes