예제 #1
0
 // 공격하기
 void AttackControl()
 {
     if (Input.GetKeyUp(KeyCode.Space) && !BitControl.Get(m_curState, (int)Hero.HERO_STATE.CONTROL_ENERGY_CHARGE))
     {
         m_curState = BitControl.Set(m_curState, (int)Hero.HERO_STATE.ATTACK);
     }
 }
예제 #2
0
    // 가로 이동
    float HorizontalMoveControl()
    {
        float moveX = 0.0f;

        if (Input.GetKey(KeyCode.A))
        {
            m_curState = BitControl.Set(m_curState, (int)Hero.HERO_STATE.MOVE);

            moveX = -m_moveSpeed * Time.deltaTime;

            this.m_skletonAnimation.skeleton.flipX = false;
            //this.GetComponent<SpriteRenderer>().flipX = false;
        }



        if (Input.GetKey(KeyCode.D))
        {
            m_curState = BitControl.Set(m_curState, (int)Hero.HERO_STATE.MOVE);
            moveX      = m_moveSpeed * Time.deltaTime;

            this.m_skletonAnimation.skeleton.flipX = true;
        }
        return(moveX);
    }
예제 #3
0
    // 가로 이동
    float HorizontalMoveControl()
    {
        float moveX = 0.0f;

        if (Input.GetKey(KeyCode.A))
        {
            m_curState = BitControl.Set(m_curState, (int)HERO_STATE.MOVE);

            moveX = -m_moveSpeed * Time.deltaTime;

            this.m_skletonAnimation.skeleton.flipX = false;
            //this.GetComponent<SpriteRenderer>().flipX = false;

            if (m_rigidBody.velocity.x > 0.0f)
            {
                m_rigidBody.velocity = new Vector2(0.0f, m_rigidBody.velocity.y);
            }
        }



        if (Input.GetKey(KeyCode.D))
        {
            m_curState = BitControl.Set(m_curState, (int)HERO_STATE.MOVE);
            moveX      = m_moveSpeed * Time.deltaTime;

            this.m_skletonAnimation.skeleton.flipX = true;
            if (m_rigidBody.velocity.x > 0.0f)
            {
                m_rigidBody.velocity = new Vector2(0.0f, m_rigidBody.velocity.y);
            }
        }
        return(moveX);
    }
    //단순 애니메이션 작업

    void NetworkAnimation()
    {
        if (m_roboState == (int)ROBO_STATE.IDLE) //BitControl.Get(m_roboState, (int)ROBO_STATE.IDLE))
        {
            CheckAndSetAnimation(ANI_IDLE, true);
            // m_skletonAnimation.state.SetAnimation(0, ANI_IDLE, true);
            m_engineAnimator.SetInteger("play", 0);
        }
        else
        {
            if (BitControl.Get(m_roboState, (int)ROBO_STATE.MOVE))
            {
                if (IsCurrentAnimation(ANI_IDLE))
                {
                    m_skletonAnimation.state.SetAnimation(0, ANI_MOVE, true);
                }
                m_engineAnimator.SetInteger("play", 1);
            }
        }
        if (BitControl.Get(m_roboState, (int)ROBO_STATE.ATTACK))
        {
            m_skletonAnimation.state.SetAnimation(0, ANI_ATTACK, false);
            m_roboState = BitControl.Clear(m_roboState, (int)ROBO_STATE.ATTACK);
            m_roboState = BitControl.Set(m_roboState, (int)ROBO_STATE.COOLTIME);
        }
    }
    void ControlGun()
    {
        m_prevAngle = m_gunAngle;
        if (!m_skletonAnimation.skeleton.flipX)
        {
            m_armBone.transform.rotation = Quaternion.Euler(0, 0, m_gunAngle);
        }
        else
        {
            m_armBone.transform.rotation = Quaternion.Euler(0, 0, -m_gunAngle);
        }


        if (Input.GetKey(KeyCode.UpArrow))
        {
            if (m_gunAngle - 1.0f > -360.0f)
            {
                m_gunAngle -= 1.0f;
            }
        }
        if (Input.GetKey(KeyCode.DownArrow))
        {
            if (m_gunAngle + 1.0f < 360.0f)
            {
                m_gunAngle += 1.0f;
            }
        }

        if (ENERGY >= 2.0f && !BitControl.Get(m_roboState, (int)ROBO_STATE.COOLTIME) && Input.GetKeyUp(KeyCode.Space))
        {
            SoundManager.Instance().PlaySound(m_laser1);
            m_roboState = BitControl.Set(m_roboState, (int)ROBO_STATE.ATTACK);
        }

        if (BitControl.Get(m_roboState, (int)ROBO_STATE.ATTACK) &&
            !BitControl.Get(m_roboState, (int)ROBO_STATE.COOLTIME))
        {
            m_skletonAnimation.state.SetAnimation(0, ANI_ATTACK, false);
            StateSend();
            m_roboState = BitControl.Clear(m_roboState, (int)ROBO_STATE.ATTACK);
            m_roboState = BitControl.Set(m_roboState, (int)ROBO_STATE.COOLTIME);

            if (ENERGY >= 2.0f)
            {
                //if (!IsInvoking("EnergyTestUser"))
                //   Invoke("EnergyTestUser" , 0.5f);

                if (m_gunPlayerName.Equals(GameManager.Instance().PLAYER.USER_NAME))
                {
                    ENERGY -= 2.0f;
                    FireBullet();
                }
            }
        }
    }
