예제 #1
0
 public void dropItem(Game game, ItemStack item)
 {
     if (item.getItem().index != Item.itemEmpty.index)
     {
         Entity e = new EntityItem(game.currentWorld.player.position, item, 40);
         game.currentWorld.EntityAddingList.Add(e);
     }
 }
예제 #2
0
        public bool mineTileNoNearUpdate(int x, int y, ItemPick pick, World.TileDepth tileDepth)
        {
            Tile tile = getTileObject(x, y, tileDepth);
            int  data = getTileDataNoCheck(x, y, tileDepth);

            if (setTile(x, y, Tile.TileAir.index, tileDepth))
            {
                Entity e = new EntityItem(new Vector2((x) * World.tileSizeInPixels, (y) * World.tileSizeInPixels), tile.dropStack(this, pick, Game.rand, x, y, tileDepth));
                tile.mine(this, x, y, data, pick, tileDepth);
                EntityAddingList.Add(e);
                return(true);
            }
            return(false);
        }
예제 #3
0
파일: World.cs 프로젝트: nedearb/Specland
 public bool mineTileNoNearUpdate(int x, int y, ItemPick pick, World.TileDepth tileDepth)
 {
     Tile tile = getTileObject(x, y, tileDepth);
     int data = getTileDataNoCheck(x, y, tileDepth);
     if (setTile(x, y, Tile.TileAir.index, tileDepth)) {
         Entity e = new EntityItem(new Vector2((x) * World.tileSizeInPixels, (y) * World.tileSizeInPixels), tile.dropStack(this, pick, Game.rand, x, y, tileDepth));
         tile.mine(this, x, y, data, pick, tileDepth);
         EntityAddingList.Add(e);
         return true;
     }
     return false;
 }
예제 #4
0
        public override void update(Game game, World world)
        {
            bool gravityOn = true;

            if (pickUpDelay <= 0)
            {
                float     d  = Vector2.Distance(world.player.position, position);
                Rectangle pr = new Rectangle((int)world.player.position.X, (int)world.player.position.Y, (int)world.player.size.X, (int)world.player.size.Y);
                Rectangle r  = new Rectangle((int)position.X, (int)position.Y, (int)size.X, (int)size.Y);

                foreach (Entity e in world.EntityList)
                {
                    if (e is EntityItem)
                    {
                        EntityItem ei = ((EntityItem)e);
                        if (e.uniqueID < uniqueID)
                        {
                            if (ei.stack.getItem().index == stack.getItem().index&& ei.stack.getData() == stack.getData())
                            {
                                if (Vector2.Distance(ei.position, position) < (World.tileSizeInPixels))
                                {
                                    ei.stack.setCount(stack.setCount(stack.getCount() + ei.stack.getCount()));
                                }
                            }
                        }
                    }
                }

                if (pr.Intersects(r))
                {
                    stack = game.inventory.pickUp(stack);
                    if (stack.isEmpty())
                    {
                        if (!playedSoundEffectRecently)
                        {
                            SoundEffectPlayer.playSoundWithRandomPitch(SoundEffectPlayer.SoundPop);
                        }
                    }
                    pickUpDelay = maxPickupDelay;
                }
                else if (d < (6 * World.tileSizeInPixels))
                {
                    position += ((world.player.position - position) / d) * 4;
                    gravityOn = false;
                }
            }

            if (stack.isEmpty())
            {
                remove(game, world);
            }

            if (!collision(world, speed.X, 0))
            {
                position.X += speed.X;
            }
            else
            {
                speed.X = 0;
            }

            if (!collision(world, 0, speed.Y))
            {
                position.Y += speed.Y;
            }
            else
            {
                speed.Y = 0;
            }

            if (collision(world, 0, 1))
            {
            }
            else if (gravityOn)
            {
                speed.Y += gravityAcc;
            }

            pickUpDelay--;
        }
예제 #5
0
 public void dropItem(Game game, ItemStack item)
 {
     if (item.getItem().index != Item.itemEmpty.index) {
         Entity e = new EntityItem(game.currentWorld.player.position, item, 40);
         game.currentWorld.EntityAddingList.Add(e);
     }
 }