Esempio n. 1
0
        public Chunk createChunkInRegion(Region _Region, int _PosX, int _PosY)
        {
            Chunk var_Chunk = null;
            switch (_Region.RegionEnum)
            {
                case RegionEnum.Grassland:
                    {
                        var_Chunk = ChunkFactory.chunkFactory.createChunk((int)(_PosX), (int)(_PosY), ChunkEnum.Grassland, RegionDependency.regionDependency.getLayer(_Region.RegionEnum), _Region);
                        break;
                    }
                case RegionEnum.Snowland:
                    {
                        var_Chunk = ChunkFactory.chunkFactory.createChunk((int)(_PosX), (int)(_PosY), ChunkEnum.Snowland, RegionDependency.regionDependency.getLayer(_Region.RegionEnum), _Region);
                        break;
                    }
                case RegionEnum.Lavaland:
                    {
                        var_Chunk = ChunkFactory.chunkFactory.createChunk((int)(_PosX), (int)(_PosY), ChunkEnum.Lavaland, RegionDependency.regionDependency.getLayer(_Region.RegionEnum), _Region);
                        break;
                    }
            }

            if (var_Chunk != null)
            {
                this.addChunkToRegion(_Region, _PosX, _PosY, var_Chunk);

                ChunkFactory.chunkFactory.generateChunk(var_Chunk);
            }

            return var_Chunk;
        }
Esempio n. 2
0
 private void addChunkToRegion(Region _Region, int _PosX, int _PosY, Chunk _ChunkToAdd)
 {
     if (_Region.setChunkAtPosition(new Vector3(_PosX, _PosY, 0), _ChunkToAdd))
     {
     }
     else
     {
         Logger.Logger.LogErr("RegionFactory->addChunkToRegion(...) : Chunk kann der Region " + _Region.Name + " nicht hinzufügt werden!");
     }
 }
Esempio n. 3
0
        public void generateFarms(Region _Region, int _MaxCount, int _MinDistance)
        {
            int var_StartPositionX = (int)_Region.Position.X;
            int var_StartPositionY = (int)_Region.Position.Y;

            int var_EndPositionX = var_StartPositionX + (int)_Region.Size.X * Chunk.chunkSizeX * Block.BlockSize;
            int var_EndPositionY = var_StartPositionY + (int)_Region.Size.Y * Chunk.chunkSizeY * Block.BlockSize;

            int var_Count = Utility.Random.GenerateGoodRandomNumber(0, _MaxCount);
            var_Count = _MaxCount;
            for (int i = 0; i < var_Count; i++)
            {
                EnvironmentObject var_EnvironmentObject = EnvironmentFactory.environmentFactory.createEnvironmentObject(_Region.RegionEnum, FactoryEnums.EnvironmentEnum.FarmHouse1);
                var_EnvironmentObject.Position = new Microsoft.Xna.Framework.Vector3(500, 500, 0);
                //var_EnvironmentObject.CollisionBounds.Add(new Microsoft.Xna.Framework.Rectangle(var_EnvironmentObject.DrawBounds.Left + 40, var_EnvironmentObject.DrawBounds.Bottom - 105, 280, 65));
                ((Model.Map.World.World)_Region.Parent).addObject(var_EnvironmentObject,true, _Region); // Region wird erst world zugewiesen. dannach könne erst objetek hin :(
            }
        }
Esempio n. 4
0
 public Chunk createChunk(int _PosX, int _PosY, ChunkEnum _ChunkEnum, List<Enum> _Layer, Region _ParentRegion)
 {
     switch (_ChunkEnum)
     {
         case ChunkEnum.Grassland:
             {
                 return createChunkGrassland(_PosX, _PosY, _Layer, _ParentRegion);
             }
         case ChunkEnum.Snowland:
             {
                 return createChunkSnowland(_PosX, _PosY, _Layer, _ParentRegion);
             }
         case ChunkEnum.Lavaland:
             {
                 return createChunkLavaland(_PosX, _PosY, _Layer, _ParentRegion);
             }
     }
     return null;
 }
