public void LoadAndInitializeLevel()
        {
            XElement levelData = LoadLevelData();

            if (Data.Profile.PlayingRaceMode)
            {
                RaceLapCount = GetLapsForRace(levelData);
            }
            else
            {
                XElement rankFractionElement = levelData.Element(Rank_Fraction_Data_Element);
                RankACandyFraction = GetCandyFractionForRanking(rankFractionElement, "a", Rank_A_Candy_Fraction);
                RankBCandyFraction = GetCandyFractionForRanking(rankFractionElement, "b", Rank_B_Candy_Fraction);
            }

            WireUpCallElementFactoryCallbacks();

            Map = BlockFactory.CreateLevelBlockMap(levelData.Element(Terrain_Data_Element).Element(BlockFactory.Data_Group_Node_Name));

            CollectableFactory.LoadCollectables(levelData.Element(Terrain_Data_Element).Element(CollectableFactory.Data_Group_Node_Name));
            SignpostFactory.LoadSignposts(levelData.Element(Terrain_Data_Element).Element(SignpostFactory.Data_Group_Node_Name));
            FlagFactory.LoadFlags(levelData.Element(Terrain_Data_Element).Element(FlagFactory.Data_Group_Node_Name));

            Player = CharacterFactory.LoadPlayer(levelData.Element(CharacterFactory.Player_Data_Node_Name));

            FinalizeLevelSetup(levelData);
        }
Beispiel #2
0
        public bool Load()
        {
            if ((RegisterComponent != null) && (UnregisterComponent != null))
            {
                FlushCurrentComponents();

                try
                {
                    XDocument loadData = XDocument.Load("BopscotchLevel.xml");
                    AttemptToLoadPlayerData(loadData.Element("leveldata"));
                    AttemptToLoadRaceData(loadData.Element("leveldata"));

                    BackgroundTexture = loadData.Element("leveldata").Element("background").Attribute("texture").Value;

                    BlockFactory.LoadBlocks(loadData.Element("leveldata").Element("terrain").Element(BlockFactory.Data_Group_Node_Name), RegisterComponent);
                    CollectableFactory.LoadCollectables(loadData.Element("leveldata").Element("terrain").Element(CollectableFactory.Data_Group_Node_Name), RegisterComponent);
                    SignpostFactory.LoadSignposts(loadData.Element("leveldata").Element("terrain").Element(SignpostFactory.Data_Group_Node_Name), RegisterComponent);
                    FlagFactory.LoadFlags(loadData.Element("leveldata").Element("terrain").Element(FlagFactory.Data_Group_Node_Name), RegisterComponent);

                    return(true);
                }
                catch (Exception)
                {
                }
            }

            return(false);
        }
Beispiel #3
0
        public void ReinstateDynamicObjects(XElement serializedData)
        {
            WireUpCallElementFactoryCallbacks();

            BlockFactory.ReinstateSerializedBlocks(GetSerializedFactoryData(serializedData, BlockFactory.Serialized_Data_Identifier));
            CollectableFactory.ReinstateSerializedCollectables(GetSerializedFactoryData(serializedData, CollectableFactory.Serialized_Data_Identifier));
            FlagFactory.ReinstateSerializedFlags(GetSerializedFactoryData(serializedData, FlagFactory.Serialized_Data_Identifier));
            SignpostFactory.ReinstateSerializedSignposts(GetSerializedFactoryData(serializedData, SignpostFactory.Signpost_Serialized_Data_Identifier));
            SignpostFactory.ReinstateSerializedRouteMarkers(GetSerializedFactoryData(serializedData, SignpostFactory.Route_Marker_Serialized_Data_Identifier));

            _registerGameObject(new Background());

            Player = CharacterFactory.ReinstatePlayer();
        }
        public void ReinstateDynamicObjects(XElement serializedData)
        {
            WireUpCallElementFactoryCallbacks();

            XElement levelData = LoadLevelData();

            Map = BlockFactory.ReinstateLevelBlockMap(levelData.Element(Terrain_Data_Element).Element(BlockFactory.Data_Group_Node_Name));

            CollectableFactory.ReinstateSerializedCollectables(GetSerializedFactoryData(serializedData, CollectableFactory.Serialized_Data_Identifier));
            FlagFactory.ReinstateSerializedFlags(GetSerializedFactoryData(serializedData, FlagFactory.Serialized_Data_Identifier));
            SignpostFactory.ReinstateSerializedSignposts(GetSerializedFactoryData(serializedData, SignpostFactory.Signpost_Serialized_Data_Identifier));
            SignpostFactory.ReinstateSerializedRouteMarkers(GetSerializedFactoryData(serializedData, SignpostFactory.Route_Marker_Serialized_Data_Identifier));

            Player = CharacterFactory.ReinstatePlayer();

            FinalizeLevelSetup(levelData);
        }
