Exemple #1
0
    protected override void Initialize()
    {
        this.GetComponent <Camera>().cullingMask = ~LayerMask.GetMask("UI");

        _inputGetKeyComponent = new InputComponent(KeyKind.GETKEY);
        _inputGetKeyComponent.Bind(KeyCode.W, () => this.transform.Translate(Vector3.up * 20.0f * Time.deltaTime));
        _inputGetKeyComponent.Bind(KeyCode.A, () => this.transform.Translate(Vector3.left * 20.0f * Time.deltaTime));
        _inputGetKeyComponent.Bind(KeyCode.S, () => this.transform.Translate(Vector3.down * 20.0f * Time.deltaTime));
        _inputGetKeyComponent.Bind(KeyCode.D, () => this.transform.Translate(Vector3.right * 20.0f * Time.deltaTime));
    }
    private void InitComponent()
    {
        // 애니메이션
        _animationComponent = new PlayerAnimationComponent(this.GetComponent <Animator>(),
                                                           new string[] { "IsIdle", "IsMove", "IsDead" });
        ((PlayerAnimationComponent)_animationComponent).Player = this.transform;
        // 인풋
        _inputGetKeyComponent = new InputComponent(KeyKind.GETKEY);
        _inputGetKeyComponent.Bind(KeyCode.W, MoveTop);
        _inputGetKeyComponent.Bind(KeyCode.A, MoveLeft);
        _inputGetKeyComponent.Bind(KeyCode.S, MoveDown);
        _inputGetKeyComponent.Bind(KeyCode.D, MoveRight);
        _inputGetKeyComponent.Bind(KeyCode.Mouse0, Attack);
        _inputGetKeyComponent.Idle = Idle;

        _inputGetKeyDownComponent = new InputComponent(KeyKind.GETKEY_DOWN);
        _inputGetKeyDownComponent.Bind(KeyCode.T, Toggle);
        _inputGetKeyDownComponent.Bind(KeyCode.Space, UseItem);
        _inputGetKeyDownComponent.Bind(KeyCode.Mouse1, Teleportation);
    }