getResourcesByType('laser', array('resourceID' => $_POST['rid'])); if ( count($objs) == 1 ) { $ob = $objs[0]; if (isset($_POST['get_all_data']) && is_numeric($_POST['get_all_data']) ) { $robo_data = array($ob->getRoboPosition(),$ob->getFriendPosition(),$ob->getGameTable(),$ob->getTableWidth(),$ob->getTableHeight()); print json_encode($robo_data); } else if (isset($_POST['save_data']) && is_numeric($_POST['save_data']) ) { if ( isset($_POST['robo_pos']) ) { $ob->setRoboPosition($_POST['robo_pos']); } if ( isset($_POST['friend_pos']) ) { $ob->setFriendPosition($_POST['friend_pos']); } if ( isset($_POST['game_table']) ) { $ob->setGameTable(json_decode( stripslashes($_POST['game_table']))); } if ( isset($_POST['game_tools']) ) { $useTools = json_decode( stripslashes($_POST['game_tools'])); $uts = array(); foreach($useTools as $useTool) { $ut = split(":", $useTool); $uts[$ut[0]] = $ut[1]; } $ob->setUseTools($uts); } if ( isset($_POST['game_table_w']) ) { $ob->setTableWidth(json_decode( stripslashes($_POST['game_table_w']))); } if ( isset($_POST['game_table_h']) ) { $ob->setTableHeight(json_decode( stripslashes($_POST['game_table_h']))); } $save_message = $ob->saveCompiledGame(); print json_encode($save_message); } } } ?>