import { MonkeytowerTable } from "../Tables/MonkeytowerTable";

declare module '../Tables/MonkeytowerTable' {
    interface MonkeytowerTable {
        GetFixedValue(id: number, isGetBoth: boolean): number;
        GetAddMonsterPos(stageNum: number): cc.Vec2;
        GetDoorPos(stageNum: number): cc.Vec2;
        GetBuildingType(stageNum: number, idx: number): number;
        GetBuildingLength(stageNum: number): number;
        GetBuildingPos(stageNum: number, idx: number): cc.Vec2;
        GetCornerLength(stageNum: number): number;
        GetCornerPos(stageNum: number, idx: number): cc.Vec2;
        GetCornerMove(stageNum: number, idx: number): cc.Vec2;
        GetTowerAtkRange(id: number, lv: number): number;
        GetTowerAtkSpeed(id: number, lv: number): number;
    }
}

MonkeytowerTable.prototype.GetFixedValue = function (id: number, isGetBoth: boolean) {
    let self = <MonkeytowerTable>this;
    let value: number = undefined;
    if (isGetBoth) {
        value = self.Fixed[id]["BValue"];
    } else {
        value = self.Fixed[id]["CValue"];
    }
    return value;
}

MonkeytowerTable.prototype.GetTowerAtkSpeed = function (id: number, lv: number) {
    let self = <MonkeytowerTable>this;
    let range: number = self.Tower[id]["AttackSpeed" + lv];
    return range;
}

MonkeytowerTable.prototype.GetTowerAtkRange = function (id: number, lv: number) {
    let self = <MonkeytowerTable>this;
    let range: number = self.Tower[id]["AttackRange" + lv];
    return range;
}

MonkeytowerTable.prototype.GetAddMonsterPos = function (stageNum: number) {
    let self = <MonkeytowerTable>this;
    let x: number = self["Set" + stageNum][1].CoordinateX;
    let y: number = self["Set" + stageNum][1].CoordinateY;
    return cc.v2(x, y);
}

MonkeytowerTable.prototype.GetDoorPos = function (stageNum: number) {
    let self = <MonkeytowerTable>this;
    let x: number = self["Set" + stageNum][2].CoordinateX;
    let y: number = self["Set" + stageNum][2].CoordinateY;
    return cc.v2(x, y);
}

MonkeytowerTable.prototype.GetBuildingType = function (stageNum: number, idx: number) {
    let self = <MonkeytowerTable>this;
    let type: number = self["Building" + stageNum][idx].Type;
    return type;
}

MonkeytowerTable.prototype.GetBuildingLength = function (stageNum: number) {
    let self = <MonkeytowerTable>this;
    let num: number = self["Building" + stageNum].Keys.length;
    return num;
}

MonkeytowerTable.prototype.GetBuildingPos = function (stageNum: number, idx: number) {
    let self = <MonkeytowerTable>this;
    let x: number = self["Building" + stageNum][idx].CoordinateX;
    let y: number = self["Building" + stageNum][idx].CoordinateY;
    return cc.v2(x, y);
}

MonkeytowerTable.prototype.GetCornerLength = function (stageNum: number) {
    let self = <MonkeytowerTable>this;
    let num: number = self["Corner" + stageNum].Keys.length;
    return num;
}

MonkeytowerTable.prototype.GetCornerPos = function (stageNum: number, idx: number) {
    let self = <MonkeytowerTable>this;
    let x: number = self["Corner" + stageNum][idx].CoordinateX;
    let y: number = self["Corner" + stageNum][idx].CoordinateY;
    return cc.v2(x, y);
}

MonkeytowerTable.prototype.GetCornerMove = function (stageNum: number, idx: number) {
    let self = <MonkeytowerTable>this;
    let x: number = self["Corner" + stageNum][idx].MovingX;
    let y: number = self["Corner" + stageNum][idx].MovingY;
    return cc.v2(x, y);
}