Esempio n. 1
0
    public void Apply(List <DFCoord> coordList)
    {
        DigCommand         command = new DigCommand();
        TileDigDesignation designation;

        if (!GetDesignation(out designation))
        {
            return;
        }
        command.designation = designation;
        foreach (var item in coordList)
        {
            MapDataStore.Tile tile = MapDataStore.Main[item];
            if (tile == null)
            {
                continue;
            }
            if (DesignationApplies(tile))
            {
                command.locations.Add(item);
            }
        }
        if (command.locations.Count > 0)
        {
            DFConnection.Instance.EnqueueDigCommand(command);
        }
    }
Esempio n. 2
0
        public async Task Dig()
        {
            var result = await DoCommand(async() => {
                var playerId = _account.PlayerId;

                var command = new DigCommand(playerId);
                await _bus.SendCommand(command);
            });
        }
Esempio n. 3
0
        public async Task <Unit> Handle(DigCommand command, CancellationToken cancellationToken)
        {
            await BeginChangeStatus(new PlayerStatusModel
            {
                PlayerId = command.PlayerId,
                Status   = PlayerStatusEnum.挖矿
            });

            return(Unit.Value);
        }
Esempio n. 4
0
 /// <summary>
 /// Enqueue's a digging designation command to send to DF
 /// </summary>
 /// <param name="command"></param>
 public void EnqueueDigCommand(DigCommand command)
 {
     if (digCommandCall == null)
     {
         return; //don't bother.
     }
     if (netDigCommands.Count < netDigCommands.Capacity)
     {
         netDigCommands.Enqueue(command);
     }
 }
Esempio n. 5
0
        // Checks which key the user pressed
        private static ICommand GetCommandFromKey(ConsoleKeyInfo consoleKeyInfo)
        {
            Command command = null;

            switch (consoleKeyInfo.Key)
            {
            case ConsoleKey.W:
            case ConsoleKey.UpArrow:
                command = new MoveUpCommand();
                break;

            case ConsoleKey.S:
            case ConsoleKey.DownArrow:
                command = new MoveDownCommand();
                break;

            case ConsoleKey.D:
            case ConsoleKey.RightArrow:
                command = new MoveRightCommand();
                break;

            case ConsoleKey.A:
            case ConsoleKey.LeftArrow:
                command = new MoveLeftCommand();
                break;

            case ConsoleKey.E:
                System.Console.WriteLine($"\nYou dig down");
                command = new DigCommand();
                break;

            case ConsoleKey.F:
                Console.WriteLine($"\nYou place a block below you");
                command = new PlaceCommand();
                break;

            default:
                Console.WriteLine("Unknown key");
                break;
            }
            return(command);
        }
Esempio n. 6
0
        private ICommand GetRandomCommand(Worm currentActiveWorm)
        {
            ICommand command;
            var      random = new Random();

            var validCells = GetValidAdjacentCells(currentActiveWorm);

            if (!validCells.Any())
            {
                return(new DoNothingCommand());
            }

            var randomCell         = validCells[random.Next(0, validCells.Length)];
            var randomCellPosition = new MapPosition()
            {
                X = randomCell.X, Y = randomCell.Y
            };

            switch (randomCell.Type)
            {
            case CellType.AIR:
                command = new MoveCommand()
                {
                    MapPosition = randomCellPosition
                };
                break;

            case CellType.DIRT:
                command = new DigCommand()
                {
                    MapPosition = randomCellPosition
                };
                break;

            default:
                command = new DoNothingCommand();
                break;
            }

            return(command);
        }