예제 #6
0
    float VerticalMoveControl()
    {
        float moveY = 0.0f;
        float jump  = 0.0f;

        if (Input.GetKey(KeyCode.W))
        {
            if (m_LadderState)
            {
                m_curState = BitControl.Set(m_curState, (int)Hero.HERO_STATE.MOVE);
                m_curState = BitControl.Set(m_curState, (int)Hero.HERO_STATE.LADDER);
                moveY      = m_moveSpeed * Time.deltaTime;
                m_rigidBody.gravityScale = 0.0f;
                m_rigidBody.velocity     = Vector2.zero;

                m_curState = BitControl.Clear(m_curState, (int)Hero.HERO_STATE.JUMP);
                m_curState = BitControl.Clear(m_curState, (int)Hero.HERO_STATE.JUMP_FALL);
            }
            else if (!BitControl.Get(m_curState, (int)Hero.HERO_STATE.JUMP) &&
                     !BitControl.Get(m_curState, (int)Hero.HERO_STATE.JUMP_FALL))
            {
                // 특정 오브젝트 밟자마자 (점프 안끝났는데) 점프하는 경우 방지
                if (m_rigidBody.velocity.y <= 0.0f)
                {
                    m_curState = BitControl.Set(m_curState, (int)Hero.HERO_STATE.JUMP);
                    jump       = m_jumpPower;
                }
            }
        }

        if (Input.GetKey(KeyCode.S))
        {
            if (m_LadderState)
            {
                m_curState = BitControl.Set(m_curState, (int)Hero.HERO_STATE.MOVE);
                m_curState = BitControl.Set(m_curState, (int)Hero.HERO_STATE.LADDER);
                moveY      = -m_moveSpeed * Time.deltaTime;
                m_rigidBody.gravityScale = 0.0f;
                m_rigidBody.velocity     = Vector2.zero;

                m_curState = BitControl.Clear(m_curState, (int)Hero.HERO_STATE.JUMP);
                m_curState = BitControl.Clear(m_curState, (int)Hero.HERO_STATE.JUMP_FALL);
            }
            else
            {
                //딱히 하는거 없음
            }
        }
        return((BitControl.Get(m_curState, (int)Hero.HERO_STATE.JUMP)) ? jump : moveY);
    }
