Example #1
0
        private void generateTrees(Chunk _Chunk)
        {
            int var_Count = Chunk.chunkSizeX * Chunk.chunkSizeY / 8 / Utility.Random.GenerateGoodRandomNumber(1, 5);
            for (int i = 0; i < var_Count; i++)
            {
                GameLibrary.Model.Object.EnvironmentObject var_EnvironmentObject = EnvironmentFactory.environmentFactory.createEnvironmentObject(((Region)_Chunk.Parent).RegionEnum, EnvironmentEnum.Tree_Normal_1);

                int var_X = Utility.Random.GenerateGoodRandomNumber(1, GameLibrary.Model.Map.Chunk.Chunk.chunkSizeX * (GameLibrary.Model.Map.Block.Block.BlockSize) - 1);
                int var_Y = Utility.Random.GenerateGoodRandomNumber(1, GameLibrary.Model.Map.Chunk.Chunk.chunkSizeY * (GameLibrary.Model.Map.Block.Block.BlockSize) - 1);

                var_EnvironmentObject.Position = new Vector3(var_X + _Chunk.Position.X, var_Y + _Chunk.Position.Y, 0);

                Block var_Block = _Chunk.getBlockAtCoordinate(var_EnvironmentObject.Position);

                if (var_Block.IsWalkAble)
                {
                    var_Block.Objects.Add(var_EnvironmentObject);
                    var_EnvironmentObject.CurrentBlock = var_Block;
                    ((Model.Map.World.World)_Chunk.Parent.Parent).QuadTreeObject.Insert(var_EnvironmentObject);

                    //TODO: Das stimmt natürlich nicht ganz ;) aber erst mal für den AStar...
                    //var_Block.IsWalkAble = false;
                }
            }
        }
Example #2
0
        private void generateStuff(Chunk _Chunk)
        {
            int var_Count = 0;//Chunk.chunkSizeX * Chunk.chunkSizeY / 8 / Utility.Random.GenerateGoodRandomNumber(1, 5);
            for (int i = 0; i < var_Count; i++)
            {
                //GameLibrary.Model.Object.ItemObject var_itemObject = EquipmentFactory.equipmentFactory.createEquipmentWeaponObject(WeaponEnum.Sword);
                GameLibrary.Model.Object.ItemObject var_itemObject = EquipmentFactory.equipmentFactory.createEquipmentArmorObject(ArmorEnum.GoldenArmor);

                int var_X = Utility.Random.GenerateGoodRandomNumber(1, GameLibrary.Model.Map.Chunk.Chunk.chunkSizeX * (GameLibrary.Model.Map.Block.Block.BlockSize) - 1);
                int var_Y = Utility.Random.GenerateGoodRandomNumber(1, GameLibrary.Model.Map.Chunk.Chunk.chunkSizeY * (GameLibrary.Model.Map.Block.Block.BlockSize) - 1);

                var_itemObject.Position = new Vector3(var_X + _Chunk.Position.X, var_Y + _Chunk.Position.Y, 0);

                Block var_Block = _Chunk.getBlockAtCoordinate(var_itemObject.Position);
                if (var_Block.IsWalkAble)
                {
                    var_Block.Objects.Add(var_itemObject);
                    ((Model.Map.World.World)_Chunk.Parent.Parent).QuadTreeObject.Insert(var_itemObject);
                }
            }
        }
Example #3
0
        private void generatePaths(Chunk _Chunk)
        {
            List<Vector3> var_PossiblePathEntries = new List<Vector3>();
            if (_Chunk.LeftNeighbour != null)
            {
                foreach (Vector3 var_Entry in ((Chunk)_Chunk.LeftNeighbour).PathEntries)
                {
                    if (var_Entry.X >= _Chunk.Position.X - (Block.BlockSize + 5))
                    {
                        var_PossiblePathEntries.Add(var_Entry + new Vector3(Block.BlockSize,0,0));
                    }
                }
            }
            if (_Chunk.RightNeighbour != null)
            {
                foreach (Vector3 var_Entry in ((Chunk)_Chunk.RightNeighbour).PathEntries)
                {
                    if (var_Entry.X <= _Chunk.Bounds.Right + (Block.BlockSize + 5))
                    {
                        var_PossiblePathEntries.Add(var_Entry + new Vector3(-Block.BlockSize, 0, 0));
                    }
                }
            }
            if (_Chunk.TopNeighbour != null)
            {
                foreach (Vector3 var_Entry in ((Chunk)_Chunk.TopNeighbour).PathEntries)
                {
                    if (var_Entry.Y >= _Chunk.Position.Y - (Block.BlockSize + 5))
                    {
                        var_PossiblePathEntries.Add(var_Entry + new Vector3(0, Block.BlockSize, 0));
                    }
                }
            }
            if (_Chunk.BottomNeighbour != null)
            {
                foreach (Vector3 var_Entry in ((Chunk)_Chunk.BottomNeighbour).PathEntries)
                {
                    if (var_Entry.Y <= _Chunk.Bounds.Bottom + (Block.BlockSize + 5))
                    {
                        var_PossiblePathEntries.Add(var_Entry + new Vector3(0, -Block.BlockSize, 0));
                    }
                }
            }

            if(var_PossiblePathEntries.Count == 0)
            {
                var_PossiblePathEntries.Add(_Chunk.Position);
            }

            foreach (Vector3 var_Entry in var_PossiblePathEntries)
            {
                Block var_BlockEntry =_Chunk.getBlockAtCoordinate(var_Entry);
                if (var_BlockEntry != null)
                {
                    var_BlockEntry.setLayerAt(BlockEnum.Ground1, BlockLayerEnum.Layer2);
                    _Chunk.PathEntries.Add(var_Entry);
                }

                Block var_BlockExit = _Chunk.getBlockAtCoordinate(var_Entry + new Vector3(0, (Chunk.chunkSizeY - 1) * Block.BlockSize, 0));
                if (var_BlockExit != null)
                {
                    var_BlockExit.setLayerAt(BlockEnum.Ground1, BlockLayerEnum.Layer2);
                    _Chunk.PathEntries.Add(var_BlockExit.Position);
                }
                this.generatePathFromTwoPoints(_Chunk, var_BlockEntry, var_BlockExit);
            }
        }
