当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript events.on方法代码示例

本文整理汇总了TypeScript中camelot-unchained.events.on方法的典型用法代码示例。如果您正苦于以下问题:TypeScript events.on方法的具体用法?TypeScript events.on怎么用?TypeScript events.on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在camelot-unchained.events的用法示例。


在下文中一共展示了events.on方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: return

  return (dispatch: (action: any) => any) => {
    dispatch(init());

    // Update avatar
    client.OnEnemyTargetGenderChanged((gender: Gender) =>
      client.OnEnemyTargetRaceChanged((race: Race) => {
        dispatch(onAvatarChanged(getAvatar(gender, race)));
      }),
    );
    client.OnEnemyTargetRaceChanged((race: Race) =>
      client.OnEnemyTargetGenderChanged((gender: Gender) => {
        dispatch(onAvatarChanged(getAvatar(gender, race)));
      }),
    );

    client.OnCharacterPositionChanged(_.throttle((x: number, y: number) =>
      dispatch(onCharacterPositionChanged({ x, y })), 250));

    client.OnEnemyTargetPositionChanged(_.throttle((x: number, y: number) =>
      dispatch(onTargetPositionChanged({ x, y })), 250));

    // init handlers / events
    events.on(events.clientEventTopics.handlesEnemyTarget, (player: Player) => dispatch(onCharacterUpdate(player)));

  };
开发者ID:JoelTerMeer,项目名称:Camelot-Unchained,代码行数:25,代码来源:target.ts

示例2: return

  return (dispatch: (action: any) => any) => {
    dispatch(init());
    window.onresize = () => {
      if (window.innerWidth >= 640 && window.innerHeight >= 480) {
        // dispatch(resize());
      }
    };

    // hook up to event triggers
    events.on('hudnav--navigate', (name: string) => {
      switch (name) {
        case 'chat':
        case 'crafting':
          return dispatch(toggleVisibility(name));
        case 'ui': return dispatch(toggleHUDLock());
        case 'reset': return dispatch(resetHUD());
        default: return;
      }
    });

    window.window.addEventListener('keydown', (e: KeyboardEvent) => {
      if (e.which === 27) {
        dispatch(lockHUD());
      }
    });
  };
开发者ID:JoelTerMeer,项目名称:Camelot-Unchained,代码行数:26,代码来源:layout.ts

示例3: return

  return (dispatch: (action: any) => any) => {
    dispatch(init());

    if (!hasClientAPI()) return;

    // init handlers / events
    events.on(events.clientEventTopics.handlesEnemyTarget, (player: Player) => dispatch(characterUpdate(player)));

  };
开发者ID:Fidaman,项目名称:Camelot-Unchained,代码行数:9,代码来源:target.ts

示例4: registerWarbandEvents

function registerWarbandEvents(dispatch: (action: WarbandAction) => any) {
  events.on(signalr.WARBAND_EVENTS_JOINED, (info: {id: string, name: string}) => dispatch(warbandJoined(info.id, info.name)));
  events.on(signalr.WARBAND_EVENTS_UPDATE, (info: {id: string, name: string}) => dispatch(warbandJoined(info.id, info.name)));
  events.on(signalr.WARBAND_EVENTS_QUIT, () => dispatch(warbandQuit()));
  events.on(signalr.WARBAND_EVENTS_ABANDONED, () => dispatch(warbandAbandoned()));
  events.on(signalr.WARBAND_EVENTS_MEMBERJOINED, (member: WarbandMember) => dispatch(memberJoined(member)));
  events.on(signalr.WARBAND_EVENTS_MEMBERUPDATE, (member: WarbandMember) => dispatch(memberUpdate(member)));
  events.on(signalr.WARBAND_EVENTS_MEMBERREMOVED, (member: WarbandMember) => dispatch(memberRemoved(member)));
}
开发者ID:Fidaman,项目名称:Camelot-Unchained,代码行数:9,代码来源:warband.ts

