public void Initialize(Sprite sprite, Sprite rateSprite, string poiID, string categoryName) { Destroy(this.GetComponent <PoiPoint>()); this.name = "collect"; this.ID = poiID; this.categoryName = categoryName; img = this.GetComponent <Image>(); img.sprite = sprite; img.type = Image.Type.Filled; img.fillMethod = Image.FillMethod.Vertical; img.fillAmount = 0; this.GetComponent <RectTransform>().sizeDelta = new Vector2(30, 30); GameObject poiRate = (GameObject)Instantiate(this.gameObject, this.transform.position, this.transform.rotation); poiRate.isStatic = true; poiRate.transform.SetParent(this.transform); PoiRate pr = poiRate.AddComponent <PoiRate>(); pr.Initialize(rateSprite, ID); }
void Update() { img.enabled = true; this.transform.GetChild(0).gameObject.SetActive(true); /* POI IS INVISIBLE */ if (!onScreen) { if (Vector2.Distance(this.transform.position, userPosition.position) < 100) { anim.Play("in"); onScreen = true; } } /* POI IS VISIBLE */ else { this.transform.rotation = userPosition.rotation; if (!poiCollect.isCollected) { if (Vector2.Distance(this.transform.position, userPosition.position) > 100) { anim.Play("out"); onScreen = false; } else if (Vector2.Distance(this.transform.position, userPosition.position) < 65) { poiCollect.collectPOI(0.3f); } else { poiCollect.cancelCollectPOI(); } } else { PoiRate pr = this.GetComponentInChildren <PoiRate>(); if (Vector2.Distance(this.transform.position, userPosition.position) < 65) { if (!onRate) { pr.enableRating(); rtController.ratedPOIS[categoryID].Add(this); onRate = true; } } else { if (onRate && !uiController.isUIActive) { pr.disableRating(); rtController.ratedPOIS[categoryID].Remove(this); onRate = false; } } } } if (!uiController.poiFilters[categoryID]) { rtController.ratedPOIS[categoryID].Remove(this); onRate = false; img.enabled = false; poiCollect.instantCancelCollectPOI(); this.transform.GetChild(0).gameObject.SetActive(false); } }