public void Start(Server server) { foreach (var tile in server.Map.GetTiles()) { FloorChange floorChange = tile.FloorChange; if (floorChange == FloorChange.None) { foreach (var item in tile.GetItems()) { if (useable.Contains(item.Metadata.OpenTibiaId)) { positions.Add(tile.Position, floorChange); } break; } } else { positions.Add(tile.Position, floorChange); } } server.Scripts.CreatureWalkScripts.Add(this); server.Scripts.ItemMoveScripts.Add(this); }
/// <inheritdoc /> public async Task <FloorChange> AddFloorChangeAsync(int accountId, double?cashFlow, FloorChangeReason changeReason) { return(await Task.Run(() => { Debug.WriteLine($"CppiFloorService.AddFloorChange({accountId}, {cashFlow}, {changeReason})"); // Thread.Sleep(100); var item = new FloorChange { CppiFloorHistoryId = 888, AccountCppiConfigId = 999, CashFlow = cashFlow, ChangeReason = changeReason, ChangeDateTime = DateTime.Now, CppiFloor = 777 }; var list = Dictionary[accountId].ToList(); list.Add(item); Dictionary[accountId] = list.ToArray(); return item; })); }
private void RaiseFloorChange(int previousFloor, int currentFloor) { //Console.WriteLine($"Floor is Changing from {previousFloor} to {currentFloor} and Floor change {(FloorChange == null ? "is" : "is not")} null"); FloorChange?.Invoke(this, new FloorChangeEventArgs(previousFloor, currentFloor)); }
private Position GetPosition(Position toPosition, FloorChange floorChange) { switch (floorChange) { case FloorChange.Down: toPosition = toPosition.Offset(0, 0, 1); if (positions.TryGetValue(toPosition, out floorChange)) { switch (floorChange) { case FloorChange.East: toPosition = toPosition.Offset(-1, 0, 0); break; case FloorChange.North: toPosition = toPosition.Offset(0, 1, 0); break; case FloorChange.West: toPosition = toPosition.Offset(1, 0, 0); break; case FloorChange.South: toPosition = toPosition.Offset(0, -1, 0); break; case FloorChange.NorthEast: toPosition = toPosition.Offset(-1, 1, 0); break; case FloorChange.NorthWest: toPosition = toPosition.Offset(1, 1, 0); break; case FloorChange.SouthEast: toPosition = toPosition.Offset(-1, -1, 0); break; case FloorChange.SouthWest: toPosition = toPosition.Offset(1, -1, 0); break; } } break; case FloorChange.East: toPosition = toPosition.Offset(1, 0, -1); break; case FloorChange.North: toPosition = toPosition.Offset(0, -1, -1); break; case FloorChange.West: toPosition = toPosition.Offset(-1, 0, -1); break; case FloorChange.South: toPosition = toPosition.Offset(0, 1, -1); break; case FloorChange.NorthEast: toPosition = toPosition.Offset(1, -1, -1); break; case FloorChange.NorthWest: toPosition = toPosition.Offset(-1, -1, -1); break; case FloorChange.SouthEast: toPosition = toPosition.Offset(1, 1, -1); break; case FloorChange.SouthWest: toPosition = toPosition.Offset(-1, 1, -1); break; } return(toPosition); }