getCompassHeadingOffset() public static method

public static getCompassHeadingOffset ( GameObject src, GameObject dst ) : int
src GameObject
dst GameObject
return int
Example #1
0
	/// <summary>
	/// Tracks the monsters in the specified range around the player.
	/// If the skill check is failed then false information is generated for the player.
	/// </summary>
	/// <param name="origin">Gameobject at the centre of where to check from</param>
	/// <param name="Range">Range to include</param>
	/// <param name="SkillCheckPassed">If set to <c>true</c> skill check passed.</param>
	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, StringController.str_to_the_north + 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,StringController.str_you_detect_no_monster_activity_)+Heading);break;							
				case 1://Single creature.
						//000-001-059 //You detect a creature
						UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1,StringController.str_you_detect_a_creature_)+Heading);break;		
				case 2:
				case 3:
						//000-001-060 //You detect a few creatures
						UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1,StringController.str_you_detect_a_few_creatures_)+Heading);break;										

				default:
						//000~001~061~You detect the activity of many creatures
					UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1,StringController.str_you_detect_the_activity_of_many_creatures_)+Heading);break;	

				}
			}
			else
			{
					//000~001~062~You detect no monster activity. \n	
				UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1,StringController.str_you_detect_no_monster_activity_));
			}		
		}
		else
		{//Skill check has failed. Randomly tell the player something
				string Heading = StringController.instance.GetString(1, Random.Range(StringController.str_to_the_north,StringController.str_to_the_northwest+1));
				switch ( Random.Range(0,5))
				{
				case 0:
						//000~001~062~You detect no monster activity. \n	
						UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1,StringController.str_you_detect_no_monster_activity_)+Heading);break;							
				case 1://Single creature.
						//000-001-059 //You detect a creature
						UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1,StringController.str_you_detect_a_creature_)+Heading);break;		
				case 2:
				case 3:
						//000-001-060 //You detect a few creatures
						UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1,StringController.str_you_detect_a_few_creatures_)+Heading);break;										

				default:
						//000~001~061~You detect the activity of many creatures
						UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1,StringController.str_you_detect_the_activity_of_many_creatures_)+Heading);break;	
				}
		}

	}
Example #2
0
    public static string getCompassHeading(GameObject src, GameObject dst)
    {    //String representation of the above.
        int Offset = Compass.getCompassHeadingOffset(src, dst);

        return(StringController.instance.GetString(1, StringController.str_to_the_north + Offset));             //36
    }