Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// ------------------------------------------------------------------------------
// Copyright (c) 2017-present, RobotlegsJS. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
// ------------------------------------------------------------------------------
import { injectable, inject } from "@robotlegsjs/core";
import { Sprite } from "pixi.js";
import { MediatorWatcher } from "./MediatorWatcher";
@injectable()
export class ExampleMediator {
@inject(MediatorWatcher)
public mediatorWatcher: MediatorWatcher;
@inject(Sprite)
public view: Sprite;
public initialize(): void {
this.mediatorWatcher.notify("ExampleMediator");
}
public destroy(): void {
this.mediatorWatcher.notify("ExampleMediator destroy");
}
}
// ------------------------------------------------------------------------------
// Copyright (c) 2017-present, RobotlegsJS. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
// ------------------------------------------------------------------------------
import { injectable, IGuard } from "@robotlegsjs/core";
@injectable()
export class GrumpyGuard implements IGuard {
public approve(): boolean {
return false;
}
}
// ------------------------------------------------------------------------------
// Copyright (c) 2017-present, RobotlegsJS. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
// ------------------------------------------------------------------------------
import { injectable } from "@robotlegsjs/core";
@injectable()
export class NullMediator {}
// ------------------------------------------------------------------------------
// Copyright (c) 2017-present, RobotlegsJS. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
// ------------------------------------------------------------------------------
import { injectable } from "@robotlegsjs/core";
@injectable()
export class NullMediator2 {}
// ------------------------------------------------------------------------------
// Copyright (c) 2017-present, RobotlegsJS. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
// ------------------------------------------------------------------------------
import { injectable, IGuard } from "@robotlegsjs/core";
@injectable()
export class HappyGuard implements IGuard {
public approve(): boolean {
return true;
}
}
// ------------------------------------------------------------------------------
// Copyright (c) 2017-present, RobotlegsJS. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
// ------------------------------------------------------------------------------
import { injectable, inject, named } from "@robotlegsjs/core";
@injectable()
export class RectangleMediator {
@inject(Number)
@named("width")
public width: number;
@inject(Number)
@named("height")
public height: number;
}
// ------------------------------------------------------------------------------
// Copyright (c) 2017-present, RobotlegsJS. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
// ------------------------------------------------------------------------------
import { injectable, inject } from "@robotlegsjs/core";
import { MediatorWatcher } from "./MediatorWatcher";
import { NotAView } from "./NotAView";
@injectable()
export class NotAViewMediator {
@inject(MediatorWatcher)
public mediatorWatcher: MediatorWatcher;
@inject(NotAView)
public view: NotAView;
public initialize(): void {
this.view.mediatorName = "NotAViewMediator";
this.mediatorWatcher.notify("NotAViewMediator");
}
public destroy(): void {
this.mediatorWatcher.notify("NotAViewMediator destroy");
}
}
import { TweenLite } from "gsap";
import { Sprite } from "pixi.js";
import { PixiSpritePool } from "../game/utils/PieceDisplayPool";
import { PieceUtils } from "../game/utils/PieceUtils";
import { GameEvent } from "./../events/GameEvent";
import { GameManager } from "./../game/managers/GameManager";
import { LevelModel } from "./../game/models/LevelModel";
import { PieceData } from "./../game/models/PieceData";
import { Tile } from "./../game/models/Tile";
import { TouchPhase } from "./../game/models/TouchPhase";
import { AnimationUtils } from "./../game/utils/AnimationUtils";
import { GameService } from "./../services/GameService";
import { GridFieldComponent } from "./../views/components/GridFieldComponent";
@injectable()
export class GridFieldComponentMediator extends Mediator {
@inject(LevelModel) private levelModel: LevelModel;
@inject(GameManager) private gameManager: GameManager;
@inject(GameService) private gameService: GameService;
private _displays: Map;
public initialize(): void {
this._displays = new Map();
this.view.generateGrid(this.levelModel.maxCols, this.levelModel.maxRows);
this.view.interactive = true;
this.eventMap.mapListener(this.eventDispatcher, GameEvent.CLEAR_GRID, this.game_onClearGridHandler, this);
this.eventMap.mapListener(this.eventDispatcher, GameEvent.UPDATE_GRID, this.game_onUpdateGridHandler, this);
import { inject, injectable } from "@robotlegsjs/core";
import { Mediator } from "@robotlegsjs/pixi";
import { GameService } from "./../services/GameService";
import { GameView } from "./../views/GameView";
@injectable()
export class GameViewMediator extends Mediator {
@inject(GameService) private gameService: GameService;
public initialize(): void {
this.view.createComponents();
this.gameService.createLevel();
}
public destroy(): void {
this.view.destroy();
}
}
import { inject, injectable } from "@robotlegsjs/core";
import { Grid } from "../models/Grid";
import { TileGroup } from "../models/TileGroup";
import { GameService } from "../services/GameService";
import { Tile } from "./../models/Tile";
@injectable()
export class GameManager {
@inject(GameService) private gameService: GameService;
private _grid: Grid;
private _currentPiece: TileGroup;
private _tilesToUpdate: Tile[];
private _tilesToRemove: Tile[];
public createEmpytGrid(cols = 10, rows = 20): void {
this._grid = new Grid(cols, rows);
this._tilesToUpdate = new Array();
this._tilesToRemove = new Array();
}
public addPiece(currentPiece: TileGroup): void {
this._currentPiece = currentPiece;
this._currentPiece.moveHorizontal(4);