Exemplo n.º 1
0
        public void LoadContent(ContentManager content)
        {
            _entityManager = new EntityManager();

            _map               = FileReadWriter.ReadFromBinary <Map>(MapDirectory);
            _tileset           = content.Load <Texture2D>(_map.TextureMap.TileTexture);
            _textureBackground = content.Load <Texture2D>("sprites/backgrounds/background1");
            _song              = content.Load <Song>("music/AVoid");
            MediaPlayer.Play(_song);
            MediaPlayer.IsRepeating = true;

            KeyboardInput.AddKey(Microsoft.Xna.Framework.Input.Keys.Space);


            int curPlat = 0;

            for (int x = 0; x < _map.Width; x++)
            {
                for (int y = 0; y < _map.Height; y++)
                {
                    if (_map.Tiles[x, y].ID != 8 &&
                        _map.Tiles[x, y].ID != 10 &&
                        _map.Tiles[x, y].ID != 11 &&
                        _map.Tiles[x, y].ID != 12 &&
                        _map.Tiles[x, y].ID != 13 &&
                        _map.Tiles[x, y].ID != 17 &&
                        _map.Tiles[x, y].ID != 18 &&
                        _map.Tiles[x, y].ID != 19)
                    {
                        //content.Load<Texture2D>(@"sprites/objects/warpBall")
                        _entityManager.AddEntity(new EntityPlatform("platform" + curPlat++, null, new Vector2(x * (_map.TextureMap.TileWidth) * 2.0f, y * (_map.TextureMap.TileHeight * 2.0f)) - _position, new Vector2((_map.TextureMap.TileWidth * 2.0f), (_map.TextureMap.TileHeight * 2.0f)), true));
                    }
                }
            }


            //_oldPlayerPos = _entityManager.GetEntity("player").GetComponent<ComponentTransform>().WorldTransform.Translate;

            _entityManager.AddEntity(new EntityProjectile("player",
                                                          content.Load <Texture2D>(@"sprites/player/char1"),
                                                          new Vector2(400.0f, 240.0f),
                                                          new Vector2(32.0f, 64.0f), true));

            _oldPlayerPos = _entityManager.GetEntity("player").GetComponent <ComponentTransform>().WorldTransform.Translate;


            _entityManager.AddEntity(new EntityProjectile("warpBall",
                                                          content.Load <Texture2D>(@"sprites/objects/warpBall"),
                                                          new Vector2(400.0f, 240.0f),
                                                          new Vector2(32.0f, 32.0f), true));
            //_entityManager.GetEntity("warpBall").GetComponent<ComponentTransform>().SetParent(_entityManager.GetEntity("player").GetComponent<ComponentTransform>());
            _entityManager.GetEntity("warpBall").GetComponent <ComponentTransform>().Scale = 0.6f;
            _entityManager.GetEntity("warpBall").GetComponent <ComponentCollision>().SetSize(32.0f * 0.6f, 32.0f * 0.6f);
            _entityManager.GetEntity("warpBall").GetComponent <ComponentPhysics>().DragX = 0.9999f;
        }
Exemplo n.º 2
0
 protected virtual void TrySaveSettings()
 {
     try
     {
         FileReadWriter.WriteTextToFile(this.settingFile, this.sceneIndex.ToString());
     }
     catch
     {
         FileReadWriter.WriteTextToStreamingAssets(this.settingFile, this.sceneIndex.ToString());
     }
 }
 protected void Update()
 {
     if (Input.GetKeyDown(KeyCode.R))
     {
         this.result = FileReadWriter.ReadFile(this.filePath).content;
     }
     if (Input.GetKeyDown(KeyCode.W))
     {
         this.result = FileReadWriter.WriteFile(this.filePath, this.fileContent).content;
     }
 }
Exemplo n.º 4
0
 private void SaveMap()
 {
     using (Forms.SaveFileDialog fd = new Forms.SaveFileDialog())
     {
         fd.Title  = "Save a Map...";
         fd.Filter = FILE_TYPE_FILTER;
         if (fd.ShowDialog() == Forms.DialogResult.OK)
         {
             string file = fd.FileName;
             FileReadWriter.WriteToBinary(CurrentMap, file);
         }
     }
 }
