public PointOfInterest(IPackResourceManager resourceManager, PointOfInterestType type, AttributeCollection explicitAttributes, PathingCategory rootPathingCategory) { this.ResourceManager = resourceManager; this.Type = type; this.ExplicitAttributes = explicitAttributes; Preprocess(rootPathingCategory); }
public PointOfInterest(string name, Vector3 location, Random random) { _name = name; _location = location; _random = random; _type = PointOfInterestType.Default; }
public PointOfInterest(string id, string name, PointF location, CircleStyle style, PointOfInterestType type) : base(location) { this.Style = style; //this.Location = location; this.Name = name; this.ID = id; this.Type = type; }
/// <summary> /// Returns all the points of interest of a given type. /// This is expensive so better cache the result on Start. /// </summary> public static List <IStateful> GetPointOfInterest(PointOfInterestType type) { var targets = GoapAction.GetTargets <PointOfInterest>(); for (int i = targets.Count - 1; i >= 0; i--) { var point = targets[i] as PointOfInterest; if (point.type != type) { targets.RemoveAt(i); } } return(targets); }
public static string GetPOIName(PointOfInterestType type) { switch (type) { case PointOfInterestType.Star: return(_stars.RandomItem()); case PointOfInterestType.Planet: return(_planets.RandomItem()); default: return("RANDOM NAME FAILED!"); } }
public async Task <PointsOfInterest> GetPointsOfInterestAsync(PointOfInterestType pointOfInterestType, double topLeftLatitude, double topLeftLongitude, double bottomRightLatitude, double bottomRightLongitude, uint gridDepth, uint limit) { var pathAndQuery = string.Format( TimetableClient.GetPointsOfInterestPathAndQueryFormat, (uint)pointOfInterestType, topLeftLatitude, topLeftLongitude, bottomRightLatitude, bottomRightLongitude, gridDepth, limit ); var result = await this.ExecuteAsync <PointsOfInterest>(pathAndQuery); return(result); }
/// <summary> /// Sets the POI state /// </summary> /// <param name="position">World position of the POI.</param> /// <param name="type">POI Type, grid, ore, gps, etc.</param> /// <param name="relationship">Relationship of the local player to this POI</param> public void SetState(Vector3D position, PointOfInterestType type, MyRelationsBetweenPlayerAndBlock relationship) { WorldPosition = position; POIType = type; Relationship = relationship; Vector3D viewDirection = position - MyHudMarkerRender.ActiveWorldMatrix.Translation; Distance = viewDirection.Length(); }
/// <summary> /// Draws an icon for the POI /// </summary> private static void DrawIcon(MyHudMarkerRender renderer, PointOfInterestType poiType, MyRelationsBetweenPlayerAndBlock relationship, Vector2 screenPosition, Color markerColor, float sizeScale = 1) { MyHudTexturesEnum centerIcon = MyHudTexturesEnum.corner; string centerIconSprite = string.Empty; Vector2 iconSize = new Vector2(12, 12); switch (poiType) { default: // Groups don't have an icon case PointOfInterestType.Group: return; case PointOfInterestType.Hack: centerIcon = MyHudTexturesEnum.hit_confirmation; break; case PointOfInterestType.Target: centerIcon = MyHudTexturesEnum.TargetTurret; break; case PointOfInterestType.Ore: centerIcon = MyHudTexturesEnum.HudOre; break; case PointOfInterestType.Character: case PointOfInterestType.SmallEntity: case PointOfInterestType.LargeEntity: case PointOfInterestType.StaticEntity: case PointOfInterestType.Unknown: case PointOfInterestType.UnknownEntity: { string icon = GetIconForRelationship(relationship); DrawIcon(renderer, icon, screenPosition, markerColor); return; } case PointOfInterestType.GPS: { string icon = "Textures\\HUD\\marker_gps.dds"; DrawIcon(renderer, icon, screenPosition, markerColor); return; } } // Draw icon if (!string.IsNullOrWhiteSpace(centerIconSprite)) { iconSize *= sizeScale; renderer.AddTexturedQuad(centerIconSprite, screenPosition, -Vector2.UnitY, markerColor, iconSize.X, iconSize.Y); } else { float indicatorSize = MyHudConstants.HUD_DIRECTION_INDICATOR_SIZE * 0.8f * sizeScale; renderer.AddTexturedQuad(centerIcon, screenPosition, -Vector2.UnitY, markerColor, indicatorSize, indicatorSize); } }
void Start() { //Spawn the player in m_Player = Instantiate(PlayerPrefab, transform.parent) as GameObject; Text battlesCompletedText = BattlesCompletedLabel.GetComponent <Text> (); battlesCompletedText.text = "Battles Completed: " + SaveManager.GetInstance().GetSelectedData().m_FightsCompleted; Text timeText = TimeLabel.GetComponent <Text> (); timeText.text = Timer.GetInstance().GetTime(); m_NonStaticTravelTime = Random.Range(20, 30); //Get font for use. //m_Font = Resources.GetBuiltinResource<Font> ("Arial.ttf"); float aspectratiowidth = m_PointOfInterestIconSizeX / aspectratiox; m_PointOfInterestIconSizeX = aspectratiowidth * (float)Screen.width; float aspectratioheight = m_PointOfInterestIconSizeY / aspectratioy; m_PointOfInterestIconSizeY = aspectratioheight * (float)Screen.height; //Add canvas renderer and rect transform. gameObject.AddComponent <CanvasRenderer> (); RectTransform m_MapObjectRectTransform = gameObject.AddComponent <RectTransform>(); m_MapObjectRectTransform.localPosition = Vector3.zero; m_MapObjectRectTransform.anchorMin = new Vector2(0.5f, 0.5f); //set the anchors. m_MapObjectRectTransform.anchorMax = new Vector2(0.5f, 0.5f); m_MapObjectRectTransform.pivot = new Vector2(0.5f, 0.5f); //Create game object which stores the separate regions. GameObject m_RegionsContainer = new GameObject("Map Regions"); m_RegionsContainer.AddComponent <CanvasRenderer> (); RectTransform m_RegionsContainerRectTransform = m_RegionsContainer.AddComponent <RectTransform> (); m_RegionsContainer.transform.SetParent(gameObject.transform.parent); //set anchors for region container. m_RegionsContainerRectTransform.anchorMin = new Vector2(0, 0); //set the anchors. m_RegionsContainerRectTransform.anchorMax = new Vector2(1, 1); m_RegionsContainerRectTransform.pivot = new Vector2(0.5f, 0.5f); m_RegionsContainerRectTransform.localPosition = Vector3.zero; m_RegionsContainerRectTransform.offsetMin = Vector2.zero; m_RegionsContainerRectTransform.offsetMax = Vector2.zero; //Get the size of the container. float containerWidth = m_RegionsContainerRectTransform.rect.width; float containerHeight = m_RegionsContainerRectTransform.rect.height; //Each region takes up a quarter of the container. requiredWidth = (containerWidth / 2) - 1; //(-1 to prevent overlapping) requiredHeight = (containerHeight / 2) - 1; //(-1 to prevent overlapping) //Create array of the 4 corners and the non-static region. MapRegion[] regions = new MapRegion[] { m_TopLeftRegion, m_TopRightRegion, m_BottomLeftRegion, m_BottomRightRegion, m_NonStaticRegion }; //Loop through each region and create UI elements for the map. //Create a highlighted area & draw the name of the region in the corner. foreach (MapRegion mRegion in regions) { //Create game object for region. GameObject m_NewRegion = new GameObject("Region: " + mRegion.m_RegionName); m_NewRegion.AddComponent <CanvasRenderer> (); RectTransform m_newRegionRectTransform = m_NewRegion.AddComponent <RectTransform> (); m_NewRegion.transform.SetParent(m_RegionsContainer.transform); mRegion.m_RegionGameObject = m_NewRegion; if (mRegion.m_Region == MapRegions.OTHER || mRegion.m_Region == MapRegions.CENTER) { //non-locked regions should be smaller than the corners? m_newRegionRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, (requiredWidth / 2)); m_newRegionRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, (requiredHeight / 2)); //m_newRegionRectTransform.anchoredPosition = SaveManager.GetInstance ().GetSelectedData ().m_RegionLocation.GetLocation(); } else { m_newRegionRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, requiredWidth); m_newRegionRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, requiredHeight); m_newRegionRectTransform.localPosition = Vector3.zero; } //Anchor the region correctly, based on the position on the map: switch (mRegion.m_Region) { case MapRegions.TOPLEFT: m_newRegionRectTransform.anchorMin = new Vector2(0, 1); m_newRegionRectTransform.anchorMax = new Vector2(0, 1); m_newRegionRectTransform.pivot = new Vector2(0, 1); break; case MapRegions.TOPRIGHT: m_newRegionRectTransform.anchorMin = new Vector2(1, 1); m_newRegionRectTransform.anchorMax = new Vector2(1, 1); m_newRegionRectTransform.pivot = new Vector2(1, 1); break; case MapRegions.BOTTOMLEFT: m_newRegionRectTransform.anchorMin = new Vector2(0, 0); m_newRegionRectTransform.anchorMax = new Vector2(0, 0); m_newRegionRectTransform.pivot = new Vector2(0, 0); break; case MapRegions.BOTTOMRIGHT: m_newRegionRectTransform.anchorMin = new Vector2(1, 0); m_newRegionRectTransform.anchorMax = new Vector2(1, 0); m_newRegionRectTransform.pivot = new Vector2(1, 0); break; case MapRegions.CENTER: case MapRegions.OTHER: //m_newRegionRectTransform.anchorMin = new Vector2 (0.5f, 0.5f); //m_newRegionRectTransform.anchorMax = new Vector2 (0.5f, 0.5f); //m_newRegionRectTransform.pivot = new Vector2 (0.5f, 0.5f); m_NonStaticRegionRectTransform = m_newRegionRectTransform; break; } Image i = m_NewRegion.AddComponent <Image> (); Color ic = i.color; ic.a = 0.1f; i.color = ic; //Add outline to object Outline m_RegionOutline = m_NewRegion.AddComponent <Outline>(); Color colorToUse = mRegion.m_RegionColor; colorToUse.a = 0.3f; m_RegionOutline.effectColor = colorToUse; GameObject textObject = new GameObject("Region Label: " + mRegion.m_RegionName); textObject.transform.SetParent(m_NewRegion.transform); RectTransform text_rt = textObject.AddComponent <RectTransform> (); text_rt.anchorMin = new Vector2(0, 1); text_rt.anchorMax = new Vector2(0, 1); text_rt.pivot = new Vector2(0, 1); text_rt.offsetMin = new Vector2(0, -25); text_rt.offsetMax = new Vector2(200, 0); Text t = textObject.AddComponent <Text> (); t.font = m_Font; t.text = mRegion.m_RegionName; t.resizeTextForBestFit = true; Outline textOutline = textObject.AddComponent <Outline>(); textOutline.effectColor = Color.black; //Load the saved points of interest from the serialized unity file MapPointOfInterest[] pointsOfInterest = mRegion.m_PointsOfInterest; foreach (MapPointOfInterest point in pointsOfInterest) { string m_PointName = point.m_PointOfInterestName; PointOfInterestType m_PointType = point.m_PointOfInterestType; MapRegions m_PointRegion = point.m_PointOfInterestRegion; GameObject m_IconBackground = new GameObject("Point of interest (" + m_PointType + "): " + m_PointName); m_IconBackground.AddComponent <CanvasRenderer> (); RectTransform m_IconBackgroundRectTransform = m_IconBackground.AddComponent <RectTransform> (); Image m_IconBackgroundImage = m_IconBackground.AddComponent <Image> (); m_IconBackgroundImage.sprite = IconBackground; Color opaqueColor = colorToUse; opaqueColor.a = 1.0f; m_IconBackgroundImage.color = opaqueColor; m_IconBackgroundRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, m_PointOfInterestIconSizeX * 2); m_IconBackgroundRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, m_PointOfInterestIconSizeY * 2); m_IconBackground.transform.SetParent(m_NewRegion.transform); m_IconBackgroundRectTransform.anchoredPosition = Vector2.zero + point.m_PointOffset; //apply user set offset. GameObject m_PointGameObject = new GameObject(m_PointName + " icon"); CircleCollider2D m_IconCircleCollider = m_PointGameObject.AddComponent <CircleCollider2D> (); m_IconCircleCollider.radius = m_PointOfInterestIconSizeX; m_IconCircleCollider.offset = Vector2.zero; m_IconCircleCollider.isTrigger = true; PointInfo poi_Info = m_PointGameObject.AddComponent <PointInfo> (); poi_Info.pointOfInterest = point; poi_Info.region = mRegion; m_PointGameObject.AddComponent <CanvasRenderer> (); RectTransform m_PointRectTransform = m_PointGameObject.AddComponent <RectTransform> (); Image m_PointImage = m_PointGameObject.AddComponent <Image> (); Outline m_PointOutline = m_PointGameObject.AddComponent <Outline> (); m_PointOutline.effectColor = colorToUse; //Set the image switch (m_PointType) { case PointOfInterestType.GANG_HEADQUARTERS: m_PointImage.sprite = HeadquartersSprite; break; case PointOfInterestType.VILLAGE: m_PointImage.sprite = VillageSprite; break; case PointOfInterestType.DUNGEON: default: m_PointImage.sprite = DungeonSprite; break; } m_PointGameObject.transform.SetParent(m_IconBackground.transform); //Set the position switch (m_PointRegion) { case MapRegions.TOPLEFT: m_IconBackgroundRectTransform.anchorMin = new Vector2(0, 1); m_IconBackgroundRectTransform.anchorMax = new Vector2(0, 1); m_IconBackgroundRectTransform.pivot = new Vector2(0, 1); break; case MapRegions.TOPRIGHT: m_IconBackgroundRectTransform.anchorMin = new Vector2(1, 1); m_IconBackgroundRectTransform.anchorMax = new Vector2(1, 1); m_IconBackgroundRectTransform.pivot = new Vector2(1, 1); break; case MapRegions.BOTTOMLEFT: m_IconBackgroundRectTransform.anchorMin = new Vector2(0, 0); m_IconBackgroundRectTransform.anchorMax = new Vector2(0, 0); m_IconBackgroundRectTransform.pivot = new Vector2(0, 0); break; case MapRegions.BOTTOMRIGHT: m_IconBackgroundRectTransform.anchorMin = new Vector2(1, 0); m_IconBackgroundRectTransform.anchorMax = new Vector2(1, 0); m_IconBackgroundRectTransform.pivot = new Vector2(1, 0); break; case MapRegions.CENTER: case MapRegions.OTHER: m_IconBackgroundRectTransform.anchorMin = new Vector2(0.5f, 0.5f); m_IconBackgroundRectTransform.anchorMax = new Vector2(0.5f, 0.5f); m_IconBackgroundRectTransform.pivot = new Vector2(0.5f, 0.5f); break; } //m_PointRectTransform.anchorMin = new Vector2 (0.5f, 0.5f); //m_PointRectTransform.anchorMax = new Vector2 (0.5f, 0.5f); //m_PointRectTransform.pivot = new Vector2 (0.5f, 0.5f); m_PointRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, m_PointOfInterestIconSizeX); m_PointRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, m_PointOfInterestIconSizeY); m_PointRectTransform.anchoredPosition = Vector2.zero; } EnemyManager m_EnemyManager = m_NewRegion.AddComponent <EnemyManager> (); m_EnemyManager.SetRegion(mRegion); m_EnemyManager.SetMapManager(this); } //Load the previously saved location of the non-static region. Location regionsLocation = SaveManager.GetInstance().GetSelectedData().m_RegionLocation; Vector2 posV2 = new Vector2(regionsLocation.map_x, regionsLocation.map_y); m_NonStaticRegionRectTransform.localPosition = posV2; m_NonStaticRegion.SetDynamicPosition(posV2); m_RegionsContainer.transform.SetAsFirstSibling(); }
public static Sprite GetIcon(PointOfInterestType icon) { return(_icons[(int)icon]); }