Beispiel #5
0
        public void LoadAndInitializeLevel()
        {
            XElement levelData = LoadLevelData();

            RaceLapCount = (Data.Profile.PlayingRaceMode ? GetLapsForRace(levelData) : 0);

            WireUpCallElementFactoryCallbacks();

            Map = BlockFactory.LoadBlocks(levelData.Element(Terrain_Data_Element).Element(BlockFactory.Data_Group_Node_Name));
            Map.ViewportDimensionsInTiles = new Point(
                (BackgroundDimensions.X / Definitions.Grid_Cell_Pixel_Size) + 1, BackgroundDimensions.Y / Definitions.Grid_Cell_Pixel_Size);

            CollectableFactory.LoadCollectables(levelData.Element(Terrain_Data_Element).Element(CollectableFactory.Data_Group_Node_Name));
            SignpostFactory.LoadSignposts(levelData.Element(Terrain_Data_Element).Element(SignpostFactory.Data_Group_Node_Name));
            FlagFactory.LoadFlags(levelData.Element(Terrain_Data_Element).Element(FlagFactory.Data_Group_Node_Name));

            Player     = CharacterFactory.LoadPlayer(levelData.Element(CharacterFactory.Player_Data_Node_Name));
            Player.Map = Map;

            CreateBackground(levelData.Element(Background_Data_Element));

            _registerGameObject(Map);
        }
Beispiel #6
0
        private void CompleteMouseAction()
        {
            if (_activeModalBox != null)
            {
                CheckAndHandleModalAction();
            }
            else if (_controlPanel.Contains(_inputHandler.MousePosition))
            {
                CheckAndHandleCommandChange();
            }
            else if (_selected == null)
            {
                switch (_controlPanel.ActiveOption)
                {
                case "Player":
                    _player.WorldPosition = SnapToGrid(_inputHandler.MousePosition + _cameraController.WorldPosition - new Vector2(Definitions.CellSizeInPixels / 2.0f));
                    _player.Visible       = true;
                    break;

                case "Blocks":
                    if (ModalBoxSelectionCanBePlaced("block-selector"))
                    {
                        AddTerrainObject(BlockFactory.CreateBlockFromTextureName(SelectorValue("block-selector")), _inputHandler.MousePosition);
                    }
                    break;

                case "Candies":
                    if (ModalBoxSelectionCanBePlaced("candy-selector"))
                    {
                        AddTerrainObject(CollectableFactory.CreateCandyFromTextureName(SelectorValue("candy-selector")), _inputHandler.MousePosition);
                    }
                    break;

                case "Signs":
                    if (ModalBoxSelectionCanBePlaced("sign-selector"))
                    {
                        AddTerrainObject(SignpostFactory.CreateSignpostFromTextureName(SelectorValue("sign-selector")), _inputHandler.MousePosition);
                    }
                    break;

                case "Flags":
                    if (ModalBoxSelectionCanBePlaced("flag-selector"))
                    {
                        AddTerrainObject(FlagFactory.CreateFlagFromTextureName(SelectorValue("flag-selector")), _inputHandler.MousePosition);
                    }
                    break;

                case "Enemies":
                    if (EnemySelectionCanBePlaced())
                    {
                        AddEnemy(EnemyFactory.CreateEnemyFromTextureName(SelectorValue("enemy-selector")), _inputHandler.MousePosition);
                    }
                    break;

                case "Route":
                    if (ModalBoxSelectionCanBePlaced("route-selector"))
                    {
                        AddTerrainObject(SignpostFactory.CreateRouteMarkerFromTextureName(SelectorValue("route-selector")), _inputHandler.MousePosition);
                    }
                    break;
                }
            }
            else if (_selected is ObjectBase)
            {
                if (!SnapDraggedObjectToGrid())
                {
                    _selected.ReturningToPreviousLocation = true; _selected.Selected = false; _selected = null;
                }
            }
        }