protected override void handleWorldInteract(GameTime time, KeyboardState currentKeyboardState, MouseState currentMouseState, KeyboardState prevKeyboardState, MouseState prevMouseState) { if (Game1.keyBindManager.bindings["Use"].isDown()) { TileType selectedBlock = entity.world.getBlock(entity.location); if (selectedBlock != null) { if (!Game1.keyBindManager.bindings["Use"].wasDown() || !entity.world.worldLocToTileLoc(entity.location).Equals(harvestLocation)) { harvestLocation = entity.world.worldLocToTileLoc(entity.location); ticksHarvesting = 0; maxTicksHarvestingTime = selectedBlock.harvestTicks; } if (selectedBlock.tags.Contains(TagReferencer.Harvest)) { if (ticksHarvesting == 0) { SoundManager.getSound(selectedBlock.blockBreakSound).playWithVariance(0, .05f, 0, SoundType.MONSTER); } ticksHarvesting++; if (ticksHarvesting > selectedBlock.harvestTicks) { Console.WriteLine(selectedBlock.Equals(TileTypeReferencer.REACTIVE_BUSH_0) || selectedBlock.Equals(TileTypeReferencer.REACTIVE_BUSH_1)); if (selectedBlock.Equals(TileTypeReferencer.REACTIVE_BUSH_0) || selectedBlock.Equals(TileTypeReferencer.REACTIVE_BUSH_1)) { //entity.world.useBlock(entity.location, entity, entity.inventory.items[entity.inventory.currentItem]); entity.world.placeTile(TileTypeReferencer.AIR, entity.location); ((PlayerTaipir)entity).transformedFrom.hunger += 13; ticksHarvesting = 0; for (int i = 0; i < 7; i++) { entity.world.addEntity(new ParticleTileBreak(entity.location, entity.world, new Vector2(), selectedBlock, 150)); } } else { entity.world.useBlock(entity.location, entity, entity.inventory.items[entity.inventory.currentItem]); ticksHarvesting = 0; } /* * * * */ } } } } else { ticksHarvesting = 0; } }
public override void prePhysicsUpdate(GameTime time) { base.prePhysicsUpdate(time); this.location = startLoc; float distanceFromPlayer = Vector2.Distance(world.player.location, this.location); if (currentSound == null || (currentSound != null && currentSound.IsDisposed)) { currentSound = SoundManager.getSound("teleporter_ambiance").play(SoundType.AMBIENT); } currentSound.Volume = Math.Max(0, Math.Min(1, 1f / distanceFromPlayer * 75)); if (distanceFromPlayer < Game1.instance.graphics.PreferredBackBufferWidth && rand.NextDouble() < .2f) { int xAddative = ((rand.Next(50) - 25) * (rand.Next(50) - 25)); Vector2 particleLoc = location + new Vector2(xAddative, -rand.Next(200) + 50); TileType particleBlock = world.getBlock(particleLoc); if (particleBlock != null && !particleBlock.Equals(TileTypeReferencer.AIR)) { ParticleTileBreak particle = new ParticleTileBreak(particleLoc, world, new Vector2(0, 0), particleBlock, 75); particle.gravityMultiplier = -.000001f; particle.width = 5; particle.height = 5; world.addEntity(particle); } } }
public int GetNumber() { if (type.Equals(TileType.Clear)) { return(number); } return(-1); }
// Equality override. public override bool Equals(object obj) { if (obj == null) { return(false); } // If obj can not be cast to BasicTile. BasicTile tile = obj as BasicTile; if (tile == null) { return(false); } return(Type.Equals(tile.Type)); }
public bool Equals(Tile otherTile) { if (x == otherTile.X && y == otherTile.Y && level == otherTile.level && type.Equals(otherTile.type)) { return(true); } return(false); }
public void DoesEqualsWork() { TileType empty = TileType.EMPTY; (TileType empty2, _) = TileType.GetTileType(0); Assert.AreEqual(empty, empty2); Assert.True(empty.Equals(empty2)); // Explicit test }
public Boolean isGreen(int value, TileType type) { if (type.Equals(TileType.SOU)) { if (value == 2 || value == 3 || value == 4 || value == 6 || value == 8) { return(true); } } else if (type.Equals(TileType.HON)) { if (value == 6) { return(true); } } return(false); }
// Get Tiles by TileType public List <Tiles> GetTiles(TileType tileType) { List <Tiles> result = new List <Tiles>(); foreach (Tiles tiles in this.tiles) { if (tileType.Equals(tiles.GetTileType())) { result.Add(tiles); } } return(result); }
public void ToggleTile(MouseEventArgs e) { if (valid == false) { return; } MouseButtons mouseButton = e.Button; if (mouseButton.Equals(MouseButtons.Left) == true) { switch (type) { case TileType.blank: case TileType.start: this.type = TileType.blocked; this.Image = Program.blockedImage; Program.allStartTiles.Remove(this); break; case TileType.blocked: if (isEdgeTile == false) { break; } this.type = TileType.start; this.Image = Program.startImage; Program.allStartTiles.Add(this); break; } } if (mouseButton.Equals(MouseButtons.Right) == true) { if (type.Equals(TileType.start) == true) { Program.allStartTiles.Remove(this); } this.type = TileType.blank; this.Image = Program.blankImage; } //this.Invalidate(); }
public bool Matches(MatchPiece otherPiece) { return(TileType.Equals(otherPiece.TileType)); }
public override void prePhysicsUpdate(GameTime time) { base.prePhysicsUpdate(time); currentTexSwap--; if (currentTexSwap <= 0) { currentTexIndex = (currentTexIndex + 1) % Game1.texture_entity_owl_stand.Length; standTex = Game1.texture_entity_owl_stand[currentTexIndex]; currentTexSwap = texSwapPoint; } foreach (Entity entity in world.entities) { if (entity is Weapon && !aggro) { if (Vector2.Distance(entity.location, this.location) <= 200) { spook(); } } } float distanceFromPlayer = Vector2.Distance(world.player.location, this.location); if (aggro) { //TODO: allow damaging of other entities if (world.player.getCollisionBox().Intersects(this.getCollisionBox())) { Vector2 throwPlayerAmt = velocity; if (throwPlayerAmt.Length() > 0) { throwPlayerAmt = Vector2.Normalize(velocity); } //ensure that player is thrown a real distance, instead of normalizing 0. world.player.damage(25, this, (throwPlayerAmt + new Vector2(0, -2)) * 20f); } if (state == ATTACKING && (collideBottom || collideLeft || collideRight)) { world.shakeScreen(50, 400); SoundManager.getSound("owl-attack").playWithVariance(0, 1f / distanceFromPlayer * 100, (location - world.player.location).X, SoundType.MONSTER); } if (collideBottom || collideLeft || collideRight /* || !isLocationAir*/) { state = RETREATING; randomAdditionalTime = rand.Next(4000); for (int k = -1; k <= 1; k++) { Vector2 belowLoc = location + new Vector2(k * Chunk.tileDrawWidth, Chunk.tileDrawWidth * 2); TileType belowBlock = world.getBlock(belowLoc); if (belowBlock != null && !belowBlock.Equals(TileTypeReferencer.AIR)) { for (int i = 0; i < 10; i++) { world.addEntity(new ParticleTileBreak(belowLoc, world, new Vector2(Vector2.Normalize(velocity).X * 15, -10), belowBlock, 150)); } world.placeTile(TileTypeReferencer.AIR, belowLoc); SoundManager.getSound(belowBlock.blockBreakSound).playWithVariance(0, .25f, 0, SoundType.MONSTER); } } } else if (Vector2.Distance(this.location, world.player.location) >= 2000 + randomAdditionalTime) { state = ATTACKING; } TileType currentBlock = world.getBlock(location); if (currentBlock != null) { if (!currentBlock.Equals(TileTypeReferencer.AIR)) { this.velocity *= .8f; for (int i = 0; i < 10; i++) { world.addEntity(new ParticleTileBreak(location, world, new Vector2(Vector2.Normalize(velocity).X * 15, -10), currentBlock, 150)); } world.placeTile(TileTypeReferencer.AIR, location); SoundManager.getSound(currentBlock.blockBreakSound).playWithVariance(0, .25f, 0, SoundType.MONSTER); } } if (state == RETREATING) { float direction = 0; if (world.player.location.X < this.location.X) { direction = 1; } else if (world.player.location.X > this.location.X) { direction = -1; } walk(direction); this.impulse += new Vector2(direction, -2) * .3f; } else if (state == ATTACKING) { this.impulse += Vector2.Normalize(world.player.location - location) * .235f; } } else { if (distanceFromPlayer <= 650 * world.player.detectionRadiousModifier) { if (Vector2.Distance(world.player.location, lastPlayerLoc) > 4 && random.NextDouble() < .05f * world.player.detectionLevel) { spook(); } lastPlayerLoc = world.player.location; } } }
private bool TileIsWall(CellMap map, int x, int y) => _wallTile.Equals(map.GetTileType(x, y));
internal bool IsValidPath() { /* indiquant si on peut aller sur une case ou non. Pour cela, il suffit de regarder le type * de la case : seuls les chemins, l’herbe et les ponts sont accessibles.*/ return(tileType.Equals(TileType.Bridge) || tileType.Equals(TileType.Grass) || tileType.Equals(TileType.Path)); }
public override int use(PlayerBase user, WorldBase world, Vector2 location, GameTime time, BinaryInputManager inputManager) { int consumed = 0; if (inputManager.isDown()) { TileType selectedBlock = user.world.getBlock(user.location); if (selectedBlock != null && (selectedBlock.TILEID == TileTypeReferencer.REACTIVE_TRUNK_0.TILEID || selectedBlock.TILEID == TileTypeReferencer.REACTIVE_TRUNK_1.TILEID)) { if (!inputManager.wasDown() || !user.world.worldLocToTileLoc(user.location).Equals(harvestLocation)) { harvestLocation = user.world.worldLocToTileLoc(user.location); ticksHarvesting = 0; maxTicksHarvestingTime = selectedBlock.harvestTicks; } if (ticksHarvesting == 0) { SoundManager.getSound(selectedBlock.blockBreakSound).playWithVariance(0, .05f, 0, SoundType.MONSTER); } ticksHarvesting++; if (ticksHarvesting > selectedBlock.harvestTicks) { //user.world.useBlock(user.location, user, this); ticksHarvesting = 0; consumed = 1; for (int x = -3; x <= 3; x++) { for (int y = -7; y <= 0; y++) { Vector2 potentialTrunkLoc = user.location + new Vector2(x * Chunk.tileDrawWidth, y * Chunk.tileDrawWidth); TileType potentialTrunk = user.world.getBlock(potentialTrunkLoc); if (potentialTrunk != null && (potentialTrunk.Equals(TileTypeReferencer.REACTIVE_TRUNK_0) || potentialTrunk.Equals(TileTypeReferencer.REACTIVE_TRUNK_1))) { world.useBlock(potentialTrunkLoc, user, this); } } } } /*else * { * world.useBlock(user.location, user, this); * }*/ } else { if (!inputManager.wasDown()) { base.use(user, world, location, time, inputManager); if (user is Player) { Player player = (Player)user; if (player.state.actionPermitted(STATE_ACTIONS.THROW)) { Entities.Projectiles.EntityAxe axe = new Entities.Projectiles.EntityAxe(user.location + new Vector2(0, -15), world, user); axe.velocity += Vector2.Normalize(location - user.location) * 15; world.addEntity(axe); SoundManager.getSound("spear-throw").playWithVariance(0, .2f, 0, SoundType.MONSTER); consumed = 1; player.state.decorate(axe); player.state.submitStateAction(STATE_ACTIONS.THROW); } } else { Entities.Projectiles.EntityAxe axe = new Entities.Projectiles.EntityAxe(user.location + new Vector2(0, -15), world, user); axe.velocity += Vector2.Normalize(location - user.location) * 15; world.addEntity(axe); SoundManager.getSound("spear-throw").playWithVariance(0, .2f, 0, SoundType.MONSTER); consumed = 1; } /*Entities.Projectiles.EntityAxe axe = new Entities.Projectiles.EntityAxe(user.location + new Vector2(0, -15), world, user); * axe.velocity += Vector2.Normalize(location - user.location) * 15; * world.addEntity(axe); * * SoundManager.getSound("spear-throw").playWithVariance(0, .2f, 0, SoundType.MONSTER); * consumed = 1;*/ } } } else { ticksHarvesting = 0; } return(consumed); }
// METHODES /// <summary> /// Indicates if it is a valid path (only for Bridge, Grass and Path tile types) /// </summary> /// <returns>Indicates if it is a valid path</returns> public bool IsValidPath() { return(tileType.Equals(TileType.BRIDGE) || tileType.Equals(TileType.GRASS) || tileType.Equals(TileType.PATH)); }
public bool Matches(System.Type otherType) { return(TileType.Equals(otherType)); }
internal bool IsValidPath() { return(tileType.Equals(TileType.Bridge) || tileType.Equals(TileType.Grass) || tileType.Equals(TileType.Path)); }
public override void update(GameTime time) { timeUntilNextPlacement--; if (timeUntilNextPlacement <= 0) { TileType tileOn = world.getBlock(trunkLoc); if (tileOn != null) { if (remainingTrunkTiles > 0) { if (tileOn.tags.Contains(TagReferencer.AIR) && !tileOn.tags.Contains(TagReferencer.Teleporter)) { SoundManager.getSound(world.decorator.treeManager.trunk.blockBreakSound).playWithVariance(0, 1f / Vector2.Distance(trunkLoc, world.playerLoc) * 75, (location - world.player.location).X, SoundType.AMBIENT); remainingTrunkTiles--; world.placeTile(world.decorator.treeManager.trunk, trunkLoc); trunkLoc += new Vector2(0, -Chunk.tileDrawWidth); } else { world.killEntity(this); } } else if (remainingTrunkTiles == 0) { if (tileOn.tags.Contains(TagReferencer.AIR) && !tileOn.tags.Contains(TagReferencer.Teleporter)) { SoundManager.getSound(world.decorator.treeManager.trunk.blockBreakSound).playWithVariance(0, 1f / Vector2.Distance(trunkLoc, world.playerLoc) * 75, (location - world.player.location).X, SoundType.AMBIENT); remainingTrunkTiles--; world.placeTile(world.decorator.treeManager.treeTop, trunkLoc); } else { world.killEntity(this); } } else { if (currentLeafRadious < maxLeafRadious) { SoundManager.getSound(world.decorator.treeManager.leaves.blockBreakSound).playWithVariance(0, 1f / Vector2.Distance(trunkLoc, world.playerLoc) * 75, (location - world.player.location).X, SoundType.AMBIENT); currentLeafRadious++; TileType consideredTile = world.getBlock(location); for (int x = -currentLeafRadious; x <= currentLeafRadious; x++) { for (int y = -currentLeafRadious; y <= currentLeafRadious; y++) { Vector2 candidateLoc = trunkLoc + new Vector2(x * Chunk.tileDrawWidth, y * Chunk.tileDrawWidth); consideredTile = world.getBlock(candidateLoc); if (consideredTile != null && consideredTile.tags.Contains(TagReferencer.AIR) && !consideredTile.tags.Contains(TagReferencer.Teleporter) && !consideredTile.Equals(world.decorator.treeManager.treeTop) && !consideredTile.Equals(world.decorator.treeManager.trunk)) { world.placeTile(world.decorator.treeManager.leaves, candidateLoc); world.addEntity(new ParticleTileBreak(candidateLoc, world, new Vector2(), world.decorator.treeManager.leaves, 100)); } } } } else { world.killEntity(this); } } } timeUntilNextPlacement = MaxTimeUntilNextPlacement; } else { if (remainingTrunkTiles >= 0) { world.addEntity(new ParticleTileBreak(trunkLoc, world, new Vector2(), world.decorator.treeManager.trunk, 100)); } } }