|
|
|
import { Component, ElementRef, OnInit } from '@angular/core';
|
|
|
|
import { Game } from 'src/app/babylon/game';
|
|
|
|
import { LoginSatus } from 'src/app/babylon/controller/status/login-status';
|
|
|
|
import { StatusManager } from 'src/app/babylon/controller/status/status-manager';
|
|
|
|
import { InsitutionDataSimple } from 'src/app/babylon/model/data/institution/institution-data-simple';
|
|
|
|
import { ModeManager } from 'src/app/babylon/controller/mode-manager';
|
|
|
|
import { ServeManager } from 'src/app/babylon/controller/serve-manager';
|
|
|
|
import { BuildingBasicInfosService } from 'src/app/service/babylon/building-basic-infos.service';
|
|
|
|
import { ObjectsService } from 'src/app/service/objects.service';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-plan',
|
|
|
|
templateUrl: './plan.component.html',
|
|
|
|
styleUrls: ['./plan.component.scss', './publicPop.scss']
|
|
|
|
})
|
|
|
|
export class PlanComponent implements OnInit {
|
|
|
|
|
|
|
|
constructor(private element: ElementRef, private buildingBISrv: BuildingBasicInfosService, private objectsSrv: ObjectsService) { }
|
|
|
|
|
|
|
|
static instance: PlanComponent;
|
|
|
|
public game: Game = new Game();
|
|
|
|
public beforeOneSatus; //当前 satus
|
|
|
|
public canvas: HTMLCanvasElement; //canvas 实例
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
PlanComponent.instance = this;
|
|
|
|
ServeManager.Init(this.buildingBISrv, this.objectsSrv);
|
|
|
|
this.canvas = this.element.nativeElement.querySelector('#center') as HTMLCanvasElement;
|
|
|
|
this.game.init(this.canvas);
|
|
|
|
}
|
|
|
|
|
|
|
|
ngAfterViewInit(): void {
|
|
|
|
let loginStatus = StatusManager.getStatus<LoginSatus>(LoginSatus);
|
|
|
|
loginStatus.getInstitutionListFromServe((result: InsitutionDataSimple[], data: any) => {
|
|
|
|
if (ModeManager.institutionDemoKey == ModeManager.c_demoKey_null) { //无指定测试单位,则为正式启动,根据当前单位key寻找
|
|
|
|
let key = 'ceshi';
|
|
|
|
console.log("获取数据", data);
|
|
|
|
let find = data.find(item => { return item.key === key })
|
|
|
|
if (find) { //如果在data中找到了对应的单位key,则表示已经有三维数据,直接进入
|
|
|
|
console.log("找到已有单位" + key);
|
|
|
|
this.beforeOneSatus = StatusManager.getStatus<LoginSatus>(LoginSatus);
|
|
|
|
this.beforeOneSatus.onSelectInsSuccess(find)
|
|
|
|
} else { //如果没有找到对应的单位key,则调用新建单位
|
|
|
|
let name = 'ceshi';
|
|
|
|
console.log("没找到单位,新建" + key);
|
|
|
|
loginStatus.createInsitution(key, name);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
let find = data.find(item => { return item.key === ModeManager.institutionDemoKey })
|
|
|
|
if (find) {
|
|
|
|
sessionStorage.setItem('unitId', find.key)
|
|
|
|
this.beforeOneSatus = StatusManager.getStatus<LoginSatus>(LoginSatus);
|
|
|
|
this.beforeOneSatus.onSelectInsSuccess(find)
|
|
|
|
} else {
|
|
|
|
this.modelInit(data) //开发模式 选择单位 弹窗
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnDestroy(): void { //组件销毁前 销毁canvas
|
|
|
|
this.game.dispose();
|
|
|
|
this.game = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
//开发模式 选择单位 弹窗
|
|
|
|
modelInit(InsList) {
|
|
|
|
console.log(InsList)
|
|
|
|
}
|
|
|
|
|
|
|
|
buildingUIItems: any[] = []; //左侧 建筑list
|
|
|
|
beforeOneBuildingID: string = null; //选中 左侧建筑ID
|
|
|
|
isShowBuildingPop: boolean = false; //显隐 新增/编辑左侧建筑弹窗
|
|
|
|
isShowLeftBuilding: boolean = true; //显隐 建筑list
|
|
|
|
toggleLeftBuilding(e) { this.isShowLeftBuilding = e }; //显隐 建筑list
|
|
|
|
|
|
|
|
//选择建筑
|
|
|
|
selectLeftBuilding(e) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//创建建筑
|
|
|
|
addModelBuilding(form) {
|
|
|
|
console.log(form)
|
|
|
|
}
|
|
|
|
|
|
|
|
//编辑建筑
|
|
|
|
editModelBuilding(event, e) {
|
|
|
|
event.stopPropagation()
|
|
|
|
}
|
|
|
|
|
|
|
|
//删除建筑
|
|
|
|
deleteModelBuilding(event, e) {
|
|
|
|
event.stopPropagation()
|
|
|
|
let isTrue = confirm('您确定要删除吗')
|
|
|
|
if (isTrue) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|