Example #1
0
        public GameLayer(World world, HexMexCamera camera, CCColor4B color) : base(color)
        {
            HexMexCamera = camera;
            TouchHandler = new GameTouchHandler(this, HexMexCamera);
            World        = world;
            var hexagonLayer         = new HexagonLayer(World, HexMexCamera);
            var edgeLayer            = new EdgeLayer(World, HexMexCamera);
            var resourcePackageLayer = new ResourcePackageLayer(World, HexMexCamera);
            var structureLayer       = new StructureLayer(World, HexMexCamera);
            var controlLayer         = new ButtonLayer(World, HexMexCamera);
            var statisticLayer       = new StatisticLayer(World);
            var researchButtonLayer  = new ReseachLayer(World);
            var menuLayer            = new MenuLayer(World, HexMexCamera);

            controlLayer.ConstructionRequested        += (buttonLayer, buildButton) => ConstructionMenuRequested(buildButton, menuLayer);
            controlLayer.DisplayStructureRequested    += (buttonLayer, structureButton) => DisplayStructureMenu(structureButton, menuLayer);
            researchButtonLayer.ResearchButtonTouched += rbl => DisplayResearchMenu(menuLayer);

            var layers = new CCLayer[] { hexagonLayer, edgeLayer, resourcePackageLayer, structureLayer, controlLayer, statisticLayer, researchButtonLayer, menuLayer };

            foreach (var layer in layers)
            {
                AddChild(layer);
            }

            TouchLayers = new ReadOnlyCollection <TouchLayer>(layers.OfType <TouchLayer>().Reverse().ToList());

            BuildMenu = new BuildMenu(World.UnlockManager, World.GameSettings.VisualSettings, World.GameSettings.LanguageSettings, world.GameSettings.BuildingDescriptionDatabase);
            BuildMenu.ConstructionRequested += ConstructBuilding;
            StructureMenu = new StructureMenu(World.GameSettings.VisualSettings, World);
            ResearchMenu  = new ResearchMenu(World.GameSettings.BuildingDescriptionDatabase, World.UnlockManager, World.GameSettings.VisualSettings, World.GameSettings.LanguageSettings);

            Schedule();
        }
Example #2
0
        private void ConstructBuilding(BuildMenu buildMenu, BuildingDescription buildingDescription)
        {
            if (World.StructureManager[buildMenu.TargetNode] != null)
            {
                throw new InvalidOperationException("Spot has to be empty");
            }
            var construction = new Construction(buildMenu.TargetNode, buildingDescription, World);

            World.StructureManager.CreateStrucuture(construction);
        }