void DoPatrolling() { //close door if neccessary if (World.TryCloseDoor(CoordX - lookX, CoordY - lookY)) { return; } //let's SUDDENLY turn to the random direction, maybe? :D if (MyRandom.getRandomInt(suddenTurningFrequency) == 0) { turnToRandomPassableDirection(); return; } //Move forward if there is nothing to do... if (TryMoveForward()) { return; } else //or open door if there is. Otherwise turn to random direction { if (!World.TryOpenDoor(CoordX + lookX, CoordY + lookY)) { turnToRandomPassableDirection(); } } }
public void MoveOrOpenOrAttack(int x, int y) //-1 or 0 or 1 for x and y { if (World.IsDoorPresent(CoordX + x, CoordY + y)) { if (World.TryUnlockDoor(CoordX + x, CoordY + y, Inv.GetAllKeys)) { Timing.AddActionTime(TimeCost.OpenDoorCost(this)); Log.AddLine("You have unlocked the door with your key."); return; } if (World.TryOpenDoor(CoordX + x, CoordY + y)) { Timing.AddActionTime(TimeCost.OpenDoorCost(this)); Log.AddLine("You opened the door."); return; } } if (World.IsPassable(CoordX + x, CoordY + y)) { CoordX += x; CoordY += y; Timing.AddActionTime(TimeCost.MoveCost(this)); if (World.isItemPresent(CoordX, CoordY)) { List <Item> list = World.getItemListAt(CoordX, CoordY); int numberOfItemsOnFloor = list.Count(); if (numberOfItemsOnFloor > 1) { Log.AddLine("You see here: " + list[0].DisplayName + " and " + (numberOfItemsOnFloor - 1).ToString() + " more items"); } else { Log.AddLine("You see here: " + list[0].DisplayName); } } return; } if (World.isActorPresent(CoordX + x, CoordY + y)) { Actor attacked = World.getActorAt(CoordX + x, CoordY + y); Attack.MeleeAttack(this, attacked); } else if (!World.IsPassable(CoordX + x, CoordY + y)) { Log.AddLine("Locked! You need a key."); } //World.Redraw(CoordX-x, CoordY-y); }