You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
2.0 KiB
66 lines
2.0 KiB
import { Vec2, Vec3 } from "cc";
|
|
import { _DesktopspeedConfig } from "../_config/_DesktopspeedConfig";
|
|
import BaseConfigProxy from "../Base/BaseConfigProxy";
|
|
import ConfigT from "../Base/ConfigT";
|
|
import InstanceT from "../../ExUtils/InstanceT";
|
|
|
|
@InstanceT.DecorateInstance()
|
|
@ConfigT.DecorateConfigProxy(_DesktopspeedConfig)
|
|
export class DesktopspeedProxy extends BaseConfigProxy<_DesktopspeedConfig.DataType>{
|
|
/** 单例 */
|
|
public static readonly instance: DesktopspeedProxy;
|
|
|
|
dic_speed: Map<number, Vec2> = new Map<number, Vec2>();
|
|
public readonly Logic2RenderScale: number = 0.0001;
|
|
|
|
|
|
protected initLogic(){
|
|
this.InitSpeedInfo();
|
|
}
|
|
|
|
GetDesktopspeedData(): string[] {
|
|
let Dir: string[] = [];
|
|
this.dataList.forEach((Item) => {
|
|
Dir.push(Item.DIrString);
|
|
});
|
|
return Dir;
|
|
}
|
|
|
|
InitSpeedInfo():void {
|
|
let dir;
|
|
let lineArray: string[] = this.GetDesktopspeedData();
|
|
for (let i = 0; i < lineArray.length; i++) {
|
|
let LineString = lineArray[i];
|
|
if (LineString != "") {
|
|
let date: Vec2 = new Vec2();
|
|
let line = LineString.split(',');
|
|
dir = parseInt(line[0]);
|
|
date.x = parseInt(line[1]);
|
|
date.y = parseInt(line[2]);
|
|
this.dic_speed[dir] = date;
|
|
}
|
|
}
|
|
}
|
|
|
|
public GetSpeed(_dir: number):Vec2 {
|
|
return this.dic_speed[_dir];
|
|
}
|
|
|
|
public Logic2Render(_value: number): number {
|
|
return _value * this.Logic2RenderScale;
|
|
}
|
|
public ChangeGameVectorToVector3(_vec2: Vec2, _y: number = 0): Vec3 {
|
|
return new Vec3(this.Logic2Render(Math.floor(_vec2.x)), _y, this.Logic2Render(Math.floor(_vec2.y)));
|
|
}
|
|
|
|
public getDir(_dir:number,out?:Vec3):Vec3{
|
|
if(!out){
|
|
out =new Vec3();
|
|
}
|
|
let tempPos = this.GetSpeed(_dir*3)
|
|
out.x = tempPos.x;
|
|
out.y = tempPos.y;
|
|
return out
|
|
}
|
|
|
|
}
|