• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript game.GameBar类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中src/viseur/game.GameBar的典型用法代码示例。如果您正苦于以下问题:TypeScript GameBar类的具体用法?TypeScript GameBar怎么用?TypeScript GameBar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: recolor

    /**
     * Invoked after a player changes their color,
     * so we have a chance to recolor this Unit's sprites.
     */
    public recolor(): void {
        super.recolor();

        // <<-- Creer-Merge: recolor -->>
        const color = this.game.getPlayersColor(this.ownerID).rgbNumber();
        this.jobSprite.tint = color;
        this.healthBar.recolor(color);
        // <<-- /Creer-Merge: recolor -->>
    }
开发者ID:siggame,项目名称:Viseur,代码行数:13,代码来源:unit.ts


示例2: recolor

    /**
     * Invoked after a player changes their color,
     * so we have a chance to recolor this Beaver's sprites.
     */
    public recolor(): void {
        super.recolor();

        // <<-- Creer-Merge: recolor -->>
        const color = this.game.getPlayersColor(this.ownerID);
        this.tailSprite.tint = color.lighten(0.15).rgbNumber();
        this.healthBar.recolor(color.lighten(0.5));
        // <<-- /Creer-Merge: recolor -->>
    }
开发者ID:siggame,项目名称:Viseur,代码行数:13,代码来源:beaver.ts


示例3: render

    /**
     * Called approx 60 times a second to update and render Machine instances.
     * Leave empty if it is not being rendered.
     *
     * @param dt - A floating point number [0, 1) which represents how far into
     * the next turn that current turn we are rendering is at
     * @param current - The current (most) game state, will be this.next if this.current is undefined.
     * @param next - The next (most) game state, will be this.current if this.next is undefined.
     * @param delta - The current (most) delta, which explains what happened.
     * @param nextDelta  - The the next (most) delta, which explains what happend.
     */
    public render(
        dt: number,
        current: Immutable<IMachineState>,
        next: Immutable<IMachineState>,
        delta: Immutable<Delta>,
        nextDelta: Immutable<Delta>,
    ): void {
        super.render(dt, current, next, delta, nextDelta);

        // <<-- Creer-Merge: render -->>
        this.workBar.update(ease(current.worked, next.worked, dt));
        // <<-- /Creer-Merge: render -->>
    }
开发者ID:siggame,项目名称:Viseur,代码行数:24,代码来源:machine.ts


示例4: render

    /**
     * Called approx 60 times a second to update and render Unit instances.
     * Leave empty if it is not being rendered.
     *
     * @param dt - A floating point number [0, 1) which represents how far into
     * the next turn that current turn we are rendering is at
     * @param current - The current (most) game state, will be this.next if this.current is undefined.
     * @param next - The next (most) game state, will be this.current if this.next is undefined.
     * @param delta - The current (most) delta, which explains what happened.
     * @param nextDelta  - The the next (most) delta, which explains what happend.
     */
    public render(
        dt: number,
        current: Immutable<IUnitState>,
        next: Immutable<IUnitState>,
        delta: Immutable<Delta>,
        nextDelta: Immutable<Delta>,
    ): void {
        super.render(dt, current, next, delta, nextDelta);

        // <<-- Creer-Merge: render -->>
        // render where the Unit is

        // No longer on the map.
        if (!next.tile) {
            this.container.visible = false;

            return;
        }
        this.container.visible = true;
        this.container.position.set(
            ease(current.tile.x, next.tile.x, dt),
            ease(current.tile.y, next.tile.y, dt),
        );

        this.healthBar.update(ease(current.health, next.health, dt));
        pixiFade(this.container, dt, current.health, next.health);

        if (this.attackingTile) {
            const d = updown(dt);
            const dx = (this.attackingTile.x - current.tile.x) / 2;
            const dy = (this.attackingTile.y - current.tile.y) / 2;

            this.container.x += dx * d;
            this.container.y += dy * d;
        }
        // <<-- /Creer-Merge: render -->>
    }
开发者ID:siggame,项目名称:Viseur,代码行数:48,代码来源:unit.ts