예제 #7
0
    // 공격하기
    void AttackControl()
    {
        if (Input.GetKeyUp(KeyCode.Space) &&
            !BitControl.Get(m_curState, (int)HERO_STATE.CONTROL_ENERGY_CHARGE))
        {
            m_curState = BitControl.Clear(m_curState, (int)HERO_STATE.ATTACK);
            if (m_skletonAnimation.state.GetCurrent(1) != null)
            {
                m_skletonAnimation.state.ClearTrack(1);
            }

            m_curState = BitControl.Set(m_curState, (int)HERO_STATE.ATTACK);
        }
    }
예제 #8
0
    void ObjectControl()
    {
        // 특정 컨트롤 조작시에 조작키를 눌렀을 때
        if (Input.GetKeyUp(KeyCode.R))
        {
            int state = -1;

            switch (m_userControlName)
            {
            case "ROBOT_HEAL": state = (int)Hero.HERO_STATE.CONTROL_HEAL; break;

            case "ROBOT_DRIVE": state = (int)Hero.HERO_STATE.CONTROL_DRIVE; break;

            case "ROBOT_INVEN": state = (int)Hero.HERO_STATE.CONTROL_INVEN; break;

            case "ROBOT_GUN": state = (int)Hero.HERO_STATE.CONTROL_GUN; break;

            case "ROBOT_OUT_DOOR": state = (int)Hero.HERO_STATE.CONTROL_OUT_DOOR; break;

            case "ROBOT_STATUSVIEW": break;

            case "ROBOT_ENERGY_CHARGE": state = (int)Hero.HERO_STATE.CONTROL_ENERGY_CHARGE; break;
            }
            // SoundManager.Instance().PlaySound(m_interaction);
            if (state > 0)
            {
                m_curState = BitControl.Set(m_curState, state);
            }

            // 실제 오브젝트 작동
            //로봇 조종 체크
            ObjectRoboDriveControlCheck();

            //로봇 총 조작 체크
            ObjectRoboGunControlCheck();

            //행성 나가기 체크
            ObjectRoboOutDoorControlCheck();

            // 힐링 존 체크
            ObjectRoboHealControlCheck();

            // 인벤 체크
            ObjectRoboInvenControlCheck();
        }
    }
    void ControlGun()
    {
        m_prevAngle = m_gunAngle;
        if (!m_skletonAnimation.skeleton.flipX)
        {
            m_armBone.transform.rotation = Quaternion.Euler(0, 0, m_gunAngle);
        }
        else
        {
            m_armBone.transform.rotation = Quaternion.Euler(0, 0, -m_gunAngle);
        }


        if (Input.GetKey(KeyCode.UpArrow))
        {
            if (m_gunAngle - 1.0f > -360.0f)
            {
                m_gunAngle -= 1.0f;
            }
        }
        if (Input.GetKey(KeyCode.DownArrow))
        {
            if (m_gunAngle + 1.0f < 360.0f)
            {
                m_gunAngle += 1.0f;
            }
        }

        if (Input.GetKeyUp(KeyCode.Space) && !BitControl.Get(m_roboState, (int)HeroRobo.ROBO_STATE.COOLTIME))
        {
            SoundManager.Instance().PlaySound(m_laser1);
            m_roboState = BitControl.Set(m_roboState, (int)HeroRobo.ROBO_STATE.ATTACK);
        }

        if (BitControl.Get(m_roboState, (int)HeroRobo.ROBO_STATE.ATTACK))
        {
            m_skletonAnimation.state.SetAnimation(0, ANI_ATTACK, false);
            m_roboState = BitControl.Clear(m_roboState, (int)HeroRobo.ROBO_STATE.ATTACK);
            m_roboState = BitControl.Set(m_roboState, (int)HeroRobo.ROBO_STATE.COOLTIME);

            FireBullet();
        }
    }
