dimanche 26 décembre 2021

Can you help me to create 4 unique numbers from 1-10 in C#?

I have a problem with a Script in my Game. I have 6 Lanes in my Game and 4 Enemys at the moment. If an Enemy reaches the end of a lane, he respawns in a new lane. I want that no Enemy ever gets the same lane as above.

I did it like this

                    Randomlane = rnd.Next(1, 7);
                    Enemy1_Lane = Randomlane;

                    if (Enemy1_Lane == Enemy2_Lane)
                    {
                        if (Enemy1_Lane == 6)
                        {
                            Enemy1_Lane -= 1;
                        }
                        else
                        {
                            Enemy1_Lane += 1;
                        }
                    }

But this only works with 2 Enemys. Now I have 4. Maybe you can help me.




Aucun commentaire:

Enregistrer un commentaire