//--------------------------------------------------------------------------------------------------------------
        public static LHScene createWithContentOfFile(string plistLevelFile, CCWindow mainWindow, CCApplication application)
        {
            PlistDictionary dict = CCContentManager.SharedContentManager.Load <PlistDocument> (plistLevelFile).Root.AsDictionary;

            if (null == dict)
            {
                Debug.WriteLine("\nERROR: Could not load level file %s. The file does not appear to exist.\n", plistLevelFile);
                return(null);
            }

            var aspect = dict ["aspect"].AsInt;

            if (aspect == 0)           //exact fit
            {
                CCSize winSize = CCSize.Parse(dict ["designResolution"].AsString);
                CCScene.SetDefaultDesignResolution(winSize.Width, winSize.Height, CCSceneResolutionPolicy.ExactFit);
            }
            else if (aspect == 1)           //no borders
            {
                CCSize winSize = CCSize.Parse(dict ["designResolution"].AsString);
                CCScene.SetDefaultDesignResolution(winSize.Width, winSize.Height, CCSceneResolutionPolicy.NoBorder);
            }
            else if (aspect == 2)           //show all
            {
                CCSize winSize = mainWindow.WindowSizeInPixels;
                CCScene.SetDefaultDesignResolution(winSize.Width, winSize.Height, CCSceneResolutionPolicy.ShowAll);
            }

            PlistArray devsInfo = dict["devices"].AsArray;

            if (null == devsInfo)
            {
                Debug.WriteLine("\nERROR: Level doesn't contain valid devices.\n");
                return(null);
            }

            foreach (PlistDictionary devInf in devsInfo)
            {
                string suffix = dict ["suffix"].AsString;
                application.ContentSearchPaths.Add(suffix);
            }

            application.ContentSearchPaths.Add("hd");
            application.ContentSearchPaths.Add("568");

            return(new LHScene(dict, plistLevelFile, mainWindow));
        }
 public LHDevice(PlistDictionary dict)
 {
     size   = CCSize.Parse(dict["size"].AsString);
     suffix = dict ["suffix"].AsString;
     ratio  = dict["ratio"].AsFloat;
 }
        //--------------------------------------------------------------------------------------------------------------
        //--------------------------------------------------------------------------------------------------------------
        public LHScene(PlistDictionary dict, string plistLevelFile, CCWindow mainWindow) : base(mainWindow)
        {
            _designResolutionSize = CCSize.Parse(dict ["designResolution"].AsString);

            foreach (PlistDictionary devInf in dict["devices"].AsArray)
            {
                devices.Add(new LHDevice(devInf));
            }
            currentDev = LHDevice.currentDeviceFromArray(devices, this);
            CCSize sceneSize = currentDev.getSize();
            float  ratio     = currentDev.getRatio();

            sceneSize.Width  = sceneSize.Width / ratio;
            sceneSize.Height = sceneSize.Height / ratio;

            var aspect = dict ["aspect"].AsInt;

            if (aspect == 0)           //exact fit
            {
                sceneSize = _designResolutionSize;
            }
            else if (aspect == 1)           //no borders
            {
            }
            else if (aspect == 2)           //show all
            {
                _designOffset.X = (sceneSize.Width - _designResolutionSize.Width) * 0.5f;
                _designOffset.Y = (sceneSize.Height - _designResolutionSize.Height) * 0.5f;
            }


            //loadingInProgress = true;
            Debug.WriteLine("plistLevelFile:|" + plistLevelFile + "|");

            this.relativePath = LHUtils.folderFromPath(plistLevelFile);
//			this.relativePath = Path.GetDirectoryName (plistLevelFile);

            Debug.WriteLine("SCENE REL |" + this.relativePath + "|");
//			Console.WriteLine ("SCENE REL |" + this.relativePath + "|");

            if (this.relativePath == null)
            {
                this.relativePath = "";
            }

//			loadingInProgress = true;

//			[[CCDirector sharedDirector] setContentScaleFactor:ratio];
//			#if __CC_PLATFORM_IOS
//			[[CCFileUtils sharedFileUtils] setiPhoneContentScaleFactor:curDev.ratio];
//			#endif

//			[self setName:relativePath];

            _nodeProtocolImp.loadGenericInfoFromDictionary(dict, this);

//			self.contentSize= CGSizeMake(curDev.size.width/curDev.ratio, curDev.size.height/curDev.ratio);
//			self.position   = CGPointZero;

            PlistDictionary tracedFixInfo = dict["tracedFixtures"].AsDictionary;

            if (tracedFixInfo != null)
            {
                tracedFixtures = new PlistDictionary();
                foreach (var pair in tracedFixInfo)
                {
                    string     fixUUID = pair.Key;
                    PlistArray fixInfo = pair.Value.AsArray;
                    if (null != fixInfo)
                    {
                        tracedFixtures.Add(fixUUID, fixInfo);
                    }
                }
            }

//			supportedDevices = [[NSArray alloc] initWithArray:devices];

//			[self loadBackgroundColorFromDictionary:dict];
//			[self loadGameWorldInfoFromDictionary:dict];



            LHNodeProtocolImp.loadChildrenForNode(this, dict);

//			[self loadGlobalGravityFromDictionary:dict];
//			[self loadPhysicsBoundariesFromDictionary:dict];

//			[self setUserInteractionEnabled:YES];

//			#if __CC_PLATFORM_IOS
//			pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinch:)];
//			[[[CCDirector sharedDirector] view] addGestureRecognizer:pinchRecognizer];
//			#endif



//			#if LH_USE_BOX2D
//			_box2dCollision = [[LHBox2dCollisionHandling alloc] initWithScene:self];
//			#else//cocos2d

//			#endif
//			[self performLateLoading];

//			loadingInProgress = false;

            Debug.WriteLine("SCENE has children count " + this.ChildrenCount);
        }
        public void loadGenericInfoFromDictionary(PlistDictionary dict, CCNode nd)
        {
            b2WorldDirty = false;
            _node        = nd;

            if (null != dict)
            {
                name = dict ["name"].AsString;
                uuid = dict ["uuid"].AsString;

                //tags loading
//				{
//					NSArray* loadedTags = [dict objectForKey:@"tags"];
//					if(loadedTags){
//						_tags = [[NSMutableArray alloc] initWithArray:loadedTags];
//					}
//				}

                //user properties loading
//				{
//					NSDictionary* userPropInfo  = [dict objectForKey:@"userPropertyInfo"];
//					NSString* userPropClassName = [dict objectForKey:@"userPropertyName"];
//					if(userPropInfo && userPropClassName)
//					{
//						Class userPropClass = NSClassFromString(userPropClassName);
//						if(userPropClass){
//							#pragma clang diagnostic push
//							#pragma clang diagnostic ignored "-Wundeclared-selector"
//							_userProperty = [userPropClass performSelector:@selector(customClassInstanceWithNode:)
//								withObject:_node];
//							#pragma clang diagnostic pop
//							if(_userProperty){
//								[_userProperty setPropertiesFromDictionary:userPropInfo];
//							}
//						}
//					}
//				}

                if (dict.ContainsKey("alpha"))
                {
                    _node.Opacity = (byte)dict ["alpha"].AsFloat;
                }

                if (dict.ContainsKey("rotation"))
                {
                    _node.Rotation = -dict ["rotation"].AsFloat;
                }

                if (dict.ContainsKey("zOrder"))
                {
                    _node.ZOrder = dict ["zOrder"].AsInt;
                }

                if (dict.ContainsKey("scale"))
                {
                    CCPoint scl = CCPoint.Parse(dict ["scale"].AsString);
                    _node.ScaleX = scl.X;
                    _node.ScaleY = scl.Y;
                }

                //for sprites the content size is set from the CCSpriteFrame
                if (dict.ContainsKey("size") && _node.GetType() != typeof(LHSprite))
                {
                    _node.ContentSize = CCSize.Parse(dict ["size"].AsString);
                }

                if (dict.ContainsKey("generalPosition")
                    &&
                    _node.GetType() != typeof(LHUINode)
                    &&
                    _node.GetType() != typeof(LHBackUINode)
                    &&
                    _node.GetType() != typeof(LHGameWorldNode))
                {
                    CCPoint unitPos = CCPoint.Parse(dict ["generalPosition"].AsString);
                    CCPoint pos     = LHUtils.positionForNode(_node, unitPos);

                    _node.Position = pos;
                }
//				if([dict objectForKey:@"generalPosition"]&&
//					![_node isKindOfClass:[LHUINode class]] &&
//					![_node isKindOfClass:[LHBackUINode class]] &&
//					![_node isKindOfClass:[LHGameWorldNode class]])
//				{
//
//					CGPoint unitPos = [dict pointForKey:@"generalPosition"];
//					CGPoint pos = [LHUtils positionForNode:_node
//						fromUnit:unitPos];
//
//					NSDictionary* devPositions = [dict objectForKey:@"devicePositions"];
//					if(devPositions)
//					{
//
//						NSString* unitPosStr = [LHUtils devicePosition:devPositions
//							forSize:LH_SCREEN_RESOLUTION];
//
//						if(unitPosStr){
//							CGPoint unitPos = LHPointFromString(unitPosStr);
//							pos = [LHUtils positionForNode:_node
//								fromUnit:unitPos];
//						}
//					}
//
//					[_node setPosition:pos];
//				}

//				if([dict objectForKey:@"anchor"] &&
//					![_node isKindOfClass:[LHUINode class]] &&
//					![_node isKindOfClass:[LHBackUINode class]] &&
//					![_node isKindOfClass:[LHGameWorldNode class]])
//				{
//					CGPoint anchor = [dict pointForKey:@"anchor"];
//					anchor.y = 1.0f - anchor.y;
//					[_node setAnchorPoint:anchor];
//				}
            }
        }