private void Awake() { if (instance == null) { instance = this; } else { Destroy(this.gameObject); } }
protected void DoInAir() { if (target != null) { if (target.transform.position.y > head.transform.position.y || (goingRight && target.transform.position.x + grabRangeTargetingOffest < torsoRB.position.x) || (!goingRight && target.transform.position.x - grabRangeTargetingOffest > torsoRB.position.x)) { Debug.Log(gameObject.name + " gave up on targeting " + targetGrabTarget.gameObject.name); if (target.transform.position.y > head.transform.position.y) { Debug.Log("Because target.transform.position.y " + target.transform.position.y + " > head.transform.position.y " + head.transform.position.y); } else if (goingRight && target.transform.position.x + grabRangeTargetingOffest < torsoRB.position.x) { Debug.Log("Because goingRight && target.transform.position.x + grabRangeTargetingOffest < torsoRB.position.x"); } else { Debug.Log("Because !goingRight && target.transform.position.x-grabRangeTargetingOffest > torsoRB.position.x"); } target = null; targetGrabTarget = null; } else { torsoRB.MovePosition(Vector2.MoveTowards(torsoRB.position, target.transform.position, targetMoveSpeed * Time.deltaTime)); upperArmsRB.MovePosition(Vector2.MoveTowards(upperArmsRB.position, target.transform.position, targetMoveSpeed * Time.deltaTime)); if (Mathf.Abs(upperArmsRB.position.x - target.transform.position.x) <= grabRange && Mathf.Abs(upperArmsRB.position.y - target.transform.position.y) <= grabRange) { Debug.Log(gameObject.name + " is attempting to attach to " + targetGrabTarget.gameObject.name); //+ " returned "+ AttachTo(targetGrabTarget)); AttachTo(targetGrabTarget); } } } if (jumpX - headRB.position.y >= fallDis) { if (punishFall) { TrickGUI.GetInstance().DecreaseScore(10); } AttachToInitial(); } //Debug.Log(jumpX - headRB.position.x); }
void Start() { donnaManager.gameObject.SetActive(duoTrapeze); if (gradedPerformance) { timerText.gameObject.SetActive(true); exitBtn.SetActive(false); } duoTrapeze = false; TouchInputManager t = TouchInputManager.getInstance(); if (t == null) { Destroy(this); } trickGUI = TrickGUI.GetInstance(); t.SubscribeTapListener(this, 0); t.SubscribeSwipeListener(this, 0); if (playerAvatar == null) { Debug.Log("Player Avatar is null"); Destroy(this); } pmt = playerAvatar.GetComponent <PlayerManager_Trapeze>(); if (pmt == null) { Debug.Log("Player Avatar is missing PlayerManager_Trapeze script"); Destroy(this); } if (scriptToLoad != null) { dialogueRunner.Add(scriptToLoad); } if (canTutorial) { tutorialManager.SetActive(true); } }