Exemple #1
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();
     }
 }
Exemple #2
0
 public void Jump()
 {
     isClimbing      = true;
     targetDirection = new Vector3(0, 1, 0);
     AnimatorRunner.Run(animator, Constants.AnimationTuples.climbAnimation);
     stepManager.Notify();
 }
Exemple #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();
     }
 }
Exemple #4
0
    void OpenIKWindow(bl_NetworkGun script)
    {
        AnimatorRunner window = (AnimatorRunner)EditorWindow.GetWindow(typeof(AnimatorRunner));

        window.Show();
        bl_PlayerSync pa   = script.transform.root.GetComponent <bl_PlayerSync>();
        Animator      anim = pa.m_PlayerAnimation.m_animator;

        pa.m_PlayerAnimation.EditorSelectedGun = script;
        bl_PlayerIK hm = pa.m_PlayerAnimation.GetComponentInChildren <bl_PlayerIK>(true);

        if (hm != null)
        {
            hm.enabled = true;
        }
        window.SetAnim(anim);
        Selection.activeObject = script.LeftHandPosition.gameObject;
    }
Exemple #5
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();
         }
     }
 }
Exemple #6
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);
        }
    }
Exemple #7
0
 public void FinishShooting()
 {
     isShooting = false;
     AnimatorRunner.Run(animator, Constants.AnimationTuples.stopShootAnimation);
 }
Exemple #8
0
 public void Shoot()
 {
     isShooting = true;
     AnimatorRunner.Run(animator, Constants.AnimationTuples.shootAnimation);
 }
Exemple #9
0
 public void FinishJump()
 {
     isClimbing       = false;
     isClimbingFinish = true;
     AnimatorRunner.Run(animator, Constants.AnimationTuples.stopClimbAnimation);
 }
Exemple #10
0
 public void FinishThrowOver()
 {
     isClimbing       = false;
     isClimbingFinish = true;
     AnimatorRunner.Run(animator, Constants.AnimationTuples.stopThrowOverAnimation);
 }
Exemple #11
0
 public void ThrowOver()
 {
     isClimbing = true;
     AnimatorRunner.Run(animator, Constants.AnimationTuples.throwOverAnimation);
     stepManager.Notify();
 }