Esempio n. 5
0
        private Chunk createChunkGrassland(int _PosX, int _PosY, List<Enum> _Layer, Region _ParentRegion)
        {
            Chunk var_Result;

            var_Result = new Chunk("Chunk", _PosX, _PosY, _ParentRegion);
            var_Result.ChunkEnum = ChunkEnum.Grassland;
            this.fillChunkWithBlock(var_Result, BlockEnum.Ground1);

            var_Result.setAllNeighboursOfBlocks();

            if (Configuration.Configuration.isHost)
            {
                //generateWall(var_Result, Utility.Random.GenerateGoodRandomNumber(0, Chunk.chunkSizeX), Utility.Random.GenerateGoodRandomNumber(0, Chunk.chunkSizeY));
                //generateSecondLayer(var_Result, _Layer);
            }
            else
            {
                //generateFlowers(var_Result);
            }

            return var_Result;
        }
Esempio n. 6
0
        public bool addRegion(Region.Region _Region)
        {
            if (!containsRegion(_Region.Id))
            {
                this.regions.Add(_Region);

                if (GameLibrary.Configuration.Configuration.isHost)
                {
                    //this.saveRegion(_Region);
                }
                else
                {

                }

                return false;
            }
            else
            {
                Logger.Logger.LogErr("World->addRegion(...) : Region mit Id: " + _Region.Id + " schon vorhanden!");
                return false;
            }
        }
Esempio n. 7
0
 public Object.Object addObject(Object.Object _Object, Boolean insertInQuadTree, Region.Region _Region)
 {
     if (_Region != null)
     {
         Chunk.Chunk chunk = _Region.getChunkObjectIsIn(_Object);
         if (chunk != null)
         {
             if(this.getObject(_Object.Id)==null)
             {
                 Block.Block var_Block = chunk.getBlockAtCoordinate(_Object.Position);
                 if (var_Block != null)
                 {
                     var_Block.addObject(_Object);
                     if (insertInQuadTree)
                     {
                         this.quadTreeObject.Insert(_Object);
                     }
                     if (Configuration.Configuration.isHost)
                     {
                         Configuration.Configuration.networkManager.addEvent(new GameLibrary.Connection.Message.UpdateObjectMessage(_Object), GameMessageImportance.VeryImportant);
                     }
                 }
             }
         }
     }
     else
     {
         Logger.Logger.LogInfo("World.addObject: Object konnte der Region nicht hinzugefügt werden, da diese null war");
     }
     return _Object;
 }
Esempio n. 8
0
        private Region generateRegionGrassland(String _Name, int _PosX, int _PosY, World _ParentWorld)
        {
            Region var_Result;

            var_Result = new Region(_Name, _PosX, _PosY, RegionEnum.Grassland, _ParentWorld);

            //FarmFactory.farmFactory.generateFarms(var_Result, 1, 0);

            Logger.Logger.LogInfo("Region " + var_Result.Name + " wurde erstellt!");

            return var_Result;
        }
Esempio n. 9
0
        private Region generateRegionSnowland(String _Name, int _PosX, int _PosY, World _ParentWorld)
        {
            Region var_Result;

            var_Result = new Region(_Name, _PosX, _PosY, RegionEnum.Snowland, _ParentWorld);

            Logger.Logger.LogInfo("Region " + var_Result.Name + " wurde erstellt!");

            return var_Result;
        }
Esempio n. 10
0
 public bool containsRegion(Region.Region _Region)
 {
     return containsRegion(_Region.Id);
 }
Esempio n. 11
0
 public void saveRegion(Region.Region _Region)
 {
     String var_Path = "Save/" + _Region.Position.X + "_" + _Region.Position.Y + "/RegionInfo.sav";
     Utility.IO.IOManager.SaveISerializeAbleObjectToFile(var_Path, _Region);
 }