Exemplo n.º 1
0
 private void TryDismissObject(PhotoObject obj)
 {
     if (showerDic.ContainsKey(obj))
     {
         PhotoObjectShower shower = showerDic[obj];
         showerDic.Remove(obj);
         Destroy(shower.gameObject);
     }
 }
Exemplo n.º 2
0
 private void TryNotifyObject(PhotoObject obj, Vector2 screenPos)
 {
     if (showerDic.ContainsKey(obj))
     {
         PhotoObjectShower shower = showerDic[obj];
         shower.UpdateShower(screenPos);
     }
     else
     {
         showerDic.Add(obj, UIController.InstantiateNewObjectShower());
         showerDic[obj].UpdateShower(screenPos);
     }
 }
Exemplo n.º 3
0
        void wc_DownloadStringCompleted(object sender, System.Net.DownloadStringCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                return;
            }
            var type = JObject.Parse(e.Result).SelectToken("type").ToString();
            var id   = JObject.Parse(e.Result).SelectToken("id").ToString();

            postAnswer.Add("access_token", App.AccessToken);
            postAnswer.Add("id", id);
            switch (type)
            {
            case "hometown":
                hometown = JsonConvert.DeserializeObject <HometownObject>(e.Result);
                setHometown();
                break;

            case "music":
                music = JsonConvert.DeserializeObject <MusicObject>(e.Result);
                setMusic();
                break;

            case "book":
                book = JsonConvert.DeserializeObject <BookObject>(e.Result);
                setBook();
                break;

            case "movie":
                movie = JsonConvert.DeserializeObject <MovieObject>(e.Result);
                setMovie();
                break;

            case "photo":
                photo = JsonConvert.DeserializeObject <PhotoObject>(e.Result);
                setPhoto();
                break;
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Analyze the list of photoObjects and try to interact with them. If certain circumstances are met, it will also call to take a screenshot and save it into the gallery.
 /// </summary>
 /// <returns>The photo objects.</returns>
 /// <param name="po">Po.</param>
 public IEnumerator ProcessPhotoObject(PhotoObject po)
 {
     yield return(null);
 }
Exemplo n.º 5
0
    /// <summary>
    /// Determines the objects that could be taken.
    /// </summary>
    private void DetermineItems()
    {
        float       centerDis     = 2f;
        PhotoObject tempHighlight = null;

        foreach (PickUpItem item in allPickUpItems)
        {
            Vector2 screenPosition           = _camera.WorldToScreenPoint(item.transform.position);
            Consts.ObjectSituation situation = item.DetermineAvailability(inventoryState, screenPosition, photoThresold, currentDistance);
            if (situation != Consts.ObjectSituation.Irrelevant)
            {
                RaycastHit hit;
                if (Physics.Raycast(new Ray(transform.position, Vector3.Normalize(item.transform.position - transform.position)), out hit, currentDistance))
                {
                    if (hit.collider.gameObject == item.gameObject)
                    {
                        situation = Consts.ObjectSituation.OK;
                    }
                    else
                    {
                        situation = Consts.ObjectSituation.Irrelevant;
                    }
                }
                else
                {
                    situation = Consts.ObjectSituation.Irrelevant;
                }
            }
            if (situation != Consts.ObjectSituation.Irrelevant)
            {
                TryNotifyObject(item, screenPosition);
                Vector2 itemPos = new Vector2(screenPosition.x / Screen.width - 0.5f, screenPosition.y / Screen.height - 0.5f);
                if (itemPos.magnitude < centerDis)
                {
                    centerDis     = itemPos.magnitude;
                    tempHighlight = item;
                }
            }
            else
            {
                TryDismissObject(item);
                if (item == highlightedObject)
                {
                    highlightedObject = null;
                }
            }
        }

        foreach (InteractableObject item in allInteractables)
        {
            Vector2 screenPosition           = _camera.WorldToScreenPoint(item.transform.position);
            Consts.ObjectSituation situation = item.DetermineAvailability(inventoryState, screenPosition, photoThresold, currentDistance);
            if (situation != Consts.ObjectSituation.Irrelevant)
            {
                RaycastHit hit;
                if (Physics.Raycast(new Ray(transform.position, Vector3.Normalize(item.transform.position - transform.position)), out hit, currentDistance))
                {
                    if (hit.collider.gameObject == item.gameObject)
                    {
                        situation = Consts.ObjectSituation.OK;
                    }
                    else
                    {
                        situation = Consts.ObjectSituation.Irrelevant;
                    }
                }
                else
                {
                    situation = Consts.ObjectSituation.Irrelevant;
                }
            }
            if (situation != Consts.ObjectSituation.Irrelevant)
            {
                TryNotifyObject(item, screenPosition);
                Vector2 itemPos = new Vector2(screenPosition.x / Screen.width - 0.5f, screenPosition.y / Screen.height - 0.5f);
                if (itemPos.magnitude < centerDis)
                {
                    centerDis     = itemPos.magnitude;
                    tempHighlight = item;
                }
                else
                {
                    TryDismissObject(item);
                    if (item == highlightedObject)
                    {
                        highlightedObject = null;
                    }
                }
            }
        }

        foreach (RealPicture pic in allRealPictures)
        {
            Consts.ObjectSituation detResult = pic.DetermineAvailability(inventoryState, new Vector2(0f, 0f), photoThresold, currentDistance);
            if (detResult == Consts.ObjectSituation.OK)
            {
                foreach (KeyValuePair <PhotoObject, PhotoObjectShower> obj in showerDic)
                {
                    TryDismissObject(obj.Key);
                }
                highlightedObject = pic;
                return;
            }
        }

        if (tempHighlight != null && tempHighlight != highlightedObject)
        {
            TryDownlight();
            highlightedObject = tempHighlight;
        }

        if (highlightedObject)
        {
            TryHighlight();
        }
    }