コード例 #1
0
    private void Unlock(KeyCode keyCode, PlayerKeyboardKey.Type type = PlayerKeyboardKey.Type.Wooden)
    {
        if (!this.keys.ContainsKey(keyCode))
        {
            return;
        }

        Action action = null;

        switch (keyCode)
        {
        case KeyCode.W: action = () => this.controller.Run(PlayerController.Command.Jump); break;

        case KeyCode.A: action = () => this.controller.Run(PlayerController.Command.Left); break;

        case KeyCode.S: action = () => this.controller.Run(PlayerController.Command.Stop); break;

        case KeyCode.D: action = () => this.controller.Run(PlayerController.Command.Right); break;

        case KeyCode.Q: action = () => this.controller.Run(PlayerController.Command.WallJumpLeft); break;

        case KeyCode.E: action = () => this.controller.Run(PlayerController.Command.WallJumpRight); break;

        case KeyCode.M: action = () => this.status.Hurt(); break;
        }

        this.Add(keyCode, type, action);
    }
コード例 #2
0
    public void Add(KeyCode keyCode, PlayerKeyboardKey.Type type, Action run)
    {
        if (!this.keys.ContainsKey(keyCode))
        {
            return;
        }

        var key = this.keys[keyCode];

        key.type                = type;
        key.isUsed              = false;
        key.image.sprite        = this.keySprites[(int)type];
        key.button.interactable = true;
        key.Run = run;
    }