// CONSTRUCTOR ---------------------------------------------------------------------------------- public GameScene( GameSceneData pData ) { gameTimeLimit = pData.timeLimit; this.AddChild( BackgroundLayer = new Layer() ); this.AddChild( GameplayLayer = new Layer() ); this.AddChild( ForegroundLayer = new Layer() ); this.AddChild( DialogLayer = new Layer() ); Layers = new Layer[] {BackgroundLayer, GameplayLayer, ForegroundLayer, DialogLayer}; Touch.GetData(0).Clear(); InputManager.Instance.Reset(); currentLevel = pData.level; this.Camera.SetViewFromViewport(); _physics = GamePhysics.Instance; Hud = new Crystallography.UI.GameSceneHud(this); if (gameTimeLimit > 0.0f) { Hud.SetGameTimeLimit(gameTimeLimit); } ForegroundLayer.AddChild(Hud); SG = SelectionGroup.Instance; SG.Reset( this ); ForegroundLayer.AddChild(SG.getNode()); #if DEBUG // This is debug routine that will draw the physics bounding box around all physics bodies if(DEBUG_BOUNDINGBOXS) { this.AdHocDraw += () => { foreach (ICrystallonEntity e in _allEntites) { if (e is SpriteTileCrystallonEntity) { // Node n = e.getNode(); // Vector2 halfDimensions = new Vector2((e as SpriteTileCrystallonEntity).Width, (e as SpriteTileCrystallonEntity).Height) /4.0f; // var bl = n.Position - halfDimensions; // var tr = n.Position + halfDimensions; Director.Instance.DrawHelpers.DrawBounds2( e.getBounds() ); } } // foreach (PhysicsBody pb in _physics.SceneBodies) { // if ( pb != null ) { // var bottomLeft = pb.AabbMin; // var topRight = pb.AabbMax; // Director.Instance.DrawHelpers.DrawBounds2Fill ( // new Bounds2(bottomLeft*GamePhysics.PtoM, topRight*GamePhysics.PtoM)); // } // } }; this.AdHocDraw += () => { var s = SelectionGroup.Instance.getNode().Position; var bl = s - (20*Vector2.One); var tr = s + (20*Vector2.One); Director.Instance.DrawHelpers.DrawBounds2Fill( new Bounds2(bl,tr) ); }; this.AdHocDraw += () => { // var s = SelectionGroup.Instance.getPosition() - SelectionGroup.Instance.heading.Normalize() * FMath.Max( 80.0f, FMath.Min(120.0f, (120.0f * SelectionGroup.Instance.velocity/100.0f))); var s = SelectionGroup.Instance.getNode().LocalToWorld( SelectionGroup.UP_LEFT_SELECTION_POINT ); var bl = s - (2*Vector2.One); var tr = bl + (4*Vector2.One); Director.Instance.DrawHelpers.DrawBounds2Fill( new Bounds2(bl,tr) ); }; this.AdHocDraw += () => { var s = SelectionGroup.Instance.getNode().LocalToWorld( SelectionGroup.UP_RIGHT_SELECTION_POINT ); var bl = s - (2*Vector2.One); var tr = bl + (4*Vector2.One); Director.Instance.DrawHelpers.DrawBounds2Fill( new Bounds2(bl,tr) ); }; this.AdHocDraw += () => { var s = SelectionGroup.Instance.getNode().LocalToWorld( SelectionGroup.LEFT_UP_SELECTION_POINT ); var bl = s - (2*Vector2.One); var tr = bl + (4*Vector2.One); Director.Instance.DrawHelpers.DrawBounds2Fill( new Bounds2(bl,tr) ); }; this.AdHocDraw += () => { var s = SelectionGroup.Instance.getNode().LocalToWorld( SelectionGroup.RIGHT_UP_SELECTION_POINT ); var bl = s - (2*Vector2.One); var tr = bl + (4*Vector2.One); Director.Instance.DrawHelpers.DrawBounds2Fill( new Bounds2(bl,tr) ); }; } #endif Scheduler.Instance.ScheduleUpdateForTarget(this,0,false); Pause (false); Sequence sequence = new Sequence(); sequence.Add( new DelayTime(0.1f) ); sequence.Add( new CallFunc( () => ResetToLevel() ) ); this.RunAction(sequence); ForegroundLayer.AddChild( Support.ParticleEffectsManager.Instance ); #if METRICS DataStorage.AddMetric("Level", () => currentLevel, 1); #endif }