示例#1
0
    public void SetState(CH_STATE newState)
    {
        isNewState = true;
        CHState    = newState;

        m_Anim.SetInteger("state", (int)CHState);
    }
示例#2
0
 //잠시시간동안 아무기능도 작동하지않음
 void CollsionFalse()
 {
     collisionFalseTime += Time.deltaTime;
     if (collisionFalseTime > 0.1f)
     {
         collisionFalseTime = 0;
         eState             = CH_STATE.Airborne;
     }
 }
示例#3
0
    //점프하기
    void JumpUpdate()
    {
        if (JumpKeyDown == true)
        {
            jump.Play();
            rb.AddForce(new Vector3(0, jumpPower, 0), ForceMode2D.Impulse);

            eState = CH_STATE.Collsion_False;
        }
    }
示例#4
0
    // Start is called before the first frame update
    void Start()
    {
        startPos   = transform.position;
        rb         = GetComponent <Rigidbody2D>();
        constForce = GetComponent <ConstantForce2D>();
        ani        = transform.GetChild(0).GetComponent <Animator>();

        eState = CH_STATE.Stand;

        forceTime = 0;
    }
示例#5
0
 //조인트 붙이는 부분
 public void OnStick(Collision2D col)
 {
     if (col.transform.tag != "Player" && col.transform.tag != "Ground")
     {
         joint = gameObject.AddComponent <FixedJoint2D>();
         joint.connectedBody   = col.rigidbody;
         joint.enableCollision = true;
         //rb.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezePositionZ;
         rb.constraints = RigidbodyConstraints2D.None;
         eState         = CH_STATE.Sticking;
     }
 }
示例#6
0
 //바닥인지 판단하기
 void CheckGround()
 {
     if (DownCollider.GetComponent <DownCollider>().onCol == true)
     {
         if (eState == CH_STATE.Airborne)
         {
             eState = CH_STATE.Stand;
         }
     }
     else
     {
         eState = CH_STATE.Airborne;
     }
 }
示例#7
0
    //스틱키를 입력하는 부분
    void OnStickKey()
    {
        if (StickKeyDown)
        {
            isStickKeyDown = true;
        }

        else if (StickKeyUp)
        {
            isStickKeyDown = false;
            if (joint != null)
            {
                Destroy(joint);
                rb.constraints        = RigidbodyConstraints2D.FreezeRotation;
                constForce.force      = Vector2.zero;
                constForce.torque     = 0;
                cur_throw_force_value = Vector2.zero;
            }

            eState = CH_STATE.Airborne;
        }
    }
示例#8
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        jumpCol = true;
        switch (eState)
        {
        case CH_STATE.Stand:
            break;

        case CH_STATE.Airborne:
            //탄성 충돌 (수정)
            if (isStickKeyDown == false)
            {
                if (Mathf.Abs(ch_before_velocity.y) > bounce_skip_velocity.y)
                {
                    eState      = CH_STATE.Collsion_False;
                    rb.velocity = Vector3.Reflect(new Vector3(ch_before_velocity.x, ch_before_velocity.y, 0), collision.contacts[0].normal);
                    float velY = rb.velocity.y * 0.7f;
                    rb.velocity = new Vector2(rb.velocity.x, velY);
                }
            }
            break;

        case CH_STATE.Sticking:
            break;

        case CH_STATE.Throw_Force:
            break;

        default:
            break;
        }
        //외부 충돌하면 제자리로
        if (collision.transform.name == "OutSide")
        {
            transform.position = startPos;
            rb.velocity        = Vector2.zero;
        }
    }
示例#9
0
 protected virtual void OnEnable()
 {
     CHState = CH_STATE.Idle;
     StartCoroutine(FSMMain());
 }