// Use this for initialization void Start() { inventory = GetComponent <Inventory>(); movementScript = GetComponent <PlayerMovement>(); anim = GetComponent <Animator>(); goBackPositionStack = new Stack <Vector3>(); feedbackScript = GetComponent <UIFeedback>(); }
private void FixedUpdate() { // Vector3 newPositon = transform.position + (direction * speed * Time.deltaTime); Vector3 newScreenPosition = Camera.main.WorldToScreenPoint(newPositon); if (newScreenPosition.x > 0f && newScreenPosition.x < Screen.width && newScreenPosition.y > 0f && newScreenPosition.y < Screen.height) { transform.position = newPositon; } // Physics // Check Feedback PointerEventData pointerData = new PointerEventData(EventSystem.current); pointerData.position = Camera.main.WorldToScreenPoint(transform.position); List <RaycastResult> results = new List <RaycastResult>(); EventSystem.current.RaycastAll(pointerData, results); if (results.Count > 0) { UIFeedback fb = results[0].gameObject.GetComponent <UIFeedback>(); if (fb != null) { if (fb.checkDeadZone == true) { RectTransform fbRect = fb.image.GetComponent <RectTransform>(); Vector3 fbPosition = fbRect.position; float widht = fbRect.rect.width * fb.parentCanvas.scaleFactor; float distance = Vector2.Distance(pointerData.position, fbPosition); if (distance <= (widht / 2f)) { curFeedback = fb; } else { curFeedback = null; } } else { curFeedback = fb; } results.Clear(); } else { curFeedback = null; } } else { curFeedback = null; } if (curFeedback != null && pressFire) { curFeedback.Activate(player); } // Check suncollider RaycastHit hitInfo; if (Physics.Raycast(Camera.main.transform.position, _sun.transform.position - Camera.main.transform.position, out hitInfo, 1000f, LayerMask.NameToLayer("PERSO"))) { PlayerAvatar m = hitInfo.transform.GetComponent <PlayerAvatar>(); _sun.f**k.SetActive(true); if (m != null && m.player.playerId == this.player.playerId && _sun.enabled) { if (pressFire) { _sun.p.Launch(player, player.opponent, 0); FMODUnity.RuntimeManager.PlayOneShot("event:/SFX/sun-influence"); FMODUnity.RuntimeManager.PlayOneShot("event:/SFX/moon-influence"); if (this.player.playerId == 1) { FMODUnity.RuntimeManager.PlayOneShot("event:/SFX/good-stinger"); } else { FMODUnity.RuntimeManager.PlayOneShot("event:/SFX/evil-stinger"); } } } } else { _sun.f**k.SetActive(false); } pressFire = false; }
// Use this for initialization void Start() { movementScript = GetComponentInParent <PlayerMovement>(); interactionScript = GetComponentInParent <PlayerInteraction>(); feedbackScript = GetComponentInParent <UIFeedback>(); }
// Use this for initialization void Start() { interacting = false; movementScript = GetComponentInParent <PlayerMovement>(); feedbackScript = GetComponentInParent <UIFeedback>(); }