示例5: registerPatcherHubEvents

// HELPER METHODS
function registerPatcherHubEvents(dispatch: (action: ControllerAction) => any) {
  events.on(signalr.PATCHER_EVENTS_ALERT, (alertJSON: string) => {
    const alert = utils.tryParseJSON<webAPI.PatcherAlert>(alertJSON, client.debug);
    if (alert !== null) dispatch(alertReceived(alert));
  });

  events.on(signalr.PATCHER_EVENTS_SERVERUPDATED, (serverJSON: string) => {
    const server = utils.tryParseJSON<webAPI.ServerModel>(serverJSON, client.debug);
    if (server !== null) dispatch(serverUpdate(server));
  });

  events.on(signalr.PATCHER_EVENTS_SERVERUNAVAILABLE, (name: string) => dispatch(serverUnavailable(name)));

  events.on(signalr.PATCHER_EVENTS_CHARACTERUPDATED, (characterJSON: string) => {
    const character = utils.tryParseJSON<webAPI.SimpleCharacter>(characterJSON, client.debug);
    if (character !== null) dispatch(characterUpdate(character));
  });

  events.on(signalr.PATCHER_EVENTS_CHARACTERREMOVED, (id: string) => dispatch(characterRemoved(id)));

}
开发者ID:JoelTerMeer,项目名称:Camelot-Unchained,代码行数:22,代码来源:controller.ts

示例6: return

  return (dispatch: (action: any) => any) => {
    dispatch(init());

    if (!hasClientAPI()) return;

    // init handlers / events
    client.OnCharacterStaminaChanged((current: number, max: number) => dispatch(staminaChanged(current, max)));
    client.OnCharacterHealthChanged((current: number, max: number) => dispatch(healthChanged(current, max, BodyParts.Torso)));

    client.OnCharacterNameChanged((name: string) => dispatch(nameChanged(name)));
    client.OnCharacterRaceChanged((race: race) => dispatch(raceChanged(race)));
    client.OnCharacterFactionChanged((faction: faction) => dispatch(factionChanged(faction)));

    events.on(events.clientEventTopics.handlesCharacter, (player: Player) => dispatch(characterUpdate(player)));

  };
开发者ID:Fidaman,项目名称:Camelot-Unchained,代码行数:16,代码来源:player.ts

示例7: return

  return (dispatch: (action: any) => any) => {
    dispatch(init());

    // init handlers / events
    client.OnCharacterStaminaChanged((current: number, max: number) => dispatch(onStaminaChanged(current, max)));

    client.OnCharacterHealthChanged((current: number, max: number) =>
      dispatch(onHealthChanged(current, max, BodyParts.Torso)));

    client.OnCharacterInjuriesChanged((part: number, health: number, maxHealth: number) => 
      dispatch(onHealthChanged(health, maxHealth, part)));

    client.OnCharacterNameChanged((name: string) => dispatch(onNameChanged(name)));

    client.OnCharacterFactionChanged((faction: Faction) => dispatch(onFactionChanged(faction)));
    client.OnCharacterRaceChanged((race: Race) => {
      dispatch(onRaceChanged(race));
      client.OnCharacterGenderChanged((gender: Gender) => dispatch(onAvatarChanged(getAvatar(gender, race))));
    });

    events.on(events.clientEventTopics.handlesCharacter, (player: Player) => dispatch(onCharacterUpdate(player)));

  };
开发者ID:JoelTerMeer,项目名称:Camelot-Unchained,代码行数:23,代码来源:player.ts

示例8: registerInviteEvents

function registerInviteEvents(dispatch: (action: InvitesAction) => any) {
  events.on(signalr.GROUP_EVENTS_INVITE_RECEIVED, (invite: GroupInvite) => dispatch(inviteReceived(invite)));
}
开发者ID:JoelTerMeer,项目名称:Camelot-Unchained,代码行数:3,代码来源:invites.ts


注:本文中的camelot-unchained.events.on方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。