Exemplo n.º 5
0
        public void MainController_WriteSaveData()
        {
            MainController mc = new MainController();

            Assert.IsTrue(mc.InitialiseGameFromSave(), "Save game should be succesfully initialized");
            GameState workingGS = mc.GetGameState();

            PCModel        workingPCM = workingGS.GetPCM();
            LocationModel  workingLM  = workingGS.GetLM();
            EventModel     workingEM  = workingGS.GetEM();
            DiscoveryModel workingDM  = workingGS.GetDM();

            Assert.IsTrue(mc.WriteSaveData(), "Save Data should be sucessfully written");

            FileReadWriter frw           = new FileReadWriter();
            String         pc            = frw.ReadSaveDataFile(FileReadWriter.PLAYER_CHARACTER);
            String         inventory     = frw.ReadSaveDataFile(FileReadWriter.INVENTORY);
            String         usedEvents    = frw.ReadSaveDataFile(FileReadWriter.USED_EVENTS);
            String         currentEvent  = frw.ReadSaveDataFile(FileReadWriter.CURRENT_EVENT);
            String         discovered    = frw.ReadSaveDataFile(FileReadWriter.DISCOVERED);
            String         visitedLocs   = frw.ReadSaveDataFile(FileReadWriter.VISITED);
            String         unvisitedLocs = frw.ReadSaveDataFile(FileReadWriter.UNVISISTED);
            String         currLoc       = frw.ReadSaveDataFile(FileReadWriter.CURRENT_LOCATION);
            String         currSLoc      = frw.ReadSaveDataFile(FileReadWriter.CURRENT_SUBLOCATION);

            String workingPC           = workingPCM.GetPC().ParseToString();
            String workingInventory    = workingPCM.GetInventory().ParseToString();
            String workingUsedEvents   = workingEM.ParseUsedEventsToString();
            String workingCurrentEvent = workingEM.ParseCurrentEventToString();
            String workingDiscovered   = workingDM.ParseDiscoveredToString();
            String workingVisited      = workingLM.ParseVisitedToString();
            String workingUnvisited    = workingLM.ParseUnvisitedToString();
            String workingCurrLocation = workingLM.ParseCurrLocationToString();
            String workingCurrSLoc     = workingLM.ParseCurrSubLocToString();

            Assert.AreEqual(workingPC, pc, "Saved PC should match");
            Assert.AreEqual(workingInventory, inventory, "Saved Inventory should match");
            Assert.AreEqual(workingUsedEvents, usedEvents, "Saved Used Events should match");
            Assert.AreEqual(workingCurrentEvent, currentEvent, "Saved Current events should match");
            Assert.AreEqual(workingDiscovered, discovered, "Saved Discovered should match");
            Assert.AreEqual(workingVisited, visitedLocs, "Saved Visited should match");
            Assert.AreEqual(workingUnvisited, unvisitedLocs, "Saved Unvisisted should match");
            Assert.AreEqual(workingCurrLocation, currLoc, "Saved Curr location should match");
            Assert.AreEqual(workingCurrSLoc, currSLoc, "Saved Curr Sublocation should match");
        }
Exemplo n.º 6
0
    protected virtual void Start()
    {
        // NOTE:
        // Ignore SceneLoader scene.

        int sceneCount = SceneManager.sceneCountInBuildSettings;

        this.scenes = new string[sceneCount - 1];

        for (int i = 1; i < sceneCount; i++)
        {
            this.scenes[i - 1] = " " + SceneUtility.GetScenePathByBuildIndex(i);
        }

        string sceneIndex = FileReadWriter.ReadTextFromFile(this.settingFile) ?? "1";

        int.TryParse(sceneIndex, out this.sceneIndex);
    }
Exemplo n.º 7
0
 private void OpenMap()
 {
     using (Forms.OpenFileDialog fd = new Forms.OpenFileDialog())
     {
         fd.Title  = "Open a Map...";
         fd.Filter = FILE_TYPE_FILTER;
         if (fd.ShowDialog() == Forms.DialogResult.OK)
         {
             try
             {
                 string file = fd.FileName;
                 // Map loadedMap = FileReadWriter.ReadFromBinary<Map>(file);
                 CurrentMap = FileReadWriter.ReadFromBinary <TentativeTitle.Maps.Map>(file);
                 DefaultValues();
             }
             catch (Exception ex)
             {
                 Forms.MessageBox.Show("Could not read file: " + ex.Message);
             }
         }
     }
 }
Exemplo n.º 8
0
 public void Setup()
 {
     frw = new FileReadWriter();
 }