PageRenderTime 47ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/1.0/arpg/src/arpg.as

http://as3chat.googlecode.com/
ActionScript | 709 lines | 561 code | 104 blank | 44 comment | 63 complexity | a06ea4d2e76c63c68afffef56a0bb2b3 MD5 | raw file
  1. package
  2. {
  3. import mx.core.ClassFactory;
  4. import as3isolib.display.IsoSprite;
  5. import as3isolib.display.IsoView;
  6. import as3isolib.display.primitive.IsoBox;
  7. import as3isolib.display.renderers.*;
  8. import as3isolib.display.scene.IsoGrid;
  9. import as3isolib.display.scene.IsoScene;
  10. import as3isolib.geom.IsoMath;
  11. import as3isolib.geom.Pt;
  12. import as3isolib.graphics.SolidColorFill;
  13. import as3isolib.graphics.Stroke;
  14. import com.gskinner.motion.GTween;
  15. import component.LoginJFrame;
  16. import component.MiniMap;
  17. import component.PlayerStatusContainer;
  18. import component.ToolContainer;
  19. import eDpLib.events.ProxyEvent;
  20. import flash.display.Sprite;
  21. import flash.events.Event;
  22. import flash.events.MouseEvent;
  23. import flash.net.URLLoader;
  24. import flash.net.URLRequest;
  25. import org.aswing.ASColor;
  26. import org.aswing.AsWingManager;
  27. import org.aswing.CursorManager;
  28. import org.aswing.GeneralListCellFactory;
  29. import org.aswing.JFrame;
  30. import org.aswing.JList;
  31. import org.aswing.JOptionPane;
  32. import org.aswing.JPanel;
  33. import org.aswing.JScrollPane;
  34. import org.aswing.JTextArea;
  35. import org.aswing.JWindow;
  36. import org.aswing.UIManager;
  37. import org.aswing.VectorListModel;
  38. import org.aswing.event.AWEvent;
  39. import org.myleft.UserListCell;
  40. import org.myleft.astar.AStar;
  41. import org.myleft.core.SocketConnection;
  42. import org.myleft.data.CharacterStatic;
  43. import org.myleft.data.Define;
  44. import org.myleft.data.TileMap;
  45. import org.myleft.data.User;
  46. import org.myleft.events.SocketConnectionEvent;
  47. import org.myleft.geom.IntPoint;
  48. import skins.ALookAndFeel;
  49. [SWF(backgroundColor="#869ca7")]//,frameRate="30"
  50. public class arpg extends Sprite
  51. {
  52. private var socket:SocketConnection;
  53. private var userJlist:JList
  54. private var model:VectorListModel = new VectorListModel;
  55. private var myinfo:User;
  56. private var time:Date;
  57. //????
  58. private var minimap:MiniMap;
  59. private var floorScene:IsoScene;
  60. private var mainScene:IsoScene;
  61. private var frontScene:IsoScene;
  62. //????
  63. private var view:IsoView;
  64. private var rectBox:IsoBox;
  65. private var heroBox:IsoSprite;
  66. private var boxfills:Array=[new SolidColorFill(0xff0000, .5), new SolidColorFill(0x00ff00, .5), new SolidColorFill(0x0000ff, .5), new SolidColorFill(0xff0000, .5), new SolidColorFill(0x00ff00, .5), new SolidColorFill(0x0000ff, .5)];
  67. //????
  68. private var tileSize:int=50;
  69. private var tileMap:TileMap;
  70. //??????
  71. private var currentPt:IntPoint;
  72. private var myGTween:GTween;
  73. //????
  74. private var mainWindow:JWindow;
  75. private var topContainer:JPanel;//????
  76. private var playerStatusContainer:PlayerStatusContainer;//?????
  77. private var toolContainer:ToolContainer;//?????
  78. private var scrollPane:JScrollPane;
  79. private var chatText:JTextArea;
  80. private var loginDialog:LoginJFrame;
  81. private var progressDialog:progressJFrame;
  82. private var mysound:mySound;
  83. private var xmlLoader:URLLoader;
  84. public function arpg()
  85. {
  86. AsWingManager.initAsStandard(this);
  87. CursorManager.getManager().showCustomCursor(CursorAnimation.defaultCursor);
  88. UIManager.setLookAndFeel(new ALookAndFeel());
  89. myGTween=new GTween();
  90. this.cacheAsBitmap = true;
  91. currentPt=new IntPoint(1, 1);
  92. mysound = new mySound();
  93. loadmap("data/map01.xml");
  94. game_init();
  95. this.addChild(view);
  96. /** ??? **/
  97. playerStatusContainer=new PlayerStatusContainer;
  98. playerStatusContainer.mouseEnabled = false;
  99. playerStatusContainer.validate();
  100. this.addChild(playerStatusContainer);
  101. //????
  102. var userJframe:JFrame = new JFrame(this, "??????");
  103. userJframe.setClosable(false);
  104. userJframe.setResizable(false);
  105. userJlist = new JList(model, new GeneralListCellFactory(UserListCell,false,false));
  106. userJframe.setSizeWH(200, 300);
  107. userJframe.getContentPane().append(new JScrollPane(userJlist));
  108. userJframe.setLocationXY(0, playerStatusContainer.height);
  109. userJframe.show();
  110. myinfo = new User;
  111. /** ??? **/
  112. minimap = new MiniMap();
  113. minimap.mouseEnabled = false;
  114. minimap.x = stage.stageWidth - minimap.width;
  115. minimap.y = 0;
  116. this.addChild(minimap);
  117. /** ??? **/
  118. toolContainer=new ToolContainer();
  119. toolContainer.mouseEnabled=false;
  120. toolContainer.setSizeWH(stage.stageWidth, 30);
  121. toolContainer.y = stage.stageHeight - toolContainer.height;
  122. toolContainer.validate();
  123. this.addChild(toolContainer);
  124. //????
  125. chatText = new JTextArea;
  126. chatText.setWordWrap(true);
  127. chatText.setBackground(new ASColor(0, 0));
  128. chatText.setForeground(new ASColor(0xff0000));
  129. scrollPane = new JScrollPane(chatText);
  130. scrollPane.mouseEnabled = false;
  131. scrollPane.setSizeWH(300, 150);
  132. scrollPane.validate();
  133. scrollPane.y = toolContainer.y - scrollPane.height;
  134. this.addChild(scrollPane);
  135. toolContainer.messageText.addActionListener(sendFun);
  136. toolContainer.sendButton.addActionListener(sendFun);
  137. toolContainer.quitButton.addActionListener(quitFun);
  138. toolContainer.walkButton.addActionListener(function(e:AWEvent):void
  139. {
  140. var p:IntPoint;
  141. switch (heroBox.sprites[0].getDirection())
  142. {
  143. case 0: //x
  144. p=screenToMap(heroBox.x + tileSize, heroBox.y);
  145. break;
  146. case 1: //y
  147. p=screenToMap(heroBox.x, heroBox.y + tileSize);
  148. break;
  149. case 2: //-x
  150. p=screenToMap(heroBox.x - tileSize, heroBox.y);
  151. break;
  152. case 3: //-y
  153. p=screenToMap(heroBox.x, heroBox.y - tileSize);
  154. break;
  155. }
  156. if (tileMap.isWalkable(p.x, p.y))
  157. {
  158. myinfo.solution=[];
  159. myinfo.solution.push(p);
  160. if (myGTween && myGTween.position < 1)
  161. return;
  162. timeStart(null, myinfo);
  163. }
  164. });
  165. toolContainer.toggleButton.addActionListener(function(e:AWEvent):void
  166. {
  167. heroBox.sprites[0].toggleDirection();
  168. });
  169. toolContainer.upButton.addActionListener(function(e:AWEvent):void
  170. {
  171. heroBox.sprites[0].setDirection(3);
  172. });
  173. toolContainer.downButton.addActionListener(function(e:AWEvent):void
  174. {
  175. heroBox.sprites[0].setDirection(1);
  176. });
  177. toolContainer.leftButton.addActionListener(function(e:AWEvent):void
  178. {
  179. heroBox.sprites[0].setDirection(2);
  180. });
  181. toolContainer.rightButton.addActionListener(function(e:AWEvent):void
  182. {
  183. heroBox.sprites[0].setDirection(0);
  184. });
  185. time = new Date;
  186. var username:String = '??'+((Math.random()*1000)>>0)+time.getHours()+time.getSeconds()+time.getHours()
  187. loginDialog = new LoginJFrame(mainWindow, "??", true);
  188. loginDialog.setResizable(false);
  189. loginDialog.pack();
  190. loginDialog.usernameText.setText(username);
  191. loginDialog.setLocationXY((stage.stageWidth-loginDialog.width)*0.5, (stage.stageHeight-loginDialog.height)*0.5);
  192. loginDialog.loginButton.addActionListener(loginClickHandle);
  193. loginDialog.connectButton.addActionListener(connectClickHandle);
  194. loginDialog.show();
  195. //???
  196. progressDialog = new progressJFrame(mainWindow, "???");
  197. progressDialog.pack();
  198. progressDialog.setLocationXY((stage.stageWidth-progressDialog.width)*0.5, (stage.stageHeight-progressDialog.height)*0.5);
  199. socket = new SocketConnection;
  200. socket.addEventListener(Define.CONNECT, eventHandle);
  201. socket.addEventListener(Define.CLOSE, eventHandle);
  202. socket.addEventListener(Define.EV_TYPE_AUTH, eventHandle);
  203. socket.addEventListener(Define.EV_TYPE_USER_ADD, eventHandle);
  204. socket.addEventListener(Define.EV_TYPE_USER_LOGIN, eventHandle);
  205. socket.addEventListener(Define.EV_TYPE_USER_LOGOUT, eventHandle);
  206. socket.addEventListener(Define.EV_TYPE_AUTH_OTHER_LOGIN, eventHandle);
  207. socket.addEventListener(Define.EV_TYPE_MESSAGE, eventHandle);
  208. socket.addEventListener(Define.EV_TYPE_MOVE, eventHandle);
  209. stage.addEventListener(Event.RESIZE, resizeHandler);
  210. }
  211. public function loadmap(url:String):void {
  212. if (!this.xmlLoader) this.xmlLoader = new URLLoader();
  213. this.xmlLoader.addEventListener(Event.COMPLETE, createData);
  214. this.xmlLoader.load(new URLRequest(url));
  215. }
  216. private function createData(e:Event):void {
  217. this.xmlLoader.removeEventListener(Event.COMPLETE, createData);
  218. XML.ignoreWhitespace = true;
  219. var mapdata:XML = new XML(e.target.data);
  220. var building:XMLList = mapdata.building.item;
  221. if (mapdata.grid.attribute('tileSize')) this.tileSize = mapdata.grid.attribute('tileSize');
  222. //????
  223. if (!tileMap) tileMap=new TileMap();
  224. tileMap.initialize(mapdata.grid.attribute('w'), mapdata.grid.attribute('h'));
  225. var a:IsoSprite=new IsoSprite();
  226. a.setSize(this.tileSize*2, this.tileSize*1/2, this.tileSize*1/2);
  227. a.moveTo(tileSize*3+10, tileSize*3+10, tileSize*1);
  228. a.sprites=[new Talisman()];
  229. mainScene.addChild(a);
  230. var pos:Array,size:Array;
  231. for each (var item:XML in building) {
  232. pos = item.attribute('pos').toString().split(',');
  233. size = item.attribute('size').toString().split(',');
  234. trace('walkable', item.attribute('walkable')!='0');
  235. tileMap.setWalkableRect(pos[0], pos[1], size[0], size[1], item.attribute('walkable')!='0');
  236. var b:IsoSprite=new IsoSprite();
  237. b.setSize(this.tileSize*size[0], this.tileSize*size[1], this.tileSize*size[2]);
  238. b.moveTo(tileSize*pos[0], tileSize*pos[1], tileSize*pos[2]);
  239. b.sprites=[Building[item.attribute('name')]];
  240. mainScene.addChild(b);
  241. trace(" item: "+ item.attributes().toString());
  242. }
  243. minimap.initialize(tileMap);
  244. }
  245. private function sendFun(e:AWEvent):void
  246. {
  247. if (toolContainer.messageText.getText().length>256)
  248. {
  249. JOptionPane.showMessageDialog("Hello", "????????256???");
  250. }
  251. else if (socket.socket.connected && toolContainer.messageText.getText().length>0)
  252. {
  253. var toStr:String = userJlist.getSelectedValue() && userJlist.getSelectedValue().username!='???' ? "to='"+User(userJlist.getSelectedValue()).username+"'" : '';
  254. socket.send("<event type='"+Define.EV_TYPE_MESSAGE+"' "+toStr+"><body>"+toolContainer.messageText.getText()+"</body></event>");
  255. toolContainer.messageText.setText("");
  256. }
  257. }
  258. private function quitFun(e:Event):void
  259. {
  260. if (socket.socket.connected) socket.send('<quit/>');
  261. }
  262. private function eventHandle(e:SocketConnectionEvent):void
  263. {
  264. progressDialog.hide();
  265. //trace(e.type);
  266. //trace(e.body.toString());
  267. var o:Object = e.body.attributes;
  268. var i:int;
  269. switch(e.type)
  270. {
  271. case Define.CONNECT:
  272. loginDialog.setConnectEnabled(false);
  273. loginDialog.setLoginEnabled(true);
  274. break;
  275. case Define.EV_TYPE_AUTH_OTHER_LOGIN:
  276. this.mylogout();
  277. loginDialog.show();
  278. JOptionPane.showMessageDialog("Hello", e.body.attributes.message);
  279. break;
  280. case Define.CLOSE:
  281. this.mylogout();
  282. loginDialog.setConnectEnabled(true);
  283. loginDialog.setLoginEnabled(false);
  284. loginDialog.show();
  285. break;
  286. case Define.EV_TYPE_USER_ADD:
  287. case Define.EV_TYPE_USER_LOGIN:
  288. var user:User = new User(o.username, createSprite(o.username, o.x, o.y));
  289. //trace("append", o.username, o.x, o.y);
  290. user.nextpoint = user.point = new IntPoint(o.x, o.y);
  291. if (myinfo.username == o.username)
  292. {
  293. myinfo = user;
  294. heroBox = myinfo.display;
  295. minimap.drawRole(myinfo.point);
  296. this.view.centerOnIso(heroBox);
  297. this.view.render();
  298. }
  299. else
  300. {
  301. mysound.play(mySound.online);
  302. //trace("append2", o.username, o.x, o.y);
  303. }
  304. model.append(user);
  305. this.mainScene.addChild(user.display);
  306. this.mainScene.render();
  307. break;
  308. case Define.EV_TYPE_USER_LOGOUT://??????
  309. for (i=0;i < model.getSize(); i++)
  310. {
  311. if (User(model.get(i)).username == o.username)
  312. {
  313. deleteUser( User(model.get(i)) );
  314. break;
  315. }
  316. }
  317. this.mainScene.render();
  318. break;
  319. case Define.EV_TYPE_AUTH:
  320. if (e.body.attributes.result==1)
  321. {
  322. myinfo.username = o.username;
  323. mainScene.render();
  324. loginDialog.hide();
  325. this.mainScene.container.visible = true;
  326. JOptionPane.showMessageDialog("Hello", "????");
  327. }
  328. else
  329. {
  330. loginDialog.show();
  331. this.mainScene.container.visible = false;
  332. JOptionPane.showMessageDialog("Hello", e.body.attributes.message);
  333. }
  334. break;
  335. case Define.EV_TYPE_MESSAGE:
  336. var ismy:Boolean = myinfo.username==e.body.attributes.from? true : false;
  337. var istomy:Boolean = myinfo.username==e.body.attributes.to? true : false;
  338. var toString:String =e.body.attributes.to ? ' ? <b>'+ e.body.attributes.to + '</b>' : '';
  339. var date:Date = new Date(int(e.body.attributes.timestamp) * 1000);
  340. var dateStr:String = " (" + date.fullYear + "-" + (date.month+1) + "-" + date.date + " " + date.hours + ":" + date.minutes + ")";
  341. var msgStr:String = e.body.firstChild.firstChild.toString();
  342. if (ismy)
  343. {
  344. msgStr = '<font color="#0066FF">' + msgStr + '</font>';
  345. }
  346. if (toString)
  347. {
  348. if (istomy)
  349. {
  350. mysound.play(mySound.msg);
  351. }
  352. chatText.setHtmlText( '<font color="#FF6600"><b>' + e.body.attributes.from + '</b></font>'+ toString +' ?:' + msgStr + dateStr + "<br/>" + chatText.getHtmlText());
  353. }
  354. else
  355. {
  356. if (e.body.attributes.from)
  357. {
  358. chatText.setHtmlText( '<font color="#FF6600"><b>' + e.body.attributes.from + '</b></font> ?:' + msgStr + dateStr + "<br/>" + chatText.getHtmlText());
  359. }
  360. else
  361. {
  362. chatText.setHtmlText( '<b>???</b>' + msgStr + dateStr + "<br/>" + chatText.getHtmlText());
  363. }
  364. }
  365. break;
  366. case Define.EV_TYPE_MOVE:
  367. //trace("EV_TYPE_MOVE");
  368. for (i=0;i < model.getSize(); i++)
  369. {//trace(myinfo.username, o.from, User(model.get(i)).username, User(model.get(i)).username == o.from);
  370. if (User(model.get(i)).username == o.from && o.from!=myinfo.username)
  371. {
  372. //trace(o.from, User(model.get(i)).username);
  373. User(model.get(i)).solution.push(new IntPoint(o.x, o.y));
  374. if (User(model.get(i)).gt && User(model.get(i)).gt.position<1 && User(model.get(i)).gt.position>0) return;
  375. timeStart(User(model.get(i)).gt, User(model.get(i)));
  376. //User(model.get(i)).display.moveTo(o.x * tileSize, o.y * tileSize, 0);
  377. //this.mainScene.render();
  378. break;
  379. }
  380. }
  381. break;
  382. }
  383. }
  384. //??
  385. private function connectClickHandle(e:AWEvent):void
  386. {
  387. if (!socket.socket.connected) {
  388. progressDialog.setTitle('???...');
  389. progressDialog.show();
  390. socket.connect(loginDialog.hostText.getText(), int(loginDialog.portText.getText()));
  391. }
  392. }
  393. //??
  394. private function loginClickHandle(e:AWEvent):void
  395. {
  396. progressDialog.setTitle('???...');
  397. progressDialog.show();
  398. if (loginDialog.usernameText.getText().length>0 && loginDialog.passwordText.getText().length>0)
  399. {
  400. var temp:String="<event type='"+Define.EV_TYPE_AUTH+"' ";
  401. temp += "username='"+loginDialog.usernameText.getText()+"' ";
  402. temp += "password='"+loginDialog.passwordText.getText()+"' ";
  403. temp = temp+"/>";
  404. socket.send(temp);
  405. }
  406. else
  407. {
  408. socket.send("<event type='"+Define.EV_TYPE_AUTH+"' anonymous='1'/>");
  409. }
  410. }
  411. //????
  412. private function sendMove(x:int, y:int):void
  413. {
  414. socket.send("<event type='"+Define.EV_TYPE_MOVE+"' from='"+myinfo.username+"' x='"+x+"' y='"+y+"'/>");
  415. }
  416. //????
  417. private function mylogout():void
  418. {
  419. this.rectBox.moveTo(0, 0, 0);
  420. this.floorScene.render();
  421. myinfo.gt.paused = true;
  422. myinfo.clear();
  423. while (model.getSize())
  424. {
  425. deleteUser( User(model.get(0)) );
  426. }
  427. model.clear();
  428. //this.mainScene.removeAllChildren();
  429. this.mainScene.render();
  430. this.mainScene.container.visible = false;
  431. }
  432. private function deleteUser(user:User):void
  433. {
  434. trace(user);
  435. trace(user.display);
  436. var obj:IsoSprite;
  437. obj = IsoSprite(user.display);
  438. obj.removeAllChildren();
  439. this.mainScene.removeChild(obj);
  440. obj = null;
  441. model.remove(user);
  442. user = null;
  443. }
  444. //???
  445. private function game_init():void
  446. {
  447. /** ?? **/
  448. view=new IsoView();
  449. view.mouseEnabled = false;
  450. //view.autoUpdate = true;
  451. view.clipContent=true; //??
  452. //view.viewRenderers = [new ClassFactory(DefaultViewRenderer)];//,new ClassFactory(ViewBoundsRenderer)
  453. //view.setSize(300, 400);
  454. view.setSize(stage.stageWidth, stage.stageHeight);
  455. /** ?? ?? **/
  456. floorScene=new IsoScene();
  457. rectBox=new IsoBox();
  458. rectBox.fills=[null, null, null, null, null, new SolidColorFill(0xff0000, .5)];
  459. rectBox.setSize(tileSize, tileSize, 0);
  460. floorScene.addChild(rectBox);
  461. floorScene.render();
  462. view.addScene(floorScene);
  463. /** ?? ?? **/
  464. mainScene=new IsoScene();
  465. //mainScene.layoutEnabled = true;
  466. mainScene.hostContainer=this;
  467. var factory:ClassFactory=new ClassFactory(DefaultShadowRenderer);
  468. factory.properties={shadowColor: 0x000000, shadowAlpha: 0.3, drawAll: true};
  469. mainScene.styleRenderers=[factory];
  470. view.addScene(mainScene);
  471. //??
  472. frontScene = new IsoScene;
  473. var grid:IsoGrid=new IsoGrid();
  474. grid.showOrigin = false;
  475. grid.gridlines = new Stroke(0, 0xCCCCCC, 0.1);
  476. grid.cellSize=tileSize;
  477. grid.setGridSize(20, 20);
  478. grid.addEventListener(MouseEvent.CLICK, grid_mouseHandler);
  479. frontScene.addChild(grid);
  480. frontScene.render();
  481. view.addScene(frontScene);
  482. view.render();
  483. }
  484. //??????
  485. private function createSprite(username:String, x:int, y:int):IsoSprite
  486. {
  487. var spritex:IsoSprite=new IsoSprite();
  488. spritex.setSize(40, 40, 40);
  489. spritex.moveTo(x*tileSize, y*tileSize, 0);
  490. spritex.sprites=[new Character(username)];
  491. return spritex;
  492. }
  493. //????
  494. private function grid_mouseHandler(evt:ProxyEvent):void
  495. {
  496. var mEvt:MouseEvent=MouseEvent(evt.targetEvent);
  497. var pt:Pt=new Pt(mEvt.localX, mEvt.localY);
  498. IsoMath.screenToIso(pt);
  499. var goal:IntPoint=screenToMap(pt.x, pt.y);
  500. if (evt.type == MouseEvent.CLICK)
  501. {
  502. if (tileMap.isWalkable(goal.x, goal.y))
  503. {
  504. var a:AStar=new AStar(tileMap, myinfo.nextpoint, goal);
  505. myinfo.solution = a.solve();
  506. myinfo.solution.pop();
  507. if (myinfo.solution)
  508. {
  509. this.rectBox.moveTo(goal.x * tileSize, goal.y * tileSize, 0);
  510. this.floorScene.render();
  511. if (myinfo.gt && myinfo.gt.position < 1 && myinfo.gt.paused==false)
  512. {
  513. trace('myinfo timeStart return ');
  514. return;
  515. }
  516. timeStart(myinfo.gt, myinfo);
  517. }
  518. }
  519. }
  520. }
  521. private function pointToDirection(p1:IntPoint, p2:IntPoint):int
  522. {
  523. if (p1.x < p2.x)
  524. {
  525. return 0;
  526. }
  527. else if (p1.y < p2.y)
  528. {
  529. return 1;
  530. }
  531. else if (p1.x > p2.x)
  532. {
  533. return 2;
  534. }
  535. else if (p1.y > p2.y)
  536. {
  537. return 3;
  538. }
  539. return this.heroBox.sprites[0].getDirection();
  540. }
  541. private function screenToMap(x:int, y:int):IntPoint
  542. {
  543. return new IntPoint((x / this.tileSize)>>0, (y / this.tileSize)>>0);//Math.floor uint
  544. }
  545. //????
  546. private function resizeHandler(e:Event):void
  547. {
  548. view.setSize(stage.stageWidth, stage.stageHeight);
  549. /** ??? **/
  550. minimap.x = stage.stageWidth - minimap.width;
  551. /** ??? **/
  552. toolContainer.y = stage.stageHeight - toolContainer.height;
  553. scrollPane.y = toolContainer.y - scrollPane.height;
  554. }
  555. //??
  556. private function timeStart(e:GTween, user:User):void
  557. {
  558. if (user.solution.length > 0)
  559. {
  560. if (user.username == myinfo.username)
  561. {
  562. var path:Array = user.solution.concat();
  563. path.push(user.nextpoint);
  564. minimap.drawPath(path);
  565. //minimap.drawPath(user.solution);
  566. }
  567. if (e==null)
  568. e=new GTween();
  569. e.target = user.display;
  570. e.paused = false;
  571. e.duration = 1;
  572. e.onComplete = function(event:GTween):void{
  573. trace('onComplete', user.username);
  574. user.point = user.nextpoint;
  575. timeStart(event, user);
  576. };
  577. e.onChange = function():void
  578. {
  579. if (user.username == myinfo.username)
  580. {
  581. view.centerOnIso(heroBox);
  582. view.render();
  583. }
  584. mainScene.render();
  585. };
  586. //trace(user.solution[user.solution.length-1].x, user.solution[user.solution.length-1].y);
  587. user.nextpoint = user.solution.pop();
  588. if (user.username==myinfo.username) sendMove(user.nextpoint.x, user.nextpoint.y);
  589. var p1:IntPoint=screenToMap(user.point.x, user.point.y);
  590. //trace('.toString()',user.point.toString(), user.nextpoint.toString());
  591. //trace(user.display.sprites[0]);
  592. if (user.display) user.display.sprites[0].setDirection(pointToDirection(user.point, user.nextpoint));
  593. if (user.display && user.display.sprites[0].state != CharacterStatic.walk)
  594. if (user.display) user.display.sprites[0].walk();
  595. e.setValues({"y":user.nextpoint.y * tileSize, "x":user.nextpoint.x * tileSize});
  596. }
  597. else
  598. {
  599. if (user.display) user.display.sprites[0].stand();
  600. }
  601. if (user.username==myinfo.username) minimap.drawRole(user.point);
  602. mainScene.render();
  603. }
  604. }
  605. }