示例#1
0
	public void unSubscribeToControllingInteraction(InteractionCallbacks subscriber, Class<? extends InteractionBase> interaction)
	{
		for(InteractionBase i: gameControlInteractions)
		{
			if(i.getClass() == interaction)
			{
				i.unSubscribe(subscriber);
				return;
			}
		}		
	}
示例#2
0
	/**
	 * Unsubscribes the passed element from all the interactions it was subscribed
	 * And also passes the element to the "Remove List"
	 * Objects in the remove list are removed removed next time the cleanRemoveList() method is called.
	 * Normally that is called after the end of each step
	 *   
	 */
	public void postDestroyed(ElementBase element)
	{
		this.toBeRemoved.add(element);
		if(element instanceof InteractionCallbacks)
		{
			for(InteractionBase interaction: interactions)
				interaction.unSubscribe((InteractionCallbacks) element);
			
			for(InteractionBase gameControlInteraction: gameControlInteractions)
				gameControlInteraction.unSubscribe((InteractionCallbacks) element);
		}
	}
示例#3
0
	public void subscribeToControllingInteraction(InteractionCallbacks subscriber, Class<? extends InteractionBase> interaction)
	{
		for(InteractionBase i: gameControlInteractions)
		{
			if(i.getClass() == interaction)
			{
				i.subscribe(subscriber);
//				Helper.println("Subscribed to: " + i.getClass().getName());
				return;
			}
		}		
	}
示例#4
0
	public void step(long stepTime) {
//		Helper.println("\n\nProcessing zSortedElements..." );

		for(int i = 0; i < zSortedElements.size; i++)
		{
			a = zSortedElements.get(i);
			if(a.size == 0)
				continue;
//			Helper.println("A size: " + a.size);
			for(ElementBase element :a){
//				time = System.currentTimeMillis();
				if(renderActive)
					element.render();
//				Helper.println("Element Render Time: " + 
//				(System.currentTimeMillis() - time) 
//				+ " For Element: " + element.getClass().getName());
				
				
				
//				time = System.currentTimeMillis();
				if(this.gameState==GameState.PLAYING)
					element.step(stepTime);
				
//				Helper.println("Element Step Time: " + 
//				(System.currentTimeMillis() - time) 
//				+ " For Element: " + element.getClass().getName());
			}
		}
				
		
//		time = System.currentTimeMillis();
//		GlobalVars.ge.getRenderer().startRendering();
//		t = System.currentTimeMillis();
		for(int i = 0; i < elements.size; i++)
		{
//			time = System.currentTimeMillis();
			element = elements.get(i);
			if(renderActive)
				element.render();
			

//			Helper.println("Element Render Time: " + 
//				(System.currentTimeMillis() - time) 
//				+ " For Element: " + element.getClass().getName());
			
//			time = System.currentTimeMillis();
			if(this.gameState==GameState.PLAYING)
				element.step(stepTime);
			
//			Helper.println("Element Step Time: " + 
//				(System.currentTimeMillis() - time) 
//				+ " For Element: " + element.getClass().getName());
		}
		
		
//		Helper.println("\n\n\nTotal Elements Render-Step Time: " + (System.currentTimeMillis() - t));
		
//		t = System.currentTimeMillis();
//		GlobalVars.ge.getRenderer().stopRendering();
		
//		Helper.println("Stop rendering" + (System.currentTimeMillis() - t));
//		t = System.currentTimeMillis();
		
		if(this.gameState==GameState.PLAYING){
			for(int i = 0; i < interactions.size; i++)
			{
				try {
					interaction = interactions.get(i);
					interaction.checkCondition(stepTime);
					interaction.takeAction();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		
//		Helper.println("Interactions Time: " + (System.currentTimeMillis() - t));
//		t = System.currentTimeMillis();
		
		for(int i = 0; i < gameControlInteractions.size; i++)
		{
			try {
				interaction = gameControlInteractions.get(i);
				interaction.checkCondition(stepTime);
				interaction.takeAction();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		
		if(this.gameState==GameState.PLAYING)
			this.tick(stepTime);
		updateGame();
//		Helper.println("Rest: " + (System.currentTimeMillis() - t));
//		Helper.println("Stage Step Time: " + (System.currentTimeMillis() - time));
	}