예제 #1
0
	/// <summary>
	/// Register map icon
	/// </summary>
	/// <param name="theMapIcon"></param>
	void RegisterIcon(KGFIMapIcon theMapIcon)
	{
		// create copy of static representation
		GameObject aSpatialArrow = null;
		// create copy of representation
		GameObject aSpatialNewMapIcon = null;
		
		aSpatialNewMapIcon = theMapIcon.GetRepresentation();
		if(aSpatialNewMapIcon == null)
		{
			LogError("missing icon representation for: "+theMapIcon.GetGameObjectName(),name,this);
			return;
		}
		
		UpdateIconLayer(theMapIcon);
		
		if (theMapIcon.GetTextureArrow() != null)
		{
			aSpatialArrow = GenerateTexturePlane(theMapIcon.GetTextureArrow(),itsDataModuleMinimap.itsShaders.itsShaderMapIcon);
			aSpatialArrow.transform.parent = itsContainerIconArrows;
			aSpatialArrow.transform.localPosition = Vector3.zero;
			aSpatialArrow.transform.localScale = Vector3.one;
			aSpatialArrow.GetComponent<MeshRenderer>().material.renderQueue = 3200;
			SetLayerRecursively(aSpatialArrow.gameObject,itsLayerMinimap);
		}
		
		// reparent it
		aSpatialNewMapIcon.transform.parent = itsContainerIcons;
		aSpatialNewMapIcon.transform.position = Vector3.zero;
		SetLayerRecursively(aSpatialNewMapIcon.gameObject,itsLayerMinimap);

		// remember it
		mapicon_listitem_script aNewItem = new mapicon_listitem_script();
		aNewItem.itsModule = this;
		aNewItem.itsMapIcon = theMapIcon;
		aNewItem.itsRepresentationInstance = aSpatialNewMapIcon;
		aNewItem.itsRepresentationInstanceTransform = aSpatialNewMapIcon.transform;
		aNewItem.itsRotate = theMapIcon.GetRotate();
		
		aNewItem.itsRepresentationArrowInstance = aSpatialArrow;
		aNewItem.itsMapIconTransform = theMapIcon.GetTransform();
		aNewItem.SetVisibility(true);
		if (aSpatialArrow != null)
			aNewItem.itsRepresentationArrowInstanceTransform = aSpatialArrow.transform;
		aNewItem.itsCachedRepresentationSize = GetGameObjectSize(aSpatialNewMapIcon);
		itsListMapIcons.Add(aNewItem);
		itsListMapIcons.Sort(CompareMapIcons);
		
		aNewItem.UpdateIcon();
		UpdateIconScale();
		
		LogInfo(string.Format("Added icon of category '{0}' for '{1}'",theMapIcon.GetCategory(),theMapIcon.GetTransform().name),name,this);
	}
예제 #2
0
	/// <summary>
	/// set foreground or background rendering of icons (if they should disappear behind fog of war or not)
	/// </summary>
	/// <param name="anIcon"></param>
	void UpdateIconLayer(KGFIMapIcon theMapIcon)
	{
		GameObject aSpatialNewMapIcon = theMapIcon.GetRepresentation();
		MeshRenderer []aListRepRenderer = aSpatialNewMapIcon.GetComponentsInChildren<MeshRenderer>();
		CleanClickIconsList();
		foreach (MeshRenderer aRepRenderer in aListRepRenderer)
		{
			if (itsDataModuleMinimap.itsFogOfWar.itsHideMapIcons && !itsListClickIcons.Contains(theMapIcon))
			{
				aRepRenderer.sharedMaterial.renderQueue = 3000;
			}else
			{
				aRepRenderer.sharedMaterial.renderQueue = 3200;
			}
		}
	}