Example #4
0
        private void generateNpc(Chunk _Chunk)
        {
            int var_Count = (Chunk.chunkSizeX * Chunk.chunkSizeY / 5 / Utility.Random.GenerateGoodRandomNumber(1, 5)) / 2;
            for (int i = 0; i < var_Count; i++)
            {
                GameLibrary.Model.Object.NpcObject var_NpcObject = CreatureFactory.creatureFactory.createNpcObject(RaceEnum.Human, FactionEnum.Beerdrinker, CreatureEnum.Archer, GenderEnum.Male);

                int var_X = Utility.Random.GenerateGoodRandomNumber(1, GameLibrary.Model.Map.Chunk.Chunk.chunkSizeX * (GameLibrary.Model.Map.Block.Block.BlockSize) - 1);
                int var_Y = Utility.Random.GenerateGoodRandomNumber(1, GameLibrary.Model.Map.Chunk.Chunk.chunkSizeY * (GameLibrary.Model.Map.Block.Block.BlockSize) - 1);

                var_NpcObject.Position = new Vector3(var_X + _Chunk.Position.X, var_Y + _Chunk.Position.Y, 0);

                Block var_Block = _Chunk.getBlockAtCoordinate(var_NpcObject.Position);
                if (var_Block.IsWalkAble && var_Block.Layer[1] == BlockEnum.Nothing)
                {
                    var_Block.Objects.Add(var_NpcObject);
                    var_NpcObject.CurrentBlock = var_Block;
                    ((Model.Map.World.World)_Chunk.Parent.Parent).QuadTreeObject.Insert(var_NpcObject);
                }
            }
        }
Example #5
0
        private void generateFlowers(Chunk _Chunk)
        {
            int var_Count = Chunk.chunkSizeX * Chunk.chunkSizeY / Utility.Random.GenerateGoodRandomNumber(1,5);
            for (int i = 0; i < var_Count; i++)
            {
                GameLibrary.Model.Object.EnvironmentObject var_EnvironmentObject = EnvironmentFactory.environmentFactory.createEnvironmentObject(((Region)_Chunk.Parent).RegionEnum,  EnvironmentEnum.Flower_1);

                int var_X = Utility.Random.GenerateGoodRandomNumber(1, GameLibrary.Model.Map.Chunk.Chunk.chunkSizeX * (GameLibrary.Model.Map.Block.Block.BlockSize) - 1);
                int var_Y = Utility.Random.GenerateGoodRandomNumber(1, GameLibrary.Model.Map.Chunk.Chunk.chunkSizeY * (GameLibrary.Model.Map.Block.Block.BlockSize) - 1);

                var_EnvironmentObject.Position = new Vector3(var_X + _Chunk.Position.X, var_Y + _Chunk.Position.Y, 0);

                Block var_Block = _Chunk.getBlockAtCoordinate(var_EnvironmentObject.Position);

                if (var_Block.IsWalkAble && var_Block.Layer[1] == BlockEnum.Nothing)
                {
                    var_Block.ObjectsPreEnviorment.Add(var_EnvironmentObject);
                    var_EnvironmentObject.CurrentBlock = var_Block;
                    //((Model.Map.World.World)_Chunk.Parent.Parent).QuadTreeEnvironmentObject.Insert(var_EnvironmentObject);
                    //Chunk ist noch null ;) in der world.... da noch nicht hinzugefügt
                    //((Model.Map.World.World)_Chunk.Parent.Parent).addPreEnvironmentObject(var_EnvironmentObject);
                }
            }
        }
Example #6
0
        private void generateCoins(Chunk _Chunk)
        {
            int var_Count = 0;//Chunk.chunkSizeX * Chunk.chunkSizeY / 8 / Utility.Random.GenerateGoodRandomNumber(1, 5);
            for (int i = 0; i < var_Count; i++)
            {
                GameLibrary.Model.Object.ItemObject var_itemObject = ItemFactory.itemFactory.createItemObject(ItemEnum.GoldCoin);

                int var_X = Utility.Random.GenerateGoodRandomNumber(1, GameLibrary.Model.Map.Chunk.Chunk.chunkSizeX * (GameLibrary.Model.Map.Block.Block.BlockSize) - 1);
                int var_Y = Utility.Random.GenerateGoodRandomNumber(1, GameLibrary.Model.Map.Chunk.Chunk.chunkSizeY * (GameLibrary.Model.Map.Block.Block.BlockSize) - 1);

                var_itemObject.Position = new Vector3(var_X + _Chunk.Position.X, var_Y + _Chunk.Position.Y, 0);

                Block var_Block = _Chunk.getBlockAtCoordinate(var_itemObject.Position);
                if (var_Block.IsWalkAble)
                {
                    var_Block.Objects.Add(var_itemObject);
                    ((Model.Map.World.World)_Chunk.Parent.Parent).QuadTreeObject.Insert(var_itemObject);
                }
            }
        }