void Start() { ladder = GetComponent <ladder>(); anim = GetComponent <Animator>(); anim.SetBool("isDead", false); // setting isdead to false so the player will not start with the dead animation anim.SetBool("upLadder", false); }
public static void Main(string[] args) { int n = Convert.ToInt32(Console.ReadLine()); ladder l = new ladder(); l.printLegs(); for (int i = 0; i < n; i++) { Console.WriteLine("*****"); l.printLegs(); } }
// OnStateEnter is called before OnStateEnter is called on any state inside this state machine override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { actor = GameObject.FindGameObjectsWithTag("Player")[0].GetComponent <character>(); if (stateInfo.IsName("climb_up_right") || stateInfo.IsName("climb_up_left")) { ladder aLadder = actor.aLadder.GetComponent <ladder>(); if (actor.aLadder.MoveUp()) { actor.animator.SetTrigger("climb_end"); animator.SetBool("climbing", false); actor.isClimbing = false; actor.rigidbody.isKinematic = false; actor.rigidbody.MovePosition(aLadder.transform.TransformPoint(aLadder.steps[aLadder.stepCount - 1])); } else { actor.rigidbody.MovePosition(aLadder.transform.TransformPoint(aLadder.steps[aLadder.currentStep])); } } else if (stateInfo.IsName("climb_down_right") || stateInfo.IsName("climb_down_left")) { if (actor.aLadder.MoveDown()) { actor.animator.SetTrigger("climb_end"); animator.SetBool("climbing", false); actor.isClimbing = false; actor.rigidbody.isKinematic = false; } else { ; } } if (stateInfo.IsName("idle_jump") || stateInfo.IsName("walk_jump") || stateInfo.IsName("run_jump")) { animator.ResetTrigger("landing"); } }
private void OnTriggerEnter(Collider other) { if (other.tag == "VaultObject" && !animator.GetCurrentAnimatorClipInfo(0)[0].clip.name.Contains("vault")) { hudscript.setAction(ActionTypes.Vault); aVaultObject = other.GetComponent <vaultObject>(); canVault = true; animPosition = (Vector3.Distance(transform.position, aVaultObject.transform.TransformPoint(aVaultObject.curve[0])) > Vector3.Distance(transform.position, aVaultObject.transform.TransformPoint(aVaultObject.curve[aVaultObject.curve.Length - 1]))); } if (other.tag == "slideObject") { hudscript.setAction(ActionTypes.Slide); aVaultObject = other.GetComponent <vaultObject>(); canSlide = true; animPosition = (Vector3.Distance(transform.position, aVaultObject.transform.TransformPoint(aVaultObject.curve[0])) > Vector3.Distance(transform.position, aVaultObject.transform.TransformPoint(aVaultObject.curve[aVaultObject.curve.Length - 1]))); } if (other.tag == "ladder") { hudscript.setAction(ActionTypes.HoldLadder); aLadder = other.GetComponent <ladder>(); canClimb = true; } if (other.tag == "ground") { isGrounded = true; if (animator.GetCurrentAnimatorClipInfo(0)[0].clip.name.Contains("_jump") || animator.GetCurrentAnimatorClipInfo(0)[0].clip.name.Contains("falling") || animator.GetCurrentAnimatorClipInfo(0)[0].clip.name.Contains("pullup")) { animator.SetTrigger("landing"); } } if (other.tag == "slopeGround") { isGrounded = true; if (animator.GetCurrentAnimatorClipInfo(0)[0].clip.name.Contains("_jump") || animator.GetCurrentAnimatorClipInfo(0)[0].clip.name.Contains("falling")) { animator.SetTrigger("landing"); } if (Quaternion.Angle(other.transform.rotation, Quaternion.Euler(0, other.transform.rotation.eulerAngles.y, other.transform.rotation.eulerAngles.z)) > 15.0f) { aVaultObject = other.GetComponent <vaultObject>(); if (Vector3.Distance(aVaultObject.transform.TransformPoint(aVaultObject.curve[1]), transform.position) < 5.0f) { Vector3 apos = (aVaultObject.transform.position - transform.position), bpos = transform.forward; apos.y = bpos.y = 0; if (Vector3.Angle(apos, bpos) < 30 && Vector3.Angle(apos, bpos) > -30) { animator.SetBool("ski", true); rigidbody.isKinematic = true; Vector3 r = transform.rotation.eulerAngles; r.x = aVaultObject.transform.rotation.eulerAngles.x; rigidbody.MoveRotation(Quaternion.Euler(r)); } } } } if (other.tag == "holdable") { canHold = true; aVaultObject = other.GetComponent <vaultObject>(); } if (other.tag == "slip") { animator.SetTrigger("slip"); } if (other.tag == "coin") { Destroy(other.gameObject); hudscript.setCoinCount(++coin); } if (other.tag == "Finish") { finish ff = other.GetComponent <finish>(); GetComponent <AudioSource>().clip = finishmusic; GetComponent <AudioSource>().Play(); ff.animator.SetTrigger("open"); isGameDone = true; Screen.lockCursor = false; hudscript.GameFinish(); } if (other.tag == "deadzone") { hudscript.Dead(); Screen.lockCursor = false; } }