コード例 #1
0
        public List <Landmark> GetLandmarksInCell(Cell cell)
        {
            List <Landmark> landmarks = new List <Landmark>();

            try
            {
                foreach (MappableObject mappableObject in cell.occupants)
                {
                    if (mappableObject is Landmark)
                    {
                        Landmark castedLandmark = mappableObject as Landmark;
                        landmarks.Add(castedLandmark);
                    }
                }
            }
            catch (System.Exception ex)
            {
                errorHandler.CatchException(ex, ErrorState.close_window);
                return(null);
            }
            return(landmarks);
        }
コード例 #2
0
        public bool AttemptDropOff(Cell dropOffCell, DestinationType destinationType, Province provinceDestination, Landmark landmarkDestination, Country countryDestination)
        {
            //Clear the Event System so that it gets updated with the tourist if the drop off fails
            EventSystem.current.SetSelectedGameObject(null);

            bool dropOffSuccess = false;

            if (dropOffCell == null)
            {
                errorHandler.ReportError("Drop Off Failed: Player in invalid cell", ErrorState.close_window);
                return(false);
            }

            switch (destinationType)
            {
            case DestinationType.province:
                dropOffSuccess = AttemptProvinceDropOff(dropOffCell, provinceDestination);
                break;

            case DestinationType.landmark:
                dropOffSuccess = AttemptLandmarkDropOff(dropOffCell, landmarkDestination);
                break;

            case DestinationType.country:
                dropOffSuccess = AttemptCountryDropOff(dropOffCell, countryDestination);
                break;

            default:
                break;
            }

            return(dropOffSuccess);
        }
コード例 #3
0
        public bool InstantiateCulturalLandmark(MountPoint mountPoint)
        {
            if (!started)
            {
                Start();
            }

            string mountPointName = mountPoint.name;

            if (mountPointName == null)
            {
                errorHandler.ReportError("Cultural mount point name missing", ErrorState.close_window);
                return(false);
            }

            string tempName = mountPointName.Replace("The", "");

            tempName = tempName.Replace(" ", "");
            var model = Resources.Load <GameObject>(landmarkFilePath + tempName);

            if (model == null)
            {
                errorHandler.ReportError("Unable to load cultural landmark model", ErrorState.close_window);
                return(false);
            }

            var modelClone = Instantiate(model);

            if (modelClone == null)
            {
                errorHandler.ReportError("Failed to instantiate " + mountPointName, ErrorState.close_window);
                return(false);
            }

            Landmark landmarkComponent = modelClone.GetComponent(typeof(Landmark)) as Landmark;

            if (landmarkComponent == null)
            {
                errorHandler.ReportError(mountPointName + " landmark component missing", ErrorState.close_window);
                return(false);
            }

            landmarkComponent.MountPoint = mountPoint;
            landmarkComponent.ObjectName = mountPointName;
            landmarkComponent.CellIndex  = worldMapGlobe.GetCellIndex(mountPoint.localPosition);
            if (landmarkComponent.CellIndex < 0 || landmarkComponent.CellIndex > worldMapGlobe.cells.Length)
            {
                errorHandler.ReportError("Invalid cell index for " + mountPointName, ErrorState.close_window);
                return(false);
            }

            landmarkComponent.CellLocation          = worldMapGlobe.cells[landmarkComponent.CellIndex];
            landmarkComponent.CellLocation.canCross = false;
            worldMapGlobe.AddMarker(modelClone, mountPoint.localPosition, 0.001f, false, -5.0f, true, true);
            landmarkComponent.CellLocation.occupants.Add(landmarkComponent);
            string landmarkID = landmarkComponent.GetInstanceID().ToString();

            mappablesManager.MappedObjects.Add(landmarkID, landmarkComponent);
            CulturalLandmarks.Add(landmarkID, landmarkComponent);
            CulturalLandmarksByName.Add(landmarkComponent.ObjectName, landmarkComponent);

            return(true);
        }