- Home /
Read Array Inside Array
Hi!
I'm trying to create an Array Called "Area" inside an Array called "Monsters" this will be used to load monsters depending the area. I have this working with 2 variables, (Area and AreaAlternative) so if you're in the area 01 any enemy that have area 01 in Area or AreaAlternative will appear (I have this function already done). But now I want to assign more than 2 possible areas for every enemy, that why i want to create the array to save all possibles areas for a enemy there.
Right now I have something like this:
for (var i=0;i<AllEnemies.Length;i++){
if(AllEnemies[i].frequency == Frequency.Second && (AllEnemies[i].areaLocated == PlayerScript.area || AllEnemies[i].areaLocatedAlternative == PlayerScript.area) && (AllEnemies[i].enviromentLocated == PlayerScript.enviroment || AllEnemies[i].enviromentLocatedAlternative == PlayerScript.enviroment) && (AllEnemies[i].attractedTo == PlayerScript.color || AllEnemies[i].attractedTo == "Any")){
tempMonsters.Add(AllEnemies[i]);
}
As you can see here I read the area of the monster to see if is the right one or not:
(AllEnemies[i].areaLocated == PlayerScript.area || AllEnemies[i].areaLocatedAlternative == PlayerScript.area)
My problem is, if instead 2 variables I create an Array... How should I read it to see if the current area is between one of the possible Areas for that enemy? If there is another good option it would be great too!
Thank you!!
Your answer
Follow this Question
Related Questions
How do I check if all objects in an array are destroyed? 2 Answers
Creating Buttons from a Button created from an Array 1 Answer
How to Clone Array1 into Array2 in Unity? Using JavaScript. 0 Answers
My array does not update when object is destroyed. How do I fix it? (java) 2 Answers
Advice to make a lots of IF statements into a single FOR statement. 2 Answers