示例#1
0
 public void Jump()
 {
     isClimbing      = true;
     targetDirection = new Vector3(0, 1, 0);
     AnimatorRunner.Run(animator, Constants.AnimationTuples.climbAnimation);
     stepManager.Notify();
 }
示例#2
0
 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();
     }
 }
示例#3
0
 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();
     }
 }
示例#4
0
 // 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();
         }
     }
 }
示例#5
0
    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);
        }
    }
示例#6
0
 public void FinishShooting()
 {
     isShooting = false;
     AnimatorRunner.Run(animator, Constants.AnimationTuples.stopShootAnimation);
 }
示例#7
0
 public void Shoot()
 {
     isShooting = true;
     AnimatorRunner.Run(animator, Constants.AnimationTuples.shootAnimation);
 }
示例#8
0
 public void FinishJump()
 {
     isClimbing       = false;
     isClimbingFinish = true;
     AnimatorRunner.Run(animator, Constants.AnimationTuples.stopClimbAnimation);
 }
示例#9
0
 public void FinishThrowOver()
 {
     isClimbing       = false;
     isClimbingFinish = true;
     AnimatorRunner.Run(animator, Constants.AnimationTuples.stopThrowOverAnimation);
 }
示例#10
0
 public void ThrowOver()
 {
     isClimbing = true;
     AnimatorRunner.Run(animator, Constants.AnimationTuples.throwOverAnimation);
     stepManager.Notify();
 }