public virtual object CanMove(Board board, int x, int y, SolidityCheck check) { if (x < 0 || y < 0 || x >= this.ParentBoard.Width || y >= this.ParentBoard.Height) { return(false); } foreach (var entity in board.Entities) { if (entity == this) { continue; } if (entity.XPosition == x && entity.YPosition == y) { if (entity is Door && ((Door)entity).Closed) { return(entity as Door); } if (entity.Blocking) { return(entity); } } } if (board.IsSolid(y, x, check)) { return(false); } return(null); }
public virtual object CanMove(Direction targetDirection, SolidityCheck check) { var newX = this.XPosition; var newY = this.YPosition; Toolkit.PredictLocation(newX, newY, targetDirection, ref newX, ref newY); return(CanMove(this.ParentBoard, newX, newY, check)); }
public override object CanMove(Direction targetDirection, SolidityCheck check = SolidityCheck.Walker) { var newX = this.XPosition; var newY = this.YPosition; Toolkit.PredictLocation(newX, newY, targetDirection, ref newX, ref newY); if (newX < 0 || newY < 0 || newX >= this.ParentBoard.Width || newY >= this.ParentBoard.Height) { return(false); } return(null); }
public override void Move(Direction targetDirection, SolidityCheck check = SolidityCheck.Walker) { //this.ParentBoard.DirtySpots.Add(new Point(XPosition, YPosition)); //this.ParentBoard.Draw(true); if (CanMove(targetDirection, check) != null) { return; } var newX = 0; var newY = 0; Toolkit.PredictLocation(XPosition, YPosition, targetDirection, ref newX, ref newY); XPosition = newX; YPosition = newY; Point(); }
public virtual void Move(Direction targetDirection, SolidityCheck check) { var touched = this.CanMove(targetDirection, check); if (touched is Door) { var door = touched as Door; if (door.Locked) { return; } if (door.Closed) { if (this is Player) { NoxicoGame.Sound.PlaySound("set://DoorOpen"); } Energy -= 500; door.Closed = false; } } else if (touched != null) { return; } if (XPosition >= 0 && YPosition >= 0 && XPosition < this.ParentBoard.Width && YPosition < this.ParentBoard.Height) { this.ParentBoard.DirtySpots.Add(new Point(XPosition, YPosition)); } var newX = 0; var newY = 0; Toolkit.PredictLocation(XPosition, YPosition, targetDirection, ref newX, ref newY); XPosition = newX; YPosition = newY; }
public override void Move(Direction targetDirection, SolidityCheck check = SolidityCheck.Walker) { Console.WriteLine("Trying to move dropped item."); }
public override void Move(Direction targetDirection, SolidityCheck check = SolidityCheck.Walker) { var lx = XPosition; var ly = YPosition; check = SolidityCheck.Walker; if (Character.IsSlime) { check = SolidityCheck.DryWalker; } if (Character.HasToken("flying")) { check = SolidityCheck.Flyer; } #region Inter-board travel var n = NoxicoGame.Me; Board otherBoard = null; if (ly == 0 && targetDirection == Direction.North && this.ParentBoard.ToNorth > -1) { otherBoard = n.GetBoard(this.ParentBoard.ToNorth); if (this.CanMove(otherBoard, lx, otherBoard.Height - 1, check) != null) { return; } this.YPosition = otherBoard.Height; OpenBoard(this.ParentBoard.ToNorth); } else if (ly == ParentBoard.Height - 1 && targetDirection == Direction.South && this.ParentBoard.ToSouth > -1) { otherBoard = n.GetBoard(this.ParentBoard.ToSouth); if (this.CanMove(otherBoard, lx, 0, check) != null) { return; } this.YPosition = -1; OpenBoard(this.ParentBoard.ToSouth); } else if (lx == 0 && targetDirection == Direction.West && this.ParentBoard.ToWest > -1) { otherBoard = n.GetBoard(this.ParentBoard.ToWest); if (this.CanMove(otherBoard, otherBoard.Width - 1, ly, check) != null) { return; } this.XPosition = otherBoard.Width; OpenBoard(this.ParentBoard.ToWest); } else if (lx == ParentBoard.Width - 1 && targetDirection == Direction.East && this.ParentBoard.ToEast > -1) { otherBoard = n.GetBoard(this.ParentBoard.ToEast); if (this.CanMove(otherBoard, 0, ly, check) != null) { return; } this.XPosition = -1; OpenBoard(this.ParentBoard.ToEast); } #endregion if (Character.HasToken("tutorial")) { Character.GetToken("tutorial").Value++; } var newX = this.XPosition; var newY = this.YPosition; Toolkit.PredictLocation(newX, newY, targetDirection, ref newX, ref newY); foreach (var entity in ParentBoard.Entities.Where(x => x.XPosition == newX && x.YPosition == newY)) { if (entity.Blocking) { NoxicoGame.ClearKeys(); if (entity is BoardChar) { var bc = (BoardChar)entity; if (bc.Character.HasToken("hostile") || (bc.Character.HasToken("teambehavior") && bc.Character.DecideTeamBehavior(Character, TeamBehaviorClass.Attacking) != TeamBehaviorAction.Nothing)) { //Strike at your foes! AutoTravelling = false; MeleeAttack(bc); EndTurn(); return; } if (!bc.OnPlayerBump.IsBlank()) { bc.RunScript(bc.OnPlayerBump); return; } //Displace! NoxicoGame.AddMessage(i18n.Format("youdisplacex", bc.Character.GetKnownName(false, false, true)), bc.GetEffectiveColor()); bc.XPosition = this.XPosition; bc.YPosition = this.YPosition; } } } base.Move(targetDirection, check); ParentBoard.AimCamera(XPosition, YPosition); EndTurn(); if (Character.HasToken("squishy") || (Character.Path("skin/type") != null && Character.Path("skin/type").Text == "slime")) { NoxicoGame.Sound.PlaySound("set://Squish"); } else { NoxicoGame.Sound.PlaySound("set://Step"); } if (lx != XPosition || ly != YPosition) { ParentBoard.UpdateLightmap(this, true); this.DijkstraMap.Hotspots[0] = new Point(XPosition, YPosition); this.DijkstraMap.Update(); } else if (AutoTravelling) { AutoTravelling = false; #if DEBUG NoxicoGame.AddMessage("* TEST: couldn't go any further. *"); #endif } NoxicoGame.ContextMessage = null; if (OnWarp()) { NoxicoGame.ContextMessage = i18n.GetString("context_warp"); } else if (ParentBoard.Entities.OfType <DroppedItem>().FirstOrDefault(c => c.XPosition == XPosition && c.YPosition == YPosition) != null) { NoxicoGame.ContextMessage = i18n.GetString("context_droppeditem"); } else if (ParentBoard.Entities.OfType <Container>().FirstOrDefault(c => c.XPosition == XPosition && c.YPosition == YPosition) != null) { if (ParentBoard.Entities.OfType <Container>().FirstOrDefault(c => c.XPosition == XPosition && c.YPosition == YPosition).Token.HasToken("corpse")) { NoxicoGame.ContextMessage = i18n.GetString("context_corpse"); } else { NoxicoGame.ContextMessage = i18n.GetString("context_container"); } } //else if (ParentBoard.Entities.OfType<Clutter>().FirstOrDefault(c => c.XPosition == XPosition && c.YPosition == YPosition && c.Glyph == 0x147) != null) else if (ParentBoard.Entities.OfType <Clutter>().FirstOrDefault(c => c.XPosition == XPosition && c.YPosition == YPosition && c.DBRole == "bed") != null) { NoxicoGame.ContextMessage = i18n.GetString("context_bed"); } if (NoxicoGame.ContextMessage != null) { NoxicoGame.ContextMessage = Toolkit.TranslateKey(KeyBinding.Activate, false, false) + " - " + NoxicoGame.ContextMessage; } }