public static void TrackMonsters(GameObject origin ,float Range, bool SkillCheckPassed)
{
if (SkillCheckPassed)
{
int[] NoOfMonsters = new int[8];
for (int i =0; i <= NoOfMonsters.GetUpperBound(0);i++)
{
NoOfMonsters[i]=0;
}
bool NPCFound=false;
foreach (Collider Col in Physics.OverlapSphere(origin.transform.position,Range))
{
if (Col.gameObject.GetComponent<NPC>()!=null)
{
NoOfMonsters[Compass.getCompassHeadingOffset(origin, Col.gameObject)]++;
NPCFound=true;
}
}
if (NPCFound)
{
int MaxNoOfMonsters=0;
int MaxOffsetIndex=0;
for (int i =0; i <= NoOfMonsters.GetUpperBound(0);i++)
{
if(NoOfMonsters[i] > MaxNoOfMonsters)
{
MaxNoOfMonsters=NoOfMonsters[i];
MaxOffsetIndex=i;
}
}
string Heading = StringController.instance.GetString(1, 36 + MaxOffsetIndex);
switch (MaxNoOfMonsters)
{//TODO: What is a few?
case 0://Should not happen
//000~001~062~You detect no monster activity. \n
UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1,62)+Heading);break;
case 1://Single creature.
//000-001-059 //You detect a creature
UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1,59)+Heading);break;
case 2:
case 3:
//000-001-060 //You detect a few creatures
UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1,60)+Heading);break;
default:
//000~001~061~You detect the activity of many creatures
UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1,61)+Heading);break;
}
}
else
{
//000~001~062~You detect no monster activity. \n
UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1,62));
}
}
else
{//Skill check has failed. Randomly tell the player something
string Heading = StringController.instance.GetString(1, Random.Range(36,44));
switch ( Random.Range(0,5))
{
case 0:
//000~001~062~You detect no monster activity. \n
UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1,62)+Heading);break;
case 1://Single creature.
//000-001-059 //You detect a creature
UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1,59)+Heading);break;
case 2:
case 3:
//000-001-060 //You detect a few creatures
UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1,60)+Heading);break;
default:
//000~001~061~You detect the activity of many creatures
UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1,61)+Heading);break;
}
}
}