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); }
public override void update() { base.update(); if (CollideSystem.collide(Player, this) && CanHit) { Player.DealAttackDamage(2); CanHit = false; } }
private void RemoveOverlappingWater() { var fluidToRemove = Tiles.Fluids.Find(s => CollideSystem.collide(s, this)); if (fluidToRemove != null) { Tiles.RemoveFluid(fluidToRemove); } }
public override void update() { if (OnClick is null) { return; } if (CollideSystem.collide(Mouse.position, 10, position, size) && Mouse.pressed) { OnClick(this); } }
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; } } }
public bool Collide(Block block) => CollideSystem.collide(block.position, block.size + Parameters.blockSizeOffset, position, size);