예제 #10
0
    void Control()
    {
        Vector2 pos = transform.position;

        //상황 설정
        // 좌 - 우 이동  상  점프 & 사다리  하 사다리
        float moveX = 0.0f;
        float moveY = 0.0f;
        float jump  = 0.0f;

        // 특정 컨트롤을 다루고 있는 상태가 아닐 경우
        //  if(GetMoveAbleCheck())

        // 이동에 관련된 처리를 하는 녀석들 float

        // 가로이동
        moveX = HorizontalMoveControl();

        // 점프 및 수직 이동
        if (BitControl.Get(m_curState, (int)Hero.HERO_STATE.LADDER))
        {
            moveY = VerticalMoveControl();
        }
        else
        {
            jump = VerticalMoveControl();
        }

        // 공격 혹은 수리
        AttackControl();
        // 충전
        ObjectRoboEnergyControlCheck();

        ObjectControl();



        // 이동 애니메이션 체크
        if ((BitControl.Get(m_curState, (int)Hero.HERO_STATE.MOVE) &&
             (Input.GetKeyUp(KeyCode.A) || Input.GetKeyUp(KeyCode.D) || Input.GetKeyUp(KeyCode.W) || Input.GetKeyUp(KeyCode.S))))
        {
            m_curState = BitControl.Clear(m_curState, (int)Hero.HERO_STATE.MOVE);
            if (!BitControl.Get(m_curState, (int)Hero.HERO_STATE.LADDER))
            {
                CheckAndSetAnimation(ANI_IDLE, true);
                m_curState = (int)Hero.HERO_STATE.IDLE;
            }
            else
            {
                m_climb.state.ClearTrack(0);
            }
        }

        // 떨어지는 상태임

        if (!BitControl.Get(m_curState, (int)Hero.HERO_STATE.LADDER))
        {
            if (m_rigidBody.velocity.y < 0.0f)
            {
                m_curState = BitControl.Clear(m_curState, (int)Hero.HERO_STATE.JUMP);
                m_curState = BitControl.Set(m_curState, (int)Hero.HERO_STATE.JUMP_FALL);
            }
            if (m_rigidBody.velocity.y >= 0.0f)
            {
                m_curState = BitControl.Clear(m_curState, (int)Hero.HERO_STATE.JUMP_FALL);
                if (!BitControl.Get(m_curState, (int)Hero.HERO_STATE.MOVE))
                {
                    CheckAndSetAnimation(ANI_IDLE, true);
                }
            }
        }



        // -- 상태값에 따라 애니메이션 처리 및 이동 점프 처리 ----------------------------------------

        if (m_curState == (int)Hero.HERO_STATE.IDLE)
        {
            CheckAndSetAnimation(ANI_IDLE, true);
        }
        else
        {
            if (BitControl.Get(m_curState, (int)Hero.HERO_STATE.JUMP))
            {
                // 점프 ㄱㄱ
                this.m_rigidBody.AddForce(new Vector2(0, jump));
                // IDLE / MOVE 상태일 때만 점프 애니메이션
                if (IsCurrentAnimation(ANI_IDLE))// || IsCurrentAnimation(ANI_MOVE))
                {
                    //레디 -> 점핑 ㄱㄱ
                    m_skletonAnimation.state.SetAnimation(0, ANI_JUMP_READY, false);
                    m_skletonAnimation.state.AddAnimation(0, ANI_JUMP_JUMPING, true, 0f);
                }
            }

            if (BitControl.Get(m_curState, (int)Hero.HERO_STATE.JUMP_FALL))
            {
                //떨어지는 중
                if (!BitControl.Get(m_curState, (int)Hero.HERO_STATE.MOVE))
                {
                    CheckAndSetAnimation(ANI_JUMP_FALL, false);
                }
            }

            if (BitControl.Get(m_curState, (int)Hero.HERO_STATE.MOVE))
            {
                if (!IsCurrentAnimation(ANI_MOVE))
                {
                    m_skletonAnimation.state.SetAnimation(0, ANI_MOVE, true);  //
                }
                this.transform.Translate(new Vector3(moveX, moveY));
            }

            if (BitControl.Get(m_curState, (int)Hero.HERO_STATE.LADDER))
            {
                m_skletonAnimation.enabled = false;
                this.GetComponent <MeshRenderer>().enabled = false;
                m_climb.gameObject.SetActive(true);

                if (BitControl.Get(m_curState, (int)Hero.HERO_STATE.MOVE))
                {
                    if (m_climb.state.GetCurrent(0) != null &&
                        !m_climb.state.GetCurrent(0).animation.name.Equals("animation"))
                    {
                        m_climb.state.SetAnimation(0, "animation", true);
                    }
                    else if (m_climb.state.GetCurrent(0) == null)
                    {
                        m_climb.state.SetAnimation(0, "animation", true);
                    }
                    MDebug.Log("여기");
                }
            }

            //test
            if (BitControl.Get(m_curState, (int)Hero.HERO_STATE.ATTACK))
            {
                m_skletonAnimation.state.SetAnimation(1, ANI_REPAIR, false);
            }
        }
        Debug.DrawLine(pos, new Vector3(pos.x, pos.y - GetComponent <BoxCollider2D>().bounds.size.y, 0.0f), Color.red);
    }
