Changeset 3640


Ignore:
Timestamp:
2012-07-06 10:47:06 (11 years ago)
Author:
dezhidki
Message:

Talletus.

Location:
2012/27/DenisZ/TheDungeonGame/TheDungeonGame
Files:
5 added
7 edited

Legend:

Unmodified
Added
Removed
  • 2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/Item.cs

    r3563 r3640  
    2828       public virtual void onPickup(Player picker) 
    2929       { 
    30            picker.ItemInInventory = this; 
    31            picker.updateGuiImage(); 
     30           //picker.ItemInInventory = this; 
     31           //picker.updateGuiImage(); 
    3232       } 
    3333 
    3434       public ItemEntity createWorldObject() 
    3535       { 
    36            ItemEntity result = new ItemEntity(this); 
     36           ItemEntity result = new ItemEntity(this, itemTexture.Width/4, itemTexture.Height/4); 
    3737           result.Image = itemTexture; 
    3838           result.Tag = "Item"; 
  • 2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/ItemEntity.cs

    r3624 r3640  
    1212       public Item bindedItem; 
    1313 
    14        public ItemEntity(Item item) 
    15            : base(40, 40, Shape.Rectangle) 
     14       public ItemEntity(Item item, double width, double height) 
     15           : base(width, height, Shape.Rectangle) 
    1616       { 
    1717           Tag = "Item"; 
  • 2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/Room.cs

    r3624 r3640  
    6161                entitiesSpawned++; 
    6262            } 
    63             //for (int i = 0; i < entityAmount; i++) 
    64             //{ 
    65             //    EntityBase entity = RoomCreator.getEntity(Entities.entities.Length-1); 
    66             //    if(!addEntityAt(entity, RandomGen.NextInt(bWidth-2)+1, RandomGen.NextInt(bHeight-2)+1)) 
    67  
    68             //} 
     63        } 
     64 
     65        public void spawnRandomItems(int itemAmount) 
     66        { 
     67            int itemsSpawned = 0; 
     68            while (itemsSpawned < itemAmount) 
     69            { 
     70                ItemEntity item = RoomCreator.getItem(RandomGen.NextInt(1)).createWorldObject(); 
     71                if (!addBlock(item, RandomGen.NextInt(bWidth - 2) + 1, RandomGen.NextInt(bHeight - 2) + 1)) 
     72                    continue; 
     73                itemsSpawned++; 
     74            } 
    6975        } 
    7076 
     
    191197        } 
    192198 
    193         public void addBlock(IPhysicsObject obj, int bx, int by) 
    194         { 
    195             if (bx >= bWidth || bx < 0 || by >= bHeight || by < 0 || insideObjects[bx, by] != null) return; 
     199        public bool addBlock(IPhysicsObject obj, int bx, int by) 
     200        { 
     201            if (bx >= bWidth || bx < 0 || by >= bHeight || by < 0 || insideObjects[bx, by] != null) return false; 
    196202            obj.Left = insidePos.X + (bx * blockWidth); 
    197203            obj.Top = insidePos.Y - (by * blockHeight); 
    198204            insideObjects[bx, by] = obj; 
    199         } 
    200  
    201         public void addBlock(IPhysicsObject obj, int bx, int by, Vector offset) 
    202         { 
    203             addBlock(obj, bx, by); 
     205            return true; 
     206        } 
     207 
     208        public bool addBlock(IPhysicsObject obj, int bx, int by, Vector offset) 
     209        { 
    204210            obj.Position += offset; 
     211            return addBlock(obj, bx, by); 
     212             
    205213        } 
    206214 
  • 2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/RoomTemplates.cs

    r3624 r3640  
    77using MathHelper; 
    88using Entity; 
     9using Items; 
    910 
    1011namespace Rooms 
     
    2021        { 
    2122            createLevelDecorations(); 
    22  
    23             
     23            spawnRandomItems(1); 
    2424        } 
    2525    } 
     
    221221            if (id == 0) 
    222222                ent = new EntityFly((TheDungeonGame)TheDungeonGame.Instance, Vector.Zero, new Vector(50, 50), Shape.Circle); 
    223             else if(id == 1) 
     223            else if (id == 1) 
    224224                ent = new EntityZombie((TheDungeonGame)TheDungeonGame.Instance, Vector.Zero, new Vector(60, 60), Shape.Rectangle); 
    225             else if(id == 2) 
     225            else if (id == 2) 
    226226                ent = new EntityDerpFace((TheDungeonGame)TheDungeonGame.Instance, Vector.Zero, new Vector(60, 60), Shape.Circle); 
    227             else if(id == 3) 
     227            else if (id == 3) 
    228228                ent = new EntityDerpFly((TheDungeonGame)TheDungeonGame.Instance, Vector.Zero, new Vector(50, 50), Shape.Circle); 
    229229            //else if(id == 4) 
     
    231231            return ent; 
    232232        } 
     233 
     234        public static Item getItem(int id) 
     235        { 
     236            Item item = null; 
     237            if (id == 0) 
     238                item = new ItemHealth(); 
     239 
     240            return item; 
     241        } 
    233242    } 
    234243} 
  • 2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/TheDungeonGame.cs

    r3633 r3640  
    8787        soundEffects.Add(LoadSoundEffect("sound/bug_hit")); 
    8888        soundEffects.Add(LoadSoundEffect("sound/zombie_hit")); 
     89        soundEffects.Add(LoadSoundEffect("sound/item_pickup")); 
    8990    } 
    9091 
     
    104105        objectTextures.Add(LoadImage("objects/door_opened")); 
    105106        objectTextures.Add(LoadImage("objects/bossdoor")); 
     107        objectTextures.Add(LoadImage("objects/healthcan")); 
     108        objectTextures.Add(LoadImage("objects/ammo_speed")); 
     109        objectTextures.Add(LoadImage("objects/ammo_damage")); 
    106110    } 
    107111 
  • 2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/TheDungeonGame.csproj

    r3596 r3640  
    128128    <Compile Include="Ohjelma.cs" /> 
    129129    <Compile Include="RoomTemplates.cs" /> 
    130     <Compile Include="TestItem.cs" /> 
     130    <Compile Include="ItemTemplates.cs" /> 
    131131    <Compile Include="TheDungeonGame.cs" /> 
    132132    <Compile Include="Properties\AssemblyInfo.cs" /> 
  • 2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGameContent/TheDungeonGameContent.contentproj

    r3628 r3640  
    291291    </Compile> 
    292292  </ItemGroup> 
     293  <ItemGroup> 
     294    <Compile Include="sound\item_pickup.wav"> 
     295      <Name>item_pickup</Name> 
     296      <Importer>WavImporter</Importer> 
     297      <Processor>SoundEffectProcessor</Processor> 
     298    </Compile> 
     299  </ItemGroup> 
     300  <ItemGroup> 
     301    <Compile Include="objects\ammo_damage.png"> 
     302      <Name>ammo_damage</Name> 
     303      <Importer>TextureImporter</Importer> 
     304      <Processor>TextureProcessor</Processor> 
     305    </Compile> 
     306    <Compile Include="objects\ammo_speed.png"> 
     307      <Name>ammo_speed</Name> 
     308      <Importer>TextureImporter</Importer> 
     309      <Processor>TextureProcessor</Processor> 
     310    </Compile> 
     311    <Compile Include="objects\healthcan.png"> 
     312      <Name>healthcan</Name> 
     313      <Importer>TextureImporter</Importer> 
     314      <Processor>TextureProcessor</Processor> 
     315    </Compile> 
     316  </ItemGroup> 
    293317  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    294318  <!--  To modify your build process, add your task inside one of the targets below and uncomment it.  
Note: See TracChangeset for help on using the changeset viewer.