private void Awake() { //Find helper scripts MovementScript = GetComponent <couchMovement>(); ActionBox = GetComponentInChildren <couchActionBox>(); InteractScript = GetComponent <couchActionBank>(); //Configure States BaseState = GetComponent <couchBase>(); HoldState = GetComponent <couchHold>(); ThrowState = GetComponent <couchThrow>(); IdleState = GetComponent <couchIdle>(); MovingState = GetComponent <couchMoving>(); AerialState = GetComponent <couchAerial>(); BaseState.Owner = HoldState.Owner = ThrowState.Owner = MovementScript.Owner = this; IdleState.Owner = MovingState.Owner = AerialState.Owner = this; BaseState.move = HoldState.move = ThrowState.move = MovementScript; IdleState.move = MovingState.move = AerialState.move = MovementScript; BaseState.actionBox = HoldState.actionBox = ThrowState.actionBox = ActionBox; BaseState.action = HoldState.action = ThrowState.action = InteractScript; BaseState.foot = HoldState.foot = ThrowState.foot = GroundCollider; IdleState.foot = MovingState.foot = AerialState.foot = GroundCollider; BaseState.enabled = HoldState.enabled = ThrowState.enabled = MovingState.enabled = false; changeState(state.Base); rb = GetComponent <Rigidbody>(); isInteracting = false; pingHold = false; ControllerManager = GameObject.Find("ControllerManager"); reMapStart = ControllerManager.GetComponent <ControllerManager>().reMapStart; reMapTick = ControllerManager.GetComponent <ControllerManager>().reMapTick; ActionBox = transform.Find("CouchPlayerInteractCollider").GetComponent <couchActionBox>(); // Find the canvas attached to player playerCanvas = transform.Find("Canvas").GetComponent <Canvas>(); // Find the player's circle image playerCircle = playerCanvas.transform.Find("CouchPlayerCircle").GetComponent <Image>(); // Set its color to player's color playerCircle.color = playerColor; // Find player's pingle image and set its image to default hidden state //pinga = playerCanvas.transform.Find("Pinger").GetComponent<Image>(); //pinga.gameObject.SetActive(pingHold); }
/*------------------ CARRY FUNCTIONS ------------------*/ public bool PickUp(GameObject item) { if (Time.time > timeStamp && item.tag == "grabbable") { if (item.GetComponent <FixedJoint>() != null) { couchActionBank temp = item.GetComponent <FixedJoint>().connectedBody.transform.parent.GetComponent <couchActionBank>(); temp.Release(); temp.CancelThrow(); } heldItem = item; heldRB = heldItem.GetComponent <Rigidbody>(); StartCoroutine(FinishPickup()); //Will finish at end of frame return(true); } return(false); }