public void OnPointerEnter(PointerEventData eventData) { if (companion == null) { CanvasScript.instance.companionInfo.SetActive(false); return; } Vector3 cameraPos = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, Camera.main.nearClipPlane)); Vector3 infoPos = Camera.main.ScreenToWorldPoint(this.transform.position); if (cameraPos.x + 6.4 > infoPos.x + 3.0f) { CanvasScript.instance.companionInfo.transform.position = new Vector3(this.transform.position.x + 420.0f, this.transform.position.y, this.transform.position.z); } else if (cameraPos.x < infoPos.x - 3.0f) { CanvasScript.instance.companionInfo.transform.position = new Vector3(this.transform.position.x - 420.0f, this.transform.position.y, this.transform.position.z); } CanvasScript.instance.companionInfo.SetActive(true); CompanionInfoScript companionInfo = CanvasScript.instance.companionInfo.GetComponent <CompanionInfoScript>(); companionInfo.health.text = "Health: " + this.companion.health; companionInfo.companionName.text = this.companion.actorName; companionInfo.damage.text = "Damage: " + companion.damage.ToString(); companionInfo.value.text = "Value: " + companion.coinToDrop.ToString(); companionInfo.companionIcon.sprite = companion.actorIcon; companionInfo.companionSprite.sprite = companion.GetComponentInChildren <SpriteRenderer>().sprite; }
public override void Init(Blackboard blackboard) { this.blackboard = blackboard; companion = blackboard.GetValueFromKey <Companion>("companion"); eyes = companion.GetComponentInChildren <AISight>(); }