[Help] Comparing Values of two gameobjects

Hello hello Everyone,

I got a bit of a doozy here, I currently am trying to work on a pet project of mine, and have run into a snag.

In short for those who have played triple triad, I am attempting to replicate the card system, however cannot figure out how to compare two game objects once played.

I have built a database using the following format

items.Add(new Item("Bob", 4,5,6,7));

When played, (there is a small game object defining the points where the cards “lock” once played) how can i have it check the surrounding tiles to see if there is a card with the “enemy”(or similar tag) and check the variables set by the database, and compare the two.

for those not familiar with Triple Triad, the following link will provide a description of the game

Thanks for the help!

Hey Ezekiel,

I’ve never played triple triad, but you can keep track of the objects using a 2d array in your scene. One solution could be to use a for statement to set a temp variable through one row or column of the 2d array. Use an if statement to check if the next object in the sequence has the same value (Id maybe).

The code below is a general idea of what I’m talking about. You’ll need to edit it to make it work with your needs.

int[,] table = new int[3,3]
int temp = 0;
for(int i=0; i<3; i++){
for(int j=0; j<3; j++){
temp = table[i,j];
if(temp == table[i+1,j]
{Debug.Log(“Sequence!”);
}
}

Hope that helps!