Example #1
0
 public Object.Object addObject(Object.Object _Object, Boolean _InsertInQuadTree, Region.Region _Region)
 {
     if (_InsertInQuadTree)
     {
         this.quadTreeObject.Insert(_Object);
     }
     if (_Region != null)
     {
         Chunk.Chunk chunk = _Region.getChunkAtPosition(_Object.Position);
         if (chunk != null)
         {
             Block.Block var_Block = chunk.getBlockAtCoordinate(_Object.Position);
             if (var_Block != null)
             {
                 var_Block.addObject(_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);
 }
        public override void onDecorateChunk(Chunk _Chunk)
        {
            base.onDecorateChunk(_Chunk);
            int var_Count = this.getCount();

            for (int i = 0; i < var_Count; i++)
            {
                ItemObject var_itemObject = ItemFactory.itemFactory.createItemObject(this.itemEnum);

                int var_X = Utility.Random.Random.GenerateGoodRandomNumber(1, (int)_Chunk.Size.X * (Block.Block.BlockSize) - 1);
                int var_Y = Utility.Random.Random.GenerateGoodRandomNumber(1, (int)_Chunk.Size.Y * (Block.Block.BlockSize) - 1);

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

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

                if (var_Block != null)
                {
                    if (var_Block.IsWalkAble && var_Block.Layer[1] == BlockEnum.Nothing)
                    {
                        if (_Chunk.Parent != null)
                        {
                            if (_Chunk.Parent != null)
                            {
                                //((Region.Region)_Chunk.Parent).getParent().addObject(var_itemObject, true, (Region.Region)_Chunk.Parent);
                            }
                            var_Block.addObject(var_itemObject);
                        }
                    }
                }
            }
        }
        public override void onDecorateChunk(Chunk _Chunk)
        {
            base.onDecorateChunk(_Chunk);
            int var_Count = this.getCount();

            for (int i = 0; i < var_Count; i++)
            {
                EquipmentObject var_EquipmentObject = null;

                if (this.equipmentType == ItemEnum.Weapon)
                {
                    var_EquipmentObject = EquipmentFactory.equipmentFactory.createEquipmentWeaponObject(WeaponEnum.Sword);
                }
                else if (this.equipmentType == ItemEnum.Armor)
                {
                    var_EquipmentObject = EquipmentFactory.equipmentFactory.createEquipmentArmorObject(ArmorEnum.GoldenArmor);
                }

                if (var_EquipmentObject != null)
                {
                    int var_X = Utility.Random.Random.GenerateGoodRandomNumber(1, (int)_Chunk.Size.X * (Block.Block.BlockSize) - 1);
                    int var_Y = Utility.Random.Random.GenerateGoodRandomNumber(1, (int)_Chunk.Size.Y * (Block.Block.BlockSize) - 1);

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

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

                    if (var_Block != null)
                    {
                        if (var_Block.IsWalkAble && var_Block.Layer[1] == BlockEnum.Nothing)
                        {
                            if (_Chunk.Parent != null)
                            {
                                //((Region.Region)_Chunk.Parent).getParent().addObject(var_EquipmentObject, true, (Region.Region)_Chunk.Parent);
                            }
                            var_Block.addObject(var_EquipmentObject);
                        }
                    }
                }
            }
        }