import o0 from "./o0.js" module.exports = { SandbagAlgorithm: class{ constructor() { this.stableAcc = new o0.Vector2(0,0); this.stableGyr = new o0.Vector2(0,0); this.stableCount = 0; this.stableCountMax = 3000; this.frameCapacity = 6; this.frame = []; this.frameLength = 5; this.frameOffset = 0; this.frameHitCapacity = 11; this.frameHit = [];//打击后的n帧 for(var i = 0;i newFrame.shakeFixed){ newFrame.shakeFixed = newFrame.shake; }/* */ lastFrame.shakeFixed = Math.max(lastFrame.shakeFixed, Math.min(newFrame.shakeFixed,last2Frame.shakeFixed), Math.min(newFrame.shakeFixed,last3Frame.shakeFixed)); //////////////////////////////////////////////////////////////// newFrame.shakeSlope = Math.max(newFrame.shakeFixed-lastFrame.shakeFixed,0); /////////////////////////////////////////////////////////////// var direction = new o0.Vector2(0,0); if(lastFrame.hit==0 && last2Frame.hit==0 && last3Frame.hit==0 && last4Frame.hit==0 && last5Frame.hit==0 && (newFrame.accSlope >= 15 || lastFrame.accSlope >= 20) && (newFrame.shakeSlope >= 20 || lastFrame.shakeSlope >= 40)){ newFrame.hit = 1; if (this.frameHit.length < this.frameHitCapacity) { direction = this.GetDirection(); }/**/ this.frameHit = []; var o = new Object(); o.time = 0; o.gyr = lastFrame.gyr; this.frameHit.push(o); }else{ newFrame.hit = 0; } if (this.frameHit.length < this.frameHitCapacity) { var o = new Object(); o.time = this.frameHit[this.frameHit.length - 1].time + newFrame.timeGap; o.gyr = newFrame.gyr; if (this.frameHit.length == this.frameHitCapacity) { direction = this.GetDirection(); } } if ((this.frameOffset+=1) >= this.frameCapacity){ this.frameOffset -= this.frameCapacity; } if(newFrame.hit != 0){ console.log(newFrame.hit, direction); } return (newFrame.hit, direction); } test(){ return "123123131"; } } };