예제 #11
0
 //들어올때
 void RobotInEnd()
 {
     m_skletonAnimation.skeleton.SetSkin("char_01");
     m_skletonAnimation.skeleton.SetToSetupPose();
     m_curState = BitControl.Set(m_curState, (int)Hero.HERO_STATE.LADDER);
 }
    /// <summary>
    /// 캐릭터 조작에 관련된 함수
    /// </summary>
    void Control()
    {
        // 가져다 쓰기 편하기 위해 선언
        Vector3 pos = transform.position;

        // 요생키들이 실제 이동
        float movex = 0;
        float movey = 0;


        if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.RightArrow) ||
            Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.DownArrow))
        {
            m_engineAnimator.SetInteger("play", 1);
            m_roboState      = BitControl.Set(m_roboState, (int)ROBO_STATE.MOVE);
            m_energyUserTick = 0.0f;
        }

        // Horizontal
        if (Input.GetKey(KeyCode.LeftArrow) && ENERGY >= 2)
        {
            if (!IsInvoking("EnergyTestUser"))
            {
                Invoke("EnergyTestUser", 0.5f);
            }

            movex = -m_moveSpeed * Time.deltaTime;

            m_skletonAnimation.skeleton.flipX = false;
        }

        if (Input.GetKey(KeyCode.RightArrow) && ENERGY >= 2)
        {
            if (!IsInvoking("EnergyTestUser"))
            {
                Invoke("EnergyTestUser", 0.5f);
            }
            movex = m_moveSpeed * Time.deltaTime;

            m_skletonAnimation.skeleton.flipX = true;
        }
        // Vertical
        if (Input.GetKey(KeyCode.UpArrow) && ENERGY >= 2)
        {
            if (!IsInvoking("EnergyTestUser"))
            {
                Invoke("EnergyTestUser", 0.5f);
            }
            movey = m_moveSpeed * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.DownArrow) && ENERGY >= 2)
        {
            if (!IsInvoking("EnergyTestUser"))
            {
                Invoke("EnergyTestUser", 0.5f);
            }
            movey = -m_moveSpeed * Time.deltaTime;
        }


        if (BitControl.Get(m_roboState, (int)ROBO_STATE.MOVE) &&
            (Input.GetKeyUp(KeyCode.LeftArrow) || Input.GetKeyUp(KeyCode.RightArrow) ||
             Input.GetKeyUp(KeyCode.UpArrow) || Input.GetKeyUp(KeyCode.DownArrow)))
        {
            //  CheckAndSetAnimation(ANI_IDLE, true);
            m_skletonAnimation.state.SetAnimation(0, ANI_IDLE, true);
            m_roboState = BitControl.Clear(m_roboState, (int)ROBO_STATE.MOVE);
            m_engineAnimator.SetInteger("play", 0);
            //m_roboState = BitControl.Set(m_roboState, (int)ROBO_STATE.IDLE);
        }


        if (m_roboState == (int)ROBO_STATE.IDLE) //BitControl.Get(m_roboState, (int)ROBO_STATE.IDLE))
        {
            CheckAndSetAnimation(ANI_IDLE, true);
            m_engineAnimator.SetInteger("play", 0);
            // m_skletonAnimation.state.SetAnimation(0, ANI_IDLE, true);
        }
        else
        {
            if (BitControl.Get(m_roboState, (int)ROBO_STATE.MOVE))
            {
                transform.Translate(movex, movey, 0);
                if (IsCurrentAnimation(ANI_IDLE))
                {
                    m_skletonAnimation.state.SetAnimation(0, ANI_MOVE, true);
                }
            }
        }
    }
