hi all,
i need a bit of help implementing an algorithm.
im creating a beat’em’up game and according to what the first player does there are consequences on the second player and vice versa
let me be a bit more clear:
the players, for now, have 4 choises => attack, defende, idle, especial
i have an array whit all the possibilities = {1010,1020,1030,1040, 2010,2020,2030,1040, … etc}
1010 means player1 choise is attack and player2 is all so attack
1020 means player1 choise is attack and player2 is all so defence
etc…
example:
player1 choice is attack, i save this info as an int value = 10
player2 choice is defence, i save this info as an int value = 20
choice = 1020
for(int i =0; i< possibilities .Length; i++)
{
if(possibilities [i].Equals(choise))
{
if(metodos_possiveis[i].Equals(1010)
{
Ataque_Ataque(jogador1,jogador2);
}
else if(metodos_possiveis[i].Equals(1020))
{
Ataque_Defesa(jogador1,jogador2);
}
else if(metodos_possiveis[i].Equals(1030))
{
Ataque_Especial(jogador1,jogador2);
}
else if(metodos_possiveis[i].Equals(1040))
{
Ataque_Idle(jogador1,jogador2);
}
}
}
so i need to call attack_defence() method, to calculate the dmg given to each player
its solution is allready too big, there are allready too many options and i want to scale this up, so that the players will have 3 attack, 3 defence, 1 idle and 10 special and those are just too many combinations
can i create an Array of methods => Array[ ] methods = [attack_attack(),attack_defence() … etc]???
so i can do
for(int i =0; i< possibilities .Length; i++)
{
if(possibilities [i].Equals(choise))
{
methods [i];
}
}
or another solution.
thx guys.