GOL:file:fengine5.script3imageBox = window.getChild(1); function init() { started = false; out.println('start engine2'); lock = 'lock'; fcMap = util.newHashtable(); imageBox.setFocusable(false); fontWidth = 7; fontHeight = 10; fontBorderBottom = 2; backFrame = util.newFrame('backFrame', 0, 0, 0, 0); backFrame.setLayer(0); imageBox.add(backFrame); heroAFrame = util.newFrame(0, 0, 0, 0); heroAFrame.setLayer(1); imageBox.add(heroAFrame); heroAFrameArr = util.newArray(48); heroBFrame = util.newFrame(0, 0, 0, 0); heroBFrame.setLayer(2); imageBox.add(heroBFrame); heroBFrameArr = util.newArray(48); heroBFrameArrSize = 0; rectFrame = util.newFrame(0, 0, 0, 0); rectFrame.setLayer(4); rectFrame.setColor(200, 171, 113); rectFrame.fillRect(rectRX, rectRY, rectRW + 1, rectRH); imageBox.add(rectFrame); rectFrame = util.newFrame(0, 0, 0, 0); rectFrame.setLayer(4); rectFrame.setColor(200, 171, 113); rectFrame.fillRect(rectLX, rectLY, rectLW, rectLH); imageBox.add(rectFrame); rectFrame = util.newFrame(0, 0, 0, 0); rectFrame.setLayer(4); rectFrame.setColor(200, 171, 113); rectFrame.fillRect(rectTX, rectTY, rectTW, rectTH); imageBox.add(rectFrame); rectFrame = util.newFrame(0, 0, 0, 0); rectFrame.setLayer(4); rectFrame.setColor(200, 171, 113); rectFrame.fillRect(rectBX, rectBY, rectBW, rectBH); imageBox.add(rectFrame); frameFrame = util.newFrame(0, 0, 0, 0); frameFrame.setLayer(5); imageBox.add(frameFrame); statFrame = util.newFrame(0, 0, 0, 0); statFrame.setLayer(5); imageBox.add(statFrame); healthLFrame = util.newFrame(0, 0, 0, 0); healthLFrame.setLayer(5); healthLFrameMap = util.newHashtable(); imageBox.add(healthLFrame); healthRFrame = util.newFrame(0, 0, 0, 0); healthRFrame.setLayer(5); healthRFrameMap = util.newHashtable(); imageBox.add(healthRFrame); nameLFrame = util.newFrame(0, 0, 0, 0); nameLFrame.setLayer(5); imageBox.add(nameLFrame); nameRFrame = util.newFrame(0, 0, 0, 0); nameRFrame.setLayer(5); imageBox.add(nameRFrame); nameRData = util.newHashtable(); nameRStr = util.newHashtable(); framesCache = util.newArray(2000); markedFrame = 0 - 1; repeatFrame = 0; threadFrameId = 0; animationId = 0; effectSpeed = 5; effectCounterNew = 10; effectFrame0 = null; effectFrameCounter0 = 0; effectFrameNewMap0 = util.newHashtable(); effectFrameCounterAddMap0 = util.newHashtable(); effectFrame1 = null; effectFrameCounter1 = 0; effectFrameNewMap1 = util.newHashtable(); effectFrameCounterAddMap1 = util.newHashtable(); effectFrame2 = null; effectFrameCounter2 = 0; effectFrameNewMap2 = util.newHashtable(); effectFrameCounterAddMap2 = util.newHashtable(); effectFrame3 = null; effectFrameCounter3 = 0; effectFrameNewMap3 = util.newHashtable(); effectFrameCounterAddMap3 = util.newHashtable(); ff = util.newHashtable(); } function addSlices(_frame, _arr) { _arr_len = _arr.length(); for (_i = 0; _i < _arr_len; _i = _i + 1) { _f = _arr.get(_i); _frame.add(_f); } } function sendMarkedFrame() { toServer.put('mf', animationId); util.sendToServer(); toServer.clear(); } function sendOnLoad() { toServer.put('init', 1); util.sendToServer(); toServer.clear(); } function render(_frameId, _frame, _frameMap) { if (_frameMap.get(_frameId) != null) { _frame.removeAll(); _arr = _frameMap.get(_frameId); _arr_len = _arr.length(); for (_i = 0; _i < _arr_len; _i = _i + 1) { _frame.add(_arr.get(_i)); } _frameMap.remove(_frameId); } } function renderXY(_frameId, _frame, _frameArr, _mirror) { if (_frameArr.get(_frameId) != null) { _frame.removeAll(); _tmp = _frameArr[_frameId]; _key = _tmp[0]; _x = _tmp[1]; _y = _tmp[2]; _weapon = _tmp[3]; _tmp = fcMap.get(_key); _center = _tmp[0]; _height = _tmp[1]; _slices = _tmp[2]; _slicesCount = _slices.length(); _dx = 0; _dy = 0; for (_i = 0; _i < _slicesCount; _i++) { _sliceData = _slices[_i]; if (_sliceData == null) { break; } if (!_mirror) { _dx = _sliceData[1] + _x - _center; } else { _dx = _x - _center - (_sliceData[5] - (_center - _sliceData[1])) + _center; } _dy = _sliceData[2] + _y - _height; _sliceMirror = !_mirror; if (_sliceData[7] == 0) { _sliceMirror = !_sliceMirror; } _tmpname = charNameMap.get(_sliceData[0]); if (_tmpname == 'weapon.png') { _weaponData; if (_sliceData[4] == weaponHS) { _weaponData = weapon[_weapon + 12]; } else { _weaponData = weapon[_weapon]; } _dy = _dy - (_weaponData[3] - _sliceData[6]) / 2; _slice = util.newSlice('GOL:app:' + _tmpname, _dx, _dy, _weaponData[0], _weaponData[1], _weaponData[2], _weaponData[3], _sliceMirror); } else { _slice = util.newSlice('GOL:app:' + _tmpname, _dx, _dy, _sliceData[3], _sliceData[4], _sliceData[5], _sliceData[6], _sliceMirror); } _frame.add(_slice); } } } //0 sliceDataXML.getSourcePath() //1 sliceDataXML.getDestX() //2 sliceDataXML.getDestY() //3 sliceDataXML.getSourceX() //4 sliceDataXML.getSourceY() //5 sliceDataXML.getSourceW() //6 sliceDataXML.getSourceH() function getEffectFrame(_id) { if (_id == 0) { return effectFrame0; } if (_id == 1) { return effectFrame1; } if (_id == 2) { return effectFrame2; } if (_id == 3) { return effectFrame3; } } function getEffectFrameNewMap(_id) { if (_id == 0) { return effectFrameNewMap0; } if (_id == 1) { return effectFrameNewMap1; } if (_id == 2) { return effectFrameNewMap2; } if (_id == 3) { return effectFrameNewMap3; } } function setEffectFrame(_id, _frame) { if (_id == 0) { effectFrame0 = _frame; } if (_id == 1) { effectFrame1 = _frame; } if (_id == 2) { effectFrame2 = _frame; } if (_id == 3) { effectFrame3 = _frame; } } function getEffectFrameCounterAddMap(_id) { if (_id == 0) { return effectFrameCounterAddMap0; } if (_id == 1) { return effectFrameCounterAddMap1; } if (_id == 2) { return effectFrameCounterAddMap2; } if (_id == 3) { return effectFrameCounterAddMap3; } } function getEffectFrameCounter(_id) { if (_id == 0) { return effectFrameCounter0; } if (_id == 1) { return effectFrameCounter1; } if (_id == 2) { return effectFrameCounter2; } if (_id == 3) { return effectFrameCounter3; } } function decEffectFrameCounter(_id) { if (_id == 0) { effectFrameCounter0 = effectFrameCounter0 - 1; } if (_id == 1) { effectFrameCounter1 = effectFrameCounter1 - 1; } if (_id == 2) { effectFrameCounter2 = effectFrameCounter2 - 1; } if (_id == 3) { effectFrameCounter3 = effectFrameCounter3 - 1; } } function setEffectFrameCounter(_id, _value) { if (_id == 0) { effectFrameCounter0 = _value; } if (_id == 1) { effectFrameCounter1 = _value; } if (_id == 2) { effectFrameCounter2 = _value; } if (_id == 3) { effectFrameCounter3 = _value; } } function processEffect(_id) { _effectFrameNewMap = getEffectFrameNewMap(_id); _effectFrame = getEffectFrame(_id); _effectFrameCounterAddMap = getEffectFrameCounterAddMap(_id); if (_effectFrameNewMap.get(threadFrameId) != null) { //���� ������ ��� �� ������� if (_effectFrame != null) { imageBox.remove(_effectFrame); } _effectFrame = util.newFrame(0, 0, 0, 0); setEffectFrame(_id, _effectFrame); _effectFrame.setLayer(3); imageBox.add(_effectFrame); // �������� � ����� ����� �������, �������������������� ������ _arr = _effectFrameNewMap.get(threadFrameId); _effectFrameNewMap.remove(threadFrameId); _arr_len = _arr.length(); for (_i = 0; _i < _arr_len; _i = _i + 1) { _slice = _arr.get(_i); _effectFrame.add(_slice); } _counter_add = _effectFrameCounterAddMap.get(threadFrameId); _effectFrameCounterAddMap.remove(threadFrameId); setEffectFrameCounter(_id, effectCounterNew + _counter_add); } if (_effectFrameNewMap.get(100) != null) { //���� ������ ��� �� ������� if (_effectFrame != null) { imageBox.remove(_effectFrame); } _effectFrame = util.newFrame(0, 0, 0, 0); setEffectFrame(_id, _effectFrame); _effectFrame.setLayer(3); imageBox.add(_effectFrame); // �������� � ����� ����� �������, �������������������� ������ _arr = _effectFrameNewMap.get(100); _effectFrameNewMap.remove(100); _arr_len = _arr.length(); for (_i = 0; _i < _arr_len; _i = _i + 1) { _slice = _arr.get(_i); _effectFrame.add(_slice); } _counter_add = _effectFrameCounterAddMap.get(100); _effectFrameCounterAddMap.remove(100); setEffectFrameCounter(_id, effectCounterNew + _counter_add); } _effectFrameCounter = getEffectFrameCounter(_id); if (_effectFrameCounter > 0) { // �������� ����� �� ��� _y = _effectFrame.getY(); _y = _y - effectSpeed; _effectFrame.setY(_y); //��������� ������ decEffectFrameCounter(_id); _effectFrameCounter = _effectFrameCounter - 1; //���� ������ ����� 0 �� �������� �����. if (_effectFrameCounter == 0) { _effectFrame.removeAll(); imageBox.remove(_effectFrame); setEffectFrame(_id, null); } } } function repaint() { synchronized(lock) { processEffect(0); processEffect(1); processEffect(2); processEffect(3); if (heroBFrameArrSize > 0) { if (ff.get(threadFrameId) != null) { if (ff.get(threadFrameId) == 1) { heroBFrame.setLayer(2); heroAFrame.setLayer(1); } else { heroBFrame.setLayer(1); heroAFrame.setLayer(2); } } if (nameRData.get(threadFrameId) != null) { showRlabel(threadFrameId); } render(0 - 1, healthLFrame, healthLFrameMap); render(threadFrameId, healthLFrame, healthLFrameMap); render(0 - 1, healthRFrame, healthRFrameMap); render(threadFrameId, healthRFrame, healthRFrameMap); renderXY(threadFrameId, heroBFrame, heroBFrameArr, false); renderXY(threadFrameId, heroAFrame, heroAFrameArr, true); if (markedFrame == threadFrameId) { markedFrame = 0 - 1; sendMarkedFrame(); } threadFrameId = threadFrameId + 1; if (threadFrameId == heroBFrameArrSize) { threadFrameId = repeatFrame; } window.doTact(); } } } function showRlabel(_frameId) { _str = nameRStr.get(_frameId); _data = nameRData.get(_frameId); a0 = _data.get(0); a1 = _data.get(1); a2 = _data.get(2); a3 = _data.get(3); a4 = _data.get(4); a5 = _data.get(5); showLabel(a0, a1, _str, a5, nameRFrame); } if (null == lock) { init(); needStart = true; out.println('start engine 2'); sendOnLoad(); } thread = util.setInterval('repaint()', 200);