public static void main(String... args) throws IOException { InputStream contentStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("move.txt"); SceneManager sceneManager = new SceneManager(); FileReader parser = new FileReader(contentStream, sceneManager); parser.processLineByLine(); sceneManager.resolveMoves(); for (Mower mower : sceneManager.getMowerList()) { System.out.println(mower.toString()); } }
@Override public void start(Stage stage) throws Exception { stage.setTitle("Tetris"); Group root = new Group(); Scene scene = new Scene(root, 800, 400); stage.setScene(scene); stage.show(); SceneManager scmanager = new SceneManager(stage, scene, root); stage.setOnCloseRequest(scmanager.getOnCloseWindow()); scmanager.launch(); }
protected void onStart() { Log.v("ThemeDetailedActivity", "onStart"); super.onStart(); if (!SceneManager.getInstance().FindThemes(theme.componentName.getPackageName())) { finish(); } }
public boolean saveSceneManager(String fileName) { XStream xstream = new XStream(new StaxDriver()); PrintStream outFile; boolean saved = true; try { outFile = new PrintStream(new FileOutputStream(fileName)); outFile.print(xstream.toXML(m_SceneManager.getSceneGraph())); outFile.println(); outFile.print(xstream.toXML(m_SceneManager.getItemList())); outFile.close(); } catch (Exception ex) { saved = false; } return saved; }
@Override public void onBackKeyPressed() { SharedPreferences.Editor editor = recordPref.edit(); editor.putInt("RECORD", record); editor.apply(); SceneManager.getInstance().loadMenuScene(engine); birdArray.clear(); plumageArray.clear(); }
public SceneManager loadSceneManager(String fileName) { String sXmlSceneInput = ""; String sXmlItemInput = ""; try { XStream xstream = new XStream(new StaxDriver()); Scanner input = new Scanner(new File(fileName)); if (input.hasNextLine()) sXmlSceneInput += input.nextLine(); if (input.hasNextLine()) sXmlItemInput += input.nextLine(); input.close(); m_SceneManager.setSceneGraph((ArrayList<Scene>) xstream.fromXML(sXmlSceneInput)); m_SceneManager.setItemList((ArrayList<Item>) xstream.fromXML(sXmlItemInput)); } catch (Exception ex) { } return m_SceneManager; }
public void onCreate(Bundle bundle) { Log.v("ThemeDetailedActivity", "onCreate"); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); super.onCreate(bundle); requestWindowFeature(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); sdactivity = this; mThemeDetailed = new SceneDetailed(this); Bundle extras = getIntent().getExtras(); index = extras.getInt(SceneDetailedActivity.class.getSimpleName()); if (index >= SceneManager.getInstance().getThemeDescriptions().size()) { finish(); } else { theme = SceneManager.getInstance().getThemeDescriptions().elementAt(index); if (!SceneManager.getInstance().FindThemes(theme.componentName.getPackageName())) { finish(); } else { SceneManager.getInstance().pushActivity(this); setContentView(mThemeDetailed); mThemeDetailed.LoadData(index); } } }
public boolean ccTouchesMoved(MotionEvent event) { if (event.getPointerCount() > 1) { currentItem = null; CGPoint current1 = CGPoint.make(event.getX(0), event.getY(0)); CGPoint current2 = CGPoint.make(event.getX(1), event.getY(1)); float before = getDistance(multi1, multi2); float current = getDistance(current1, current2); changeScale(current - before); multi1 = current1; multi2 = current2; } else { if (firstPt != null) { CGPoint convertedLocation = CCDirector.sharedDirector().convertToGL(CGPoint.make(event.getX(), event.getY())); CGPoint current = getPosition(); if (currentItem != null && GameStatus.isShowRoundMenu && isMoving) { currentItem.moveBy(convertedLocation.x - beforePt.x, convertedLocation.y - beforePt.y); SceneManager.getInstance() .interfaceLayer .moveByRoundMenu(convertedLocation.x - beforePt.x, convertedLocation.y - beforePt.y); } else { setPosition( current.x + (convertedLocation.x - beforePt.x), current.y + (convertedLocation.y - beforePt.y)); if (GameStatus.isShowRoundMenu) { SceneManager.getInstance() .interfaceLayer .moveByRoundMenu( convertedLocation.x - beforePt.x, convertedLocation.y - beforePt.y); } } beforePt = convertedLocation; } } return true; }
private void touched(CGPoint pt) { MapItemController item = null; int len = list.size(); for (int i = 0; i < len; i++) { item = list.get(i); if (item.checkDown(pt)) { currentItem = item; break; } } if (currentItem != null) { if (GameStatus.isMapEditMode) { CGPoint worldConvert = CGPoint.zero(); CGPoint itempt = currentItem.getImage().getPositionRef(); this.convertToWorldSpace(itempt.x, itempt.y, worldConvert); Log.i("maplayer_touched", "check"); SceneManager.getInstance().interfaceLayer.showRoundMenu(worldConvert); } else { // if deco -> show tooltip // else if crop -> harvest. } } }
public void checkCuttingOnAction(SceneManager sm, Timeline tl) { LinkedList<Event> eList = sm.getEventList(); ArrayList<Tick> tArr = tl.getTickArr(); ListIterator<Event> listIt; for (int i = 0; i < tArr.size(); i++) { // println("here"); listIt = eList.listIterator(); while (listIt.hasNext()) { Event tempEvent = listIt.next(); // check for time colisions. // println("event " + tempEvent.getTimeStamp() + " tick time " + // tArr.get(i).getTimeStamp() + " " + tempEvent.type); if ((tempEvent.getType() == DIA_TIME) && (tempEvent.getTimeStamp() == tArr.get(i).getTimeStamp())) { println("CUTTING ON ACTION ERROR!"); tArr.get(i).setCutViolation(true); } else { tArr.get(i).setCutViolation(false); } } } }
@Override public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) throws IOException { man.setCurrentScene(new MenuScreen(camera, this, man)); pOnCreateSceneCallback.onCreateSceneFinished(man.getScene()); }
/** * The main function of the game. Something fun starts here. :) * * @param args passed command line arguments. */ public static void main(String[] args) { if (!Resource.getInstance().initialize()) { JOptionPane.showMessageDialog( null, "Resource loading fail.", "Cannot open game", JOptionPane.ERROR_MESSAGE); return; } if (!LevelFileManager.getInstance().initialize()) { JOptionPane.showMessageDialog( null, "Level files loading fail.", "Cannot open game", JOptionPane.ERROR_MESSAGE); return; } // Create JFrame JFrame frame = new JFrame(Constants.PROGRAM_NAME); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // frame.setResizable(false); frame.setMinimumSize(Constants.MINIMUM_WINDOW_SIZE); frame .getContentPane() .addComponentListener( new ComponentListener() { @Override public void componentShown(ComponentEvent arg0) {} @Override public void componentResized(ComponentEvent arg0) { DrawManager.getInstance() .setCanvasSize( frame.getContentPane().getWidth(), frame.getContentPane().getHeight()); } @Override public void componentMoved(ComponentEvent arg0) {} @Override public void componentHidden(ComponentEvent arg0) {} }); if (Constants.IS_FULLSCREEN) { frame.setUndecorated(true); frame.setExtendedState(JFrame.MAXIMIZED_BOTH); } else { frame.getContentPane().setPreferredSize(Constants.DEFAULT_SCREEN_SIZE); frame.pack(); } InputManager.setListenerTo(frame); frame.getContentPane().setBackground(ColorSwatch.BACKGROUND); frame.setVisible(true); // Add canvas to the frame DrawManager.getInstance().addCanvasInto(frame); DrawManager.getInstance() .setCanvasSize(frame.getContentPane().getWidth(), frame.getContentPane().getHeight()); // Set initial scene SceneManager.getInstance().setNextScene(new scene.mainmenu.MainMenuScene(true)); // SceneManager.getInstance().setNextScene(new stage.GameStage(GameStageType.PLAY)); // Game looper final long maximumWaitTime = 1000000000 / Constants.MAX_FRAME_PER_SECOND; long updateTime; Resource.getInstance().themeSong.loop(); while (true) { // Perform a game update (including game logic and painting) updateTime = System.nanoTime(); SceneManager.getInstance().update(); updateTime = System.nanoTime() - updateTime; if (updateTime < maximumWaitTime) { FPSCollector.add(Constants.MAX_FRAME_PER_SECOND); } else { FPSCollector.add(Math.round(1000000000 / updateTime)); } // Perform sleeping to limit maximum FPS if (updateTime < maximumWaitTime) { try { Thread.sleep((maximumWaitTime - updateTime) / 1000000); } catch (InterruptedException e) { Thread.interrupted(); e.printStackTrace(); } } } }
@Override public void loadResources(BaseGameActivity context) { this.isLoaded = true; mScene.setTouchAreaBindingEnabled(true); // background SceneManager.bg_bitmapTextureAtlas.clearTextureAtlasSources(); SceneManager.bg_textureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( SceneManager.bg_bitmapTextureAtlas, context, "gfx/game script/level selector/MenuChoice_background.png", 0, 0); SceneManager.loadTexture(SceneManager.bg_bitmapTextureAtlas); SceneManager.bg_sprite = new Sprite(0, 0, SceneManager.bg_textureRegion); mScene.setBackground(new SpriteBackground(SceneManager.bg_sprite)); // menu this.SheetMenuBitmapTextureAtlas = new BitmapTextureAtlas(256, 128, TextureOptions.DEFAULT); this.Level_1_TextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( this.SheetMenuBitmapTextureAtlas, context, "gfx/game script/level selector/Level_1.png", 0, 0); this.Level_2_TextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset( this.SheetMenuBitmapTextureAtlas, context, "gfx/game script/level selector/Level_2.png", 0, 40); SceneManager.loadTexture(this.SheetMenuBitmapTextureAtlas); Level_1 = new Sprite( context.getEngine().getCamera().getWidth() / 2 - Level_1_TextureRegion.getWidth() / 2, 100, this.Level_1_TextureRegion) { // chuyen sang chon level @Override public boolean onAreaTouched( final TouchEvent pSceneTouchEvent, final float pTouchAreaLocalX, final float pTouchAreaLocalY) { if (pSceneTouchEvent.getAction() == TouchEvent.ACTION_DOWN) { SceneManager.Menu_id = SceneManager.GAME_PLAY; LevelManager.Level = LevelManager.LEVEL_1_CLASS; SceneManager.load(); SceneManager.setScene(SceneManager.run()); } return true; } }; Level_2 = new Sprite( context.getEngine().getCamera().getWidth() / 2 - Level_1_TextureRegion.getWidth() / 2, 200, this.Level_2_TextureRegion) { // Thoat khoi game @Override public boolean onAreaTouched( final TouchEvent pSceneTouchEvent, final float pTouchAreaLocalX, final float pTouchAreaLocalY) { if (pSceneTouchEvent.getAction() == TouchEvent.ACTION_DOWN) { SceneManager.Menu_id = SceneManager.GAME_PLAY; LevelManager.Level = LevelManager.LEVEL_2_MARKET; SceneManager.load(); SceneManager.setScene(SceneManager.run()); } return true; } }; mScene.attachChild(Level_1); mScene.attachChild(Level_2); mScene.registerTouchArea(Level_1); mScene.registerTouchArea(Level_2); }
public void manualScreen() { SceneManager.getInstance().loadManualScene(m_engine); }
public ItemTableModel getItemTableModel() { return m_SceneManager.getItemModel(); }
public SceneTableModel getSceneTableModel() { return m_SceneManager.getSceneModel(); }
protected void onDestroy() { super.onDestroy(); mThemeDetailed.Release(); SceneManager.getInstance().popupActivity(this); Log.v("ThemeDetailedActivity", "onDestroy"); }