Exemple #1
0
        /// <summary>
        /// An anchor object is 'reborn' when it's localized!
        /// </summary>
        /// <param name="anchorInfo"></param>
        public void Reborn(AnchorInfo info)
        {
            this.anchorInfo = new AnchorInfo
            {
                //clone values
                pose = info.pose,

                experienceId         = info.experienceId,
                activityCollectionId = info.activityCollectionId,

                activityId   = info.activityId,
                activityName = info.activityName,

                type = info.type,

                activitySpecific = Utilities.CopyActivitySpecificProperties(info.activitySpecific)
            };

            //set mode
            this.SetUIMode(AnchorUIMode.Consumer);
            this.SetActivityType(info.type);
            this.SetBehaviourMode(AnchorBehaviourMode.SavedAndStandBy);

            //init edit/delete buttons
            this.editButton.onClick.AddListener(OnEditButtonClick);
            this.deleteButton.onClick.AddListener(OnDeleteButtonClick);
            this.editButton.gameObject.SetActive(false);
            this.deleteButton.gameObject.SetActive(false);
            this.isEditDeleteButtonsActive = false;

            //apply value on UI
            this.ApplyActivityName(info.activityName);

            //activity specific properties
            if (this.anchorInfo.activitySpecific != null)
            {
                switch (info.type)
                {
                case ActivityType.PoI:
                    string poIDesc = this.anchorInfo.activitySpecific["PoIDescription"];
                    this.ApplyPoIDesc(poIDesc);
                    break;

                case ActivityType.Trivia:
                    break;

                case ActivityType.Post:
                    break;

                case ActivityType.Photo:
                    break;

                case ActivityType.CV:
                    break;

                default:
                    break;
                }
            }
        }
Exemple #2
0
        //------------------------  Converting to JSON --------------------------

        /// <summary>
        /// Converting AnchorInfo list to JSON data
        /// </summary>
        /// <returns></returns>
        public JObject AnchorInfoListToJSON()
        {
            //prepare anchor info list
            List <AnchorInfo> anchorInfoList = new List <AnchorInfo>();

            foreach (GameObject anchorObj in anchorObjList)
            {
                AnchorInfo info = anchorObj.GetComponent <AnchorController>().GetAnchorInfo();
                anchorInfoList.Add(info);
            }

            //prepare an arr for converting to JSON
            AnchorInfoList tempAnchorList = new AnchorInfoList
            {
                sbActivityCollection = new AnchorInfo[anchorInfoList.Count]
            };

            for (int i = 0; i < anchorInfoList.Count; ++i)
            {
                tempAnchorList.sbActivityCollection[i] = anchorInfoList[i];
            }

            //convert to JSON
            JObject jObject = JObject.FromObject(tempAnchorList);

            MessageManager.Instance.DebugMessage(jObject.ToString());
            return(jObject);
        }
Exemple #3
0
        //-------------------- init ----------------------------------------

        /// <summary>
        /// Init anchor with a few context information
        /// </summary>
        /// <param name="anchorInfo"></param>
        public void Born(int index, AnchorInfo anchorInfo)
        {
            this.index = index;

            //set the initial anchor info
            this.anchorInfo = anchorInfo;

            //init event handler
            //this.editButton.onClick.AddListener(OnEditButtonClick);
            this.deleteButton.onClick.AddListener(OnDeleteButtonClick);

            //set it ready
            TurnOnButtons();
        }
Exemple #4
0
        public GameObject RebornAnchorObj(AnchorInfo info)
        {
            GameObject anchorObj = Instantiate(anchorObjPrefab);

            anchorObj.transform.position   = info.pose.position;
            anchorObj.transform.rotation   = info.pose.rotation;
            anchorObj.transform.localScale = new Vector3(0.001f, 0.001f, 0.001f);
            anchorObj.SetActive(true);

            AnchorController anchorController = anchorObj.GetComponentInChildren <AnchorController>();

            anchorController.Reborn(info);

            return(anchorObj);
        }
Exemple #5
0
        //-------------------------------- Spawn & Reborn AnchorObject-------------------------

        /// <summary>
        /// This is used only when user is creating anchor
        /// </summary>
        /// <param name="anchorPosition"></param>
        public void SpawnAnchorObj(Vector3 anchorPosition)
        {
            //Instantiate new anchor prefab and set transform.
            GameObject anchorObj = Instantiate(anchorObjPrefab);

            anchorObj.transform.position   = anchorPosition + Const.ANCHOR_Y_OFFSET;
            anchorObj.transform.localScale = new Vector3(0.001f, 0.001f, 0.001f);

            AnchorController anchorController = anchorObj.GetComponent <AnchorController>();

            if (currAnchorObj != null)
            {
                anchorController.TurnOffButtons();
            }
            currAnchorObj = anchorObj;

            //set some initial information
            string expId      = SBContextManager.Instance.GetSBContent().experienceId;
            string actGroupId = SBContextManager.Instance.GetSBContent().activityGroupId;
            string activityId = Utilities.GenerateAnchorUniqueId(expId, actGroupId);
            Pose   anchorPose = new Pose(anchorObj.transform.position, anchorObj.transform.rotation);
            Dictionary <string, string> actSpecific = new Dictionary <string, string>();
            AnchorInfo initialAnchorInfo            = new AnchorInfo
            {
                //initial values
                pose = anchorPose,

                experienceId         = expId,
                activityCollectionId = actGroupId,

                activityId   = activityId,
                activityName = "", //to be set later by creator

                type = ActivityType.Undefined,
                // poiDesc = "",

                activitySpecific = actSpecific
            };

            anchorController.Born(anchorObjList.Count, initialAnchorInfo); //init!

            //add to anchor list
            anchorObjList.Add(currAnchorObj);
            MessageManager.Instance.DebugMessage(string.Format("New anchor spawned, ID: '{0}'", activityId));
        }