當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Player.getPosition函數代碼示例

本文整理匯總了TypeScript中model/player/Player.getPosition函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getPosition函數的具體用法?TypeScript getPosition怎麽用?TypeScript getPosition使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了getPosition函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: death_

  /**
   * Called when the player this sprite represents gets killed.
   */
  private death_(killee : Player, killer : Player) {
    let position = killee.getPosition();
    let velocity = killee.getVelocity();

    let resourceManager = this.game_.getResourceManager();
    let ensemble = resourceManager.getSpriteSheet('explode1');
    new Effect(this.game_, ensemble.getAnimation(0), position, velocity);

    ensemble = resourceManager.getSpriteSheet('ship' + killee.ship + '_junk');
    for (let i = 0; i < ensemble.getNumAnimations(); ++i) {
      let animation = ensemble.getAnimation(i);
      let deltaVelocity = Vector.fromPolar(Math.random() * 2, Math.random() * 2 * Math.PI);
      new Effect(this.game_, animation, position, velocity.add(deltaVelocity));
    }

    if (this.game_.getViewport().contains(position)) {
      resourceManager.playSound('explodeShip');
    }
  }
開發者ID:krslynx,項目名稱:dotproduct,代碼行數:22,代碼來源:PlayerSprite.ts

示例2: checkPlayerCollision_

  protected checkPlayerCollision_(player : Player) : boolean {
    if (!player.isAlive || this.owner_.isFriend(player)) {
      return false;
    }

    let distance = this.position_.subtract(player.getPosition()).magnitude();
    if (player.getDimensions().boundingRect.contains(this.position_)) {
      this.explode_(player);
      return true;
    } else if (!this.proxActivator_) {
      if (distance <= this.proxRadius_) {
        this.proxActivator_ = player;
        this.lastDistanceToProxActivator_ = distance;
      }
    } else if (player == this.proxActivator_) {
      if (distance > this.lastDistanceToProxActivator_) {
        this.explode_(null);
        return true;
      }
      this.lastDistanceToProxActivator_ = distance;
    }
    return false;
  }
開發者ID:krslynx,項目名稱:dotproduct,代碼行數:23,代碼來源:Bomb.ts

示例3: render

  public render(viewport : Viewport) {
    if (!this.player_.isValid()) {
      this.game_.getPainter().unregisterDrawable(this.layer_, this);
      return;
    }

    if (!this.player_.isAlive) {
      return;
    }

    PlayerSprite.renderPlayer(this.game_, viewport, this.player_, this.player_.direction, this.player_.getPosition());
  }
開發者ID:krslynx,項目名稱:dotproduct,代碼行數:12,代碼來源:PlayerSprite.ts

示例4: respawn_

 /** Called when the player this sprite represents respawns. */
 private respawn_(player : Player) {
   let resourceManager = this.game_.getResourceManager();
   let animation = resourceManager.getSpriteSheet('warp').getAnimation(0);
   new Effect(this.game_, animation, player.getPosition(), Vector.ZERO);
 }
開發者ID:krslynx,項目名稱:dotproduct,代碼行數:6,代碼來源:PlayerSprite.ts

示例5: onFired

  public onFired(timeDiff : number, position : Vector, velocity : Vector, weaponData : any) {
    assert(weaponData['type'] == this.getType(), 'Cannot fire decoy with incorrect weapon type: ' + weaponData['type']);

    let lifetime = this.settings_['lifetime'];

    let projectile = this.simulation_.modelObjectFactory.newDecoy(this.owner_, this.owner_.getPosition(), this.owner_.getVelocity(), lifetime);
    this.owner_.addProjectile(projectile);

    for (let i = 0; i < timeDiff; ++i) {
      projectile.advanceTime();
    }
  }
開發者ID:krslynx,項目名稱:dotproduct,代碼行數:12,代碼來源:DecoyWeapon.ts

示例6: fire

  public fire(position : Vector, commitFireFn : (fireEnergy : number, fireDelay : number) => boolean) : any {
    if (this.count_ <= 0 || !commitFireFn(0 /* fireEnergy */, this.settings_['fireDelay'])) {
      return null;
    }

    --this.count_;
    let lifetime = this.settings_['lifetime'];
    let projectile = this.simulation_.modelObjectFactory.newDecoy(this.owner_, this.owner_.getPosition(), this.owner_.getVelocity(), lifetime);
    this.owner_.addProjectile(projectile);

    return {
      'type': this.getType()
    };
  }
開發者ID:krslynx,項目名稱:dotproduct,代碼行數:14,代碼來源:DecoyWeapon.ts

示例7: fire

  public fire(position : Vector, commitFireFn : (fireEnergy : number, fireDelay : number) => boolean) : any {
    if (this.count_ <= 0 || !commitFireFn(0 /* fireEnergy */, this.settings_['fireDelay'])) {
      return null;
    }

    --this.count_;
    let shrapnelCount = this.settings_['shrapnelCount'];
    let lifetime = this.settings_['lifetime'];
    let damage = this.settings_['damage'];

    for (let i = 0; i < shrapnelCount; ++i) {
      let velocity = Vector.fromPolar(this.settings_['speed'], i * 2 * Math.PI / shrapnelCount).add(this.owner_.getVelocity());
      let projectile = this.simulation_.modelObjectFactory.newBurst(this.owner_, this.owner_.getPosition(), velocity, lifetime, damage);
      this.owner_.addProjectile(projectile);
    }

    return {
      'type': this.getType()
    };
  }
開發者ID:krslynx,項目名稱:dotproduct,代碼行數:20,代碼來源:BurstWeapon.ts


注:本文中的model/player/Player.getPosition函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。