コード例 #1
0
    // Use this for initialization
    void Start()
    {
        Camera.main.transform.parent.transform.position = new Vector3(0f, 0.4f, -4);

        this.pinPoints = new List <GameObject>();
        foreach (Data data in Data.MOUNTAINS)
        {
            GameObject pinPoint = Instantiate(pinPointPrefab, new Vector3(data.x, data.y, data.z), Quaternion.identity);
            PinPoint   ppScript = pinPoint.GetComponent <PinPoint>();
            ppScript.SetData(data);
            TextMesh text = pinPoint.GetComponentInChildren <TextMesh>();
            text.text = data.name + "\n" + data.shortInfo;

            // Setup event trigger
            EventTrigger evtTrigger = pinPoint.GetComponent <EventTrigger>();
            evtTrigger.triggers.Clear();
            EventTrigger.Entry entry = new EventTrigger.Entry();
            entry.eventID = EventTriggerType.PointerClick;
            entry.callback.AddListener((eventData) => this.PinPointClick(pinPoint));
            evtTrigger.triggers.Add(entry);

            this.pinPoints.Add(pinPoint);
        }

        videoStation = Instantiate(videoStationPrefab, Vector3.zero, Quaternion.identity);
        videoStation.SetActive(false);

        wikipediaStation = Instantiate(wikipediaStationPrefab, Vector3.zero, Quaternion.identity);
        wikipediaStation.SetActive(false);

        isStationRunning = false;
    }
コード例 #2
0
        private PinPoint MoveForward(PinPoint currentPinPoint)
        {
            var newPinPoint = new PinPoint
            {
                Direction = currentPinPoint.Direction
            };

            switch (currentPinPoint.Direction)
            {
            case "N":
                newPinPoint.X = currentPinPoint.X;
                newPinPoint.Y = currentPinPoint.Y + 1;
                break;

            case "E":
                newPinPoint.X = currentPinPoint.X + 1;
                newPinPoint.Y = currentPinPoint.Y;
                break;

            case "S":
                newPinPoint.X = currentPinPoint.X;
                newPinPoint.Y = currentPinPoint.Y - 1;
                break;

            case "W":
                newPinPoint.X = currentPinPoint.X - 1;
                newPinPoint.Y = currentPinPoint.Y;
                break;

            default:
                break;
            }

            return(newPinPoint);
        }
コード例 #3
0
        /// <summary>
        /// Returns a pin-point
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public PinPointDTO Get(int id)
        {
            var mission = new PinPoint();

            using (var unitOfWork = new UnitOfWork())
            {
                mission = unitOfWork.PinPoints.Get(id);
            }
            var missionDTO = AutoMapper.Mapper.Map <PinPointDTO>(mission);

            return(missionDTO);
        }
コード例 #4
0
        public virtual void DbGeographyObject()
        {
            using (var ctx = GetContext())
            {
                var pin = new PinPoint
                {
                    Name        = "Foo",
                    Coordinates = DbGeography.FromText("POINT(-122.336106 47.605049)")
                };

                ctx.BulkInsert(new[] { pin });
            }
        }
コード例 #5
0
        private void Validate(PinPoint pinPoint)
        {
            if (pinPoint.MissionId == 0)
            {
                throw new ArgumentNullException(nameof(pinPoint.MissionId));
            }

            if (pinPoint.X == 0)
            {
                throw new ArgumentNullException(nameof(pinPoint.X));
            }

            if (pinPoint.Y == 0)
            {
                throw new ArgumentNullException(nameof(pinPoint.Y));
            }

            if (pinPoint.Direction.IsEmpty())
            {
                throw new ArgumentNullException(nameof(pinPoint.Direction));
            }
        }
