internal void HatcingComplete() { hatchIndicatorInProgress = null; Destroy(ouHeld.gameObject); ouHeld = null; hatchlingHeld = Instantiate(hatchling, transform).GetComponent <Hatchling>(); hatchlingHeld.transform.localPosition = carryPosition; couldHatch = false; audio.PlayOneShot(hatched); }
void Start() { r2d = GetComponent <Rigidbody2D>(); anim = GetComponent <Animator>(); wallsLayer = LayerMask.GetMask("Walls"); ouLayer = LayerMask.NameToLayer("Ou"); nestLayer = LayerMask.NameToLayer("Nest"); houseLayer = LayerMask.NameToLayer("House"); ouHeld = null; couldHatch = false; hatchIndicatorInProgress = null; audio = GetComponent <AudioSource>(); }
void OnTriggerExit2D(Collider2D other) { if (other.gameObject.layer == nestLayer) { couldHatch = false; if (hatchIndicatorInProgress != null) { Destroy(hatchIndicatorInProgress.gameObject); hatchIndicatorInProgress = null; ouHeld.transform.localPosition = carryPosition; } } }
void Update() { Vector2 velo = r2d.velocity; velo.x = Input.GetAxis(whichPlayer + "Horizontal") * moveSpeed; if (stunIndicatorInProgress == null) { if (hatchIndicatorInProgress == null) { if (Input.GetButtonDown(whichPlayer + "Hatch") && couldHatch) { ouHeld.transform.localPosition = hatchPosition; hatchIndicatorInProgress = Instantiate(hatchIndicator, transform, false).GetComponent <HatchIndicator>(); hatchIndicatorInProgress.player = this; audio.PlayOneShot(hatching); } else if (Input.GetButtonDown(whichPlayer + "Fire") && ouHeld != null) { ouHeld.Throw((facing_left ? -1 : 1) * vrum); ouHeld = null; audio.PlayOneShot(shoot); } } else { if (Input.GetButtonUp(whichPlayer + "Hatch")) { Destroy(hatchIndicatorInProgress.gameObject); hatchIndicatorInProgress = null; ouHeld.transform.localPosition = carryPosition; } } } if (Mathf.Abs(velo.y) >= 1) // if jumping { anim.SetBool("isJumpingRight", !facing_left); anim.SetBool("isJumpingLeft", facing_left); anim.SetBool("isWalkingLeft", false); anim.SetBool("isWalkingRight", false); } else { anim.SetBool("isJumpingRight", false); anim.SetBool("isJumpingLeft", false); if (velo.x != 0) { facing_left = velo.x < 0; anim.SetBool("isWalkingLeft", facing_left); anim.SetBool("isWalkingRight", !facing_left); } else { anim.SetBool("isWalkingRight", false); anim.SetBool("isWalkingLeft", false); } } // Handle pause if (Input.GetButtonDown("Cancel")) { //if (controlsEnabled) { // freeze(); // Universe.TogglePause(() => defrost()); //} //else { // Universe.TogglePause(); //} } }