예제 #13
0
    void ControlInSpace()
    {
        Vector2 pos = transform.position;

        //상황 설정
        // 좌 - 우 이동  상  점프 & 사다리  하 사다리
        float moveX = 0.0f;
        float moveY = 0.0f;

        if (Input.GetKey(KeyCode.A))
        {
            m_curState = BitControl.Set(m_curState, (int)HERO_STATE.MOVE);

            moveX = -m_moveSpeed * Time.deltaTime;
            this.m_skletonAnimation.skeleton.flipX = false;
            //this.GetComponent<SpriteRenderer>().flipX = false;
        }



        if (Input.GetKey(KeyCode.D))
        {
            m_curState = BitControl.Set(m_curState, (int)HERO_STATE.MOVE);
            moveX      = m_moveSpeed * Time.deltaTime;
            this.m_skletonAnimation.skeleton.flipX = true;

            //this.GetComponent<SpriteRenderer>().flipX = true;
        }

        if (Input.GetKey(KeyCode.W))
        {
            m_curState = BitControl.Set(m_curState, (int)HERO_STATE.MOVE);
            moveY      = m_moveSpeed * Time.deltaTime;
        }
        else if (Input.GetKey(KeyCode.S))
        {
            m_curState = BitControl.Set(m_curState, (int)HERO_STATE.MOVE);
            moveY      = -m_moveSpeed * Time.deltaTime;
        }

        if (Input.GetKey(KeyCode.S))
        {
            // 요부분에서 사다리를 체크함

            if (BitControl.Get(m_curState, (int)HERO_STATE.MOVE))
            {
                moveY = -m_moveSpeed * Time.deltaTime;
            }
            else
            {
                //딱히 하는거 없음
            }
        }

        // 상호작용 키
        if (Input.GetKey(KeyCode.R))
        {
            //this.m_animator.SetBool("Move", false);
        }

        // 이동 애니메이션 체크
        if (BitControl.Get(m_curState, (int)HERO_STATE.MOVE) &&
            (Input.GetKeyUp(KeyCode.A) || Input.GetKeyUp(KeyCode.D) ||
             (Input.GetKeyUp(KeyCode.W) || Input.GetKeyUp(KeyCode.S))))
        {
            m_curState = BitControl.Clear(m_curState, (int)HERO_STATE.MOVE);
        }

        // 최종

        if (m_curState == (int)HERO_STATE.IDLE)
        {
            CheckAndSetAnimation(ANI_IDLE, true);
        }
        else
        {
            if (BitControl.Get(m_curState, (int)HERO_STATE.MOVE))
            {
                if (IsCurrentAnimation(ANI_IDLE))
                {
                    m_skletonAnimation.state.SetAnimation(0, ANI_MOVE, true);
                }
                this.transform.Translate(new Vector3(moveX, moveY));
            }
        }


//        MoveSend();
    }