示例5: render

    /**
     * Called approx 60 times a second to update and render Furnishing instances.
     * Leave empty if it is not being rendered.
     *
     * @param dt - A floating point number [0, 1) which represents how far into
     * the next turn that current turn we are rendering is at
     * @param current - The current (most) game state, will be this.next if this.current is undefined.
     * @param next - The next (most) game state, will be this.current if this.next is undefined.
     * @param delta - The current (most) delta, which explains what happened.
     * @param nextDelta  - The the next (most) delta, which explains what happend.
     */
    public render(
        dt: number,
        current: Immutable<IFurnishingState>,
        next: Immutable<IFurnishingState>,
        delta: Immutable<Delta>,
        nextDelta: Immutable<Delta>,
    ): void {
        super.render(dt, current, next, delta, nextDelta);

        // <<-- Creer-Merge: render -->>

        if (current.isDestroyed) {
            this.container.visible = false;

            if (this.musicSprite) {
                this.musicSprite.visible = false;
            }

            // we are destroyed an invisible, so let's get out of here
            return;
        }

        // else we are visible!
        this.container.visible = true;

        this.healthBar.update(ease(current.health, next.health, dt, "cubicInOut"));

        // display the hit if took damage
        const randomRotation = (current.tile.x + current.tile.y); // random-ish
        if (current.health === next.health) {
            this.hitSprite.visible = false;
        }
        else { // we got hit!
            this.hitSprite.visible = true;
            this.hitSprite.alpha = ease(1 - dt, "cubicInOut"); // fade it out
            this.hitSprite.rotation = randomRotation;
        }

        // fade out if destroyed next turn
        this.container.alpha = next.isDestroyed
            ? ease(1 - dt, "cubicInOut")
            : 1;

        if (this.musicSprite) {
            if (current.isPlaying || next.isPlaying) {
                this.musicSprite.visible = true;

                let alpha = 1;
                let y = this.y;
                if (!current.isPlaying && next.isPlaying) { // music notes need to move up
                    alpha = ease(dt, "cubicInOut");
                    y -= alpha / 2;
                }
                else if (current.isPlaying && !next.isPlaying) { // music notes need to move down
                    alpha = ease(1 - dt, "cubicInOut");
                    y -= alpha / 2;
                }
                else { // current and next isPlaying
                    y -= 0.5;
                }

                this.musicSprite.alpha = alpha;
                this.musicSprite.y = y;
            }
            else {
                this.musicSprite.visible = false;
            }
        }

        // <<-- /Creer-Merge: render -->>
    }
开发者ID:siggame,项目名称:Viseur,代码行数:82,代码来源:furnishing.ts


示例6: render

    /**
     * Called approx 60 times a second to update and render Beaver instances.
     * Leave empty if it is not being rendered.
     *
     * @param dt - A floating point number [0, 1) which represents how far into
     * the next turn that current turn we are rendering is at
     * @param current - The current (most) game state, will be this.next if this.current is undefined.
     * @param next - The next (most) game state, will be this.current if this.next is undefined.
     * @param delta - The current (most) delta, which explains what happened.
     * @param nextDelta  - The the next (most) delta, which explains what happend.
     */
    public render(
        dt: number,
        current: Immutable<IBeaverState>,
        next: Immutable<IBeaverState>,
        delta: Immutable<Delta>,
        nextDelta: Immutable<Delta>,
    ): void {
        super.render(dt, current, next, delta, nextDelta);

        // <<-- Creer-Merge: render -->>

        if (current.health === 0) {  // Then beaver is dead.
            this.container.visible = false;

            return; // No need to render a dead beaver.
        }

        // otherwise, we have a (maybe) happy living beaver
        this.container.visible = true;

        const currentTile = current.tile;
        let nextTile = next.tile;

        if (current.health > 0 && next.health <= 0) {
            // The Beaver died between current and next.

            // Dead beavers have no tile in their next state,
            // so use the one they had before.
            nextTile = currentTile;
            this.container.alpha = ease(1 - dt, "cubicInOut"); // fade the beaver sprite
        }
        else {
            this.container.alpha = 1; // ITS ALIVE
        }

        // update their health bar, if they want it to be displayed
        this.healthBar.update(
            ease(current.health, next.health, dt, "cubicInOut"),
        );

        // render the beaver easing the transition from their current tile to their next tile
        this.container.x = ease(currentTile.x, nextTile.x, dt, "cubicInOut");
        this.container.y = ease(currentTile.y, nextTile.y, dt, "cubicInOut");

        // update its status bubbles
        this.attackingSprite.visible = false;
        this.gettingBranchSprite.visible = false;
        this.gettingFoodSprite.visible = false;
        this.distractedSprite.visible = current.turnsDistracted > 0;

        let bumpInto: undefined | ITileState; // Find something to bump into

        if (this.attacking) {
            this.attackingSprite.visible = true;
            bumpInto = this.attacking.getCurrentMostState().tile;
        }
        else if (this.harvesting) {
            const harvesting = this.harvesting.getCurrentMostState();
            if (harvesting.type === "food") {
                this.gettingFoodSprite.visible = true;
            }
            else { // tree branches
                this.gettingBranchSprite.visible = true;
            }

            bumpInto = harvesting.tile;
        }

        // if we found something to bump into, animate it bumping into it half way
        if (bumpInto) {
            const d = updown(dt);
            const dx = (bumpInto.x - current.tile.x) / 2;
            const dy = (bumpInto.y - current.tile.y) / 2;

            this.container.x += dx * d;
            this.container.y += dy * d;
        }

        // <<-- /Creer-Merge: render -->>
    }
开发者ID:siggame,项目名称:Viseur,代码行数:91,代码来源:beaver.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript renderer.createResources函数代码示例发布时间:2022-05-25
下一篇:
TypeScript mapBuilder.csvToMap函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap