Example #1
0
        private void PlaceBlock()
        {
            var blockType = status.GetItem();

            if (blockType is null)
            {
                return;
            }
            if (!blockType.IsPlaceable)
            {
                return;
            }

            foreach (var b in Tiles.VisiableBlocks)
            {
                if (CollideSystem.collide(b, this))
                {
                    return;
                }
            }
            Tiles.PlaceBlock(position.x, position.y, blockType.Type);
            status.Decrement(blockType.Type, 1);
            RemoveOverlappingWater();
            Sound.PlaySound(SoundType.Place);
        }
Example #2
0
 public override void update()
 {
     base.update();
     if (CollideSystem.collide(Player, this) && CanHit)
     {
         Player.DealAttackDamage(2);
         CanHit = false;
     }
 }
Example #3
0
        private void RemoveOverlappingWater()
        {
            var fluidToRemove = Tiles.Fluids.Find(s => CollideSystem.collide(s, this));

            if (fluidToRemove != null)
            {
                Tiles.RemoveFluid(fluidToRemove);
            }
        }
Example #4
0
 public override void update()
 {
     if (OnClick is null)
     {
         return;
     }
     if (CollideSystem.collide(Mouse.position, 10, position, size) && Mouse.pressed)
     {
         OnClick(this);
     }
 }
Example #5
0
        private void DestroyBlock()
        {
            var blockType = status.GetItem();

            if (blockType.TooltType == ToolType.Sword)
            {
                DamageMonster(blockType);
            }
            if (BreakingTicks > 0)
            {
                if (blockToBreak.tool == blockType.TooltType)
                {
                    BreakingTicks += blockType.Power;
                }
                else
                {
                    BreakingTicks += 1;
                }

                if (BreakingTicks >= blockToBreak.Durablity)
                {
                    CheckMinPower(blockType);
                    Tiles.RemoveTile(blockToBreak);
                    Sound.PlaySound(SoundType.Break);
                    DamageTool(blockType);
                    BreakingTicks = 0;
                    return;
                }
            }
            foreach (var b in Tiles.VisiableBlocks)
            {
                if (CollideSystem.collide(b, this))
                {
                    blockToBreak = b;
                    BreakingTicks++;
                    break;
                }
            }
        }
Example #6
0
 public bool Collide(Block block) => CollideSystem.collide(block.position, block.size + Parameters.blockSizeOffset, position, size);