コード例 #6
0
    public void PinPointClick(GameObject pinPoint)
    {
        videoStation.SetActive(false);
        wikipediaStation.SetActive(false);
        if (!isStationRunning)
        {
            PinPoint script = pinPoint.GetComponent <PinPoint>();
            Data     data   = script.GetData();
            if (data.mediaType == Data.MEDIA_TYPE_WEBPAGE)
            {
                WikipediaStation wsScript = wikipediaStation.GetComponent <WikipediaStation>();

                Vector3 newPosition = pinPoint.transform.position + (Camera.main.transform.forward * 3.0f);

                wsScript.LoadAndDisplay(
                    new Vector3(newPosition.x,
                                3.0f,
                                newPosition.z),
                    data.contentURL
                    );
                isStationRunning = true;
            }
            else if (data.mediaType == Data.MEDIA_TYPE_VIDEO)
            {
                VideoStation vsScript = videoStation.GetComponent <VideoStation>();
                vsScript.LoadAndDisplay(
                    new Vector3(pinPoint.transform.position.x, 0.7f, pinPoint.transform.position.z),
                    data.contentURL
                    );
                isStationRunning = true;
            }
        }
        else
        {
            isStationRunning = false;
        }
    }
コード例 #7
0
        private List <PinPoint> CreateRoute(ref Mission mission)
        {
            var pinPointsRoute = new List <PinPoint>();
            var pinPoint       = new PinPoint();

            if (mission.Id == 0)
            {
                // do this only the first time. Next times the initial position will be the previous
                // final position already
                pinPoint = new PinPoint
                {
                    MissionId       = mission.Id,
                    X               = mission.InitialX,
                    Y               = mission.InitialY,
                    Direction       = mission.InitialDirection,
                    CreatedDate     = DateTime.Now,
                    CreatedByUserId = mission.CreatedByUserId
                };
                pinPointsRoute.Add(pinPoint); // always store the initial pin-point too
            }
            else
            {
                pinPoint = mission.PinPoints.LastOrDefault();
            }

            int currentIndex;
            int newIndex;

            // if we are just moving an existing rover we have to use the "MoveInstructions"
            var instructions = mission.Id > 0 ? mission.MoveInstructions : mission.Instructions;

            // loop thru each single instructions
            foreach (var c in instructions)
            {
                switch (c)
                {
                case 'L':
                    currentIndex = _directions.IndexOf(pinPoint.Direction);
                    newIndex     = currentIndex - 1;

                    if (newIndex < 0)
                    {
                        newIndex = _directions.Length - 1;
                    }
                    if (newIndex > _directions.Length - 1)
                    {
                        newIndex = 0;
                    }

                    pinPoint = new PinPoint
                    {
                        X         = pinPoint.X,
                        Y         = pinPoint.Y,
                        Direction = _directions[newIndex].ToString()
                    };
                    break;

                case 'R':
                    currentIndex = _directions.IndexOf(pinPoint.Direction);
                    newIndex     = currentIndex + 1;

                    if (newIndex < 0)
                    {
                        newIndex = _directions.Length - 1;
                    }
                    if (newIndex > _directions.Length - 1)
                    {
                        newIndex = 0;
                    }

                    pinPoint = new PinPoint
                    {
                        X         = pinPoint.X,
                        Y         = pinPoint.Y,
                        Direction = _directions[newIndex].ToString()
                    };
                    break;

                case 'M':
                    pinPoint = MoveForward(pinPoint);
                    break;

                default:
                    break;
                }

                pinPoint.MissionId       = mission.Id;
                pinPoint.CreatedDate     = DateTime.Now;
                pinPoint.CreatedByUserId = mission.CreatedByUserId;

                pinPointsRoute.Add(pinPoint);
            }

            ValidatePinPoints(mission, pinPointsRoute);

            // set the final output for this mission
            mission.FinalX         = pinPointsRoute.LastOrDefault().X;
            mission.FinalY         = pinPointsRoute.LastOrDefault().Y;
            mission.FinalDirection = pinPointsRoute.LastOrDefault().Direction;

            return(pinPointsRoute);
        }