
import Dictionary from "../Util/Dictionary";


import Skeleton = Laya.Skeleton;
import Templet = Laya.Templet;
import Event = Laya.Event;
import Browser = Laya.Browser;
import Stat = Laya.Stat;
import WebGL = Laya.WebGL;

export class NetInfoManager {
    private static instance: NetInfoManager;
    public static get Instance(): NetInfoManager {
        return this.instance || (this.instance = new NetInfoManager());
    }

    public _thing: any;
    public GetThing(id) {
        if (this._thing) {
            return this._thing[id - 1];
        }
        return null;
    }
    
    public _theme: any;
    public GetTheme(id) {
        if (this._theme) {
            return this._theme[id - 1];
        }
        return null;
    }
    
    public _road: any;
    public GetRoad(id) {
        if (this._road) {
            return this._road[id - 1];
        }
        return null;
    }
    

    public _rate: any;
    public GetRate(id) {
        if (this._rate) {
            return this._rate[id - 1];
        }
        return null;
    }

    public _block: any;
    public GetStreet(id) {
        if (this._block) {
            return this._block[id - 1];
        }
        return null;
    }

    public _globe: any;
    public GetGlobal(key: string) {
        if (this._globe) {
            for (let index = 0; index < this._globe.length; index++) {
                const element = this._globe[index];
                if (element.key == key) {
                    return element.value;
                }
            }
        }
    }

    public _level: any;
    public GetLevel(id) {
        if (this._level) {
            return this._level[id - 1];
        }
        return null;
    }

    public _atk: any;
    public GetAtk(id) {
        if (this._atk) {
            return this._atk[id - 1];
        }
        return null;
    }

/******************************************************* */
    private mAniPath:string;
		private mStartX:number = 200;
		private mStartY:number = 500;
		private mFactory:Templet;
		private mActionIndex:number = 0;
		private mCurrIndex:number = 0;
		private mArmature:Skeleton;
		private mCurrSkinIndex:number = 0;
		private mFactory2:Templet;
    public startFun():void
		{
			this.mAniPath = "res/spine/spineRes5/vine.sk";
			this.mFactory = new Templet();
			this.mFactory.on(Event.COMPLETE, this, this.parseComplete);
			this.mFactory.on(Event.ERROR, this, this.onError);
			this.mFactory.loadAni(this.mAniPath);
		}
		
		private onError():void
		{
			console.log("error");
		}
		
		private parseComplete():void {
			//创建模式为1，可以启用换装
			this.mArmature = this.mFactory.buildArmature(1);
			this.mArmature.x = this.mStartX;
			this.mArmature.y = this.mStartY;
			this.mArmature.scale(0.5, 0.5);
			Laya.stage.addChild(this.mArmature);
			this.mArmature.on(Event.STOPPED, this, this.completeHandler);
			this.play();
		}
		
		private completeHandler():void
		{
			this.play();
		}
		
		private play():void
		{
			this.mCurrIndex++;
			if (this.mCurrIndex >= this.mArmature.getAnimNum())
			{
				this.mCurrIndex = 0;
			}
			this.mArmature.play(this.mCurrIndex,false);
		}
/******************************************************* */



}