public void Jump() { isClimbing = true; targetDirection = new Vector3(0, 1, 0); AnimatorRunner.Run(animator, Constants.AnimationTuples.climbAnimation); stepManager.Notify(); }
public void MoveRight() { if (!isMoving) { FaceRight(); if (!CanMoveRight() && CanThrowOverRight()) { ThrowOver(); targetDirection = new Vector3(tileWidth, 1, 0); } else { isMoving = true; AnimatorRunner.Run(animator, Constants.AnimationTuples.moveAnimation); startPosition = transform.position; if (CanMoveRight()) { targetDirection = new Vector3(-tileWidth, 0f, 0f); } else { targetDirection = Vector3.zero; } finalPosition = startPosition - targetDirection; } stepManager.Notify(); } }
public void Fall() { if (!isMoving) { isMoving = true; AnimatorRunner.Run(animator, Constants.AnimationTuples.fallAnimation); startPosition = transform.position; targetDirection = new Vector3(0f, -tileWidth, 0f); finalPosition = startPosition + targetDirection; stepManager.Notify(); } }
// Update is called once per frame void Update() { if (isDead) { return; } if (WillDead()) { Dead(); } if (isClimbingFinish) { transform.position += targetDirection; transform.position = CorrectedPosition(transform.position); isClimbingFinish = false; } gameObject.SetActive(true); if (isMoving) { time += Time.deltaTime; if (time >= 1.0f / speed) { StartCoroutine(delaySetMoving()); AnimatorRunner.Run(animator, Constants.AnimationTuples.stopMoveAnimation); AnimatorRunner.Run(animator, Constants.AnimationTuples.stopFallAnimation); time = 0; transform.position = CorrectedPosition(finalPosition); } else { transform.Translate(Time.deltaTime * speed * targetDirection); } //Debug.Log (transform.position + " targetDirection " + targetDirection + " finalPosition " + startPosition + targetDirection); } else { if (!IsOnGround()) { Fall(); } } }
public void Dead() { isDead = true; if (isPlayer) { LayerMask mask = LayerMask.GetMask("enemy"); RaycastHit2D hit = Physics2D.Raycast(new Vector2(transform.position.x, transform.position.y), new Vector2(isFacingRight ? 1 : -1, 0), 1f, mask); AnimatorRunner.Run(animator, Constants.AnimationTuples.deadAnimation); } else { LayerMask mask = LayerMask.GetMask("weapon"); RaycastHit2D hit = Physics2D.Raycast(new Vector2(transform.position.x, transform.position.y), new Vector2(isFacingRight ? 1 : -1, 0), 0.1f, mask); GameObject arrow = hit.collider.gameObject.transform.root.gameObject; Debug.Log("arrow" + arrow); arrow.transform.parent = this.spineNode; ArrowScript arrowScript = arrow.GetComponent <ArrowScript> (); arrowScript.StopMoving(); AnimatorRunner.Run(animator, Constants.AnimationTuples.deadAnimation); } }
public void FinishShooting() { isShooting = false; AnimatorRunner.Run(animator, Constants.AnimationTuples.stopShootAnimation); }
public void Shoot() { isShooting = true; AnimatorRunner.Run(animator, Constants.AnimationTuples.shootAnimation); }
public void FinishJump() { isClimbing = false; isClimbingFinish = true; AnimatorRunner.Run(animator, Constants.AnimationTuples.stopClimbAnimation); }
public void FinishThrowOver() { isClimbing = false; isClimbingFinish = true; AnimatorRunner.Run(animator, Constants.AnimationTuples.stopThrowOverAnimation); }
public void ThrowOver() { isClimbing = true; AnimatorRunner.Run(animator, Constants.AnimationTuples.throwOverAnimation); stepManager.Notify(); }