示例#1
0
    //Move
    void UpdateInput()
    {
        if (InputManager.Instance.IsMouseDown())
        {
            Vector3 mousePosition = InputManager.Instance.GetCursorPosition();

            Ray        ray = Camera.main.ScreenPointToRay(mousePosition);
            RaycastHit hit;

            LayerMask layerMask = (1 << LayerMask.NameToLayer("Ground")) | (1 << LayerMask.NameToLayer("Character"));


            if (Physics.Raycast(ray, out hit, 100.0f, layerMask))
            {
                if (hit.collider.gameObject.layer == LayerMask.NameToLayer("Ground"))
                {
                    _targetPosition = hit.point;
                    _targetObj      = null;
                    _isSetPosition  = true;
                    //_stateList[_stateType].UpdateInput();
                }

                else if (hit.collider.gameObject.layer == LayerMask.NameToLayer("Character"))
                {
                    HitArea   hitArea   = hit.collider.gameObject.GetComponent <HitArea>();
                    Character character = hitArea.GetCharacter();

                    switch (character.GetCharacterType())
                    {
                    case eCharacterType.MONSTER:
                        //적
                        Debug.Log("MONSTER");
                        //_targetPosition = hit.collider.gameObject.transform.position;
                        _targetObj = hit.collider.gameObject;
                        ChangeState(eState.CHASE);
                        break;
                    }
                }
            }
        }

        if (InputManager.Instance.IsAttackButtonDown())
        {
            ChangeState(eState.ATTACK);
        }
    }
示例#2
0
    void UpdateInput()
    {
        if (InputManager.Instance.IsMouseDown())
        {
            Vector3 mousePosition = InputManager.Instance.GetCursorPosition();

            Ray        ray = Camera.main.ScreenPointToRay(mousePosition);
            RaycastHit hitInfo;
            if (Physics.Raycast(ray, out hitInfo, 100.0f, 1 << LayerMask.NameToLayer("Ground")
                                | 1 << LayerMask.NameToLayer("HitArea")))
            {
                if (LayerMask.NameToLayer("Ground") == hitInfo.collider.gameObject.layer)
                {
                    _targetPosition    = hitInfo.point;
                    _targetObject      = null;
                    _isSetMovePosition = true;
                    //_stateMap[_stateType].UpdateInput();
                }

                if (LayerMask.NameToLayer("HitArea") == hitInfo.collider.gameObject.layer)
                {
                    HitArea   hitDetector = hitInfo.collider.GetComponent <HitArea>();
                    Character character   = hitDetector.GetCharacter();
                    switch (character.GetCharacterType())
                    {
                    case eCharacterType.MONSTER:
                        //적으로 파악 => 추적 state
                        _targetObject = hitInfo.collider.gameObject;
                        ChangeState(eState.CHASE);
                        break;
                    }
                }
            }
        }

        //for test
        if (InputManager.Instance.IsAttackButtonDown())
        {
            ChangeState(eState.ATTACK);
        }
    }
示例#3
0
    void UpdateInput()
    {
        if (InputManager.Instance.IsMouseDown(InputManager.eButtonSort.LEFT_BUTTON))
        {
            Vector3    mousePosition = InputManager.Instance.GetCursorPosition();
            Ray        ray           = Camera.main.ScreenPointToRay(mousePosition);
            RaycastHit hitInfo;
            if (Physics.Raycast(ray, out hitInfo, 100.0f, 1 << LayerMask.NameToLayer("Ground")
                                | 1 << LayerMask.NameToLayer("Character")))
            {
                if (LayerMask.NameToLayer("Ground") == hitInfo.collider.gameObject.layer)
                {
                    _targetPosition    = hitInfo.point;
                    _targetObject      = null;
                    _isSetMovePosition = true;
                    //_stateDictionary[_stateType].UpdateInput();
                }
                if (LayerMask.NameToLayer("Character") == hitInfo.collider.gameObject.layer)
                {
                    //Character character = hitInfo.collider.gameObject.GetComponent<Character>();
                    HitArea   hitArea   = hitInfo.collider.GetComponent <HitArea>();
                    Character character = hitArea.GetCharacter();
                    switch (character.GetCharacterType())
                    {
                    case eCharacterType.MONSTER:
                        Debug.Log("몬스터다 깽깽이들아");
                        _targetPosition    = hitInfo.collider.gameObject.transform.position;
                        _targetObject      = hitInfo.collider.gameObject;
                        _isSetMovePosition = true;
                        ChangeState(eState.CHASE);
                        break;
                    }
                }
            }
        }

        //if (InputManager.Instance.IsAttackButtonDown())
        //{
        //    ChangeState(eState.ATTACK);
        //}
    }