Example #1
0
        private void SendCommand(TankCommand tankCommand)
        {
            switch (tankCommand)
            {
            case TankCommand.COMMAND_UP:
            {
                _connector.Write('w');
                break;
            }

            case TankCommand.COMMAND_LEFT:
            {
                _connector.Write('a');
                break;
            }

            case TankCommand.COMMAND_DOWN:
            {
                _connector.Write('s');
                break;
            }

            case TankCommand.COMMAND_RIGTH:
            {
                _connector.Write('d');
                break;
            }

            case TankCommand.COMMAND_TURRET_LEFT:
            {
                _connector.Write('q');
                break;
            }

            case TankCommand.COMMAND_TURRET_RIGHT:
            {
                _connector.Write('e');
                break;
            }

            case TankCommand.COMMAND_MOVE_GUN:
            {
                _connector.Write('c');
                break;
            }

            case TankCommand.NO_COMMAND:
            {
                _connector.Write('r');
                break;
            }

            default:
            {
                _connector.Write('r');
                break;
            }
            }
        }
Example #2
0
        public void SetCommand(TankCommand tankCommand)
        {
            if (IsConnected)
            {
                _lastCommand = tankCommand;

                SendCommand(_lastCommand);
            }
        }
 public PetrolPump_ViewModel(MainWindow_ViewModel newMainViewModel, PetrolPump petrolPump)
 {
     MainWindowViewModel = newMainViewModel;
     PetrolPumpModel     = petrolPump;
     Taps = petrolPump.Taps;
     PetrolPumpTankCommand = new TankCommand(newMainViewModel, this);
     FinishedPumping       = new FinishedCommand(this);
     LiterGetankt          = 0;
     IsPumping             = false;
     allPumpVMs.Add(this);
 }
Example #4
0
        public virtual TankCommand Act(int x, int y)
        {
            var command = new TankCommand {
                DeltaX = Orientation.X, DeltaY = Orientation.Y, TransformTo = this
            };

            if (!IsAbleToStep(x + Orientation.X, y + Orientation.Y))
            {
                command.TransformTo = null;
            }
            return(command);
        }
        private void StopCommand(TankCommand tankCommand)
        {
            CommandInfo stopCommand = new CommandInfo();

            if (tankCommand == TankCommand.COMMAND_DOWN || tankCommand == TankCommand.COMMAND_LEFT || tankCommand == TankCommand.COMMAND_RIGTH || tankCommand == TankCommand.COMMAND_UP)
            {
                stopCommand.tankCommand = TankCommand.COMMAND_STOP_MOVE;
            }
            if (tankCommand == TankCommand.COMMAND_MOVE_GUN || tankCommand == TankCommand.COMMAND_TURRET_LEFT || tankCommand == TankCommand.COMMAND_TURRET_RIGHT)
            {
                stopCommand.tankCommand = TankCommand.COMMAND_STOP_ROTATE_TURRET;
            }
            stopCommand.delay = 0.1;
            SendCommand(stopCommand);
        }
Example #6
0
        public override TankCommand Act(int x, int y)
        {
            var command = new TankCommand();
            var coords  = FindPlayer(x, y);

            if (coords != new Point(-1, -1))
            {
                var correctOrientation = new Point
                {
                    X = CalculateAxisDirection(x, coords.X),
                    Y = CalculateAxisDirection(y, coords.Y)
                };
                if (correctOrientation == Orientation &&
                    IsAbleToStep(x + correctOrientation.X, y + correctOrientation.Y))
                {
                    command.CreateTo = Game.Shells[GetType()](Orientation);
                }
                else
                {
                    Orientation = correctOrientation;
                }
            }
            else
            {
                if (IsAbleToStep(x + Orientation.X, y + Orientation.Y))
                {
                    command.DeltaX      = Orientation.X;
                    command.DeltaY      = Orientation.Y;
                    command.TransformTo = this;
                    if (Game.Map[x + Orientation.X, y + Orientation.Y] is Upgrade)
                    {
                        command.TransformTo = new EnemyUpgraded(Orientation);
                    }
                }
                else
                {
                    Orientation = FindNewOrientation(x, y);
                }
            }

            return(command);
        }
Example #7
0
        public override TankCommand Act(int x, int y)
        {
            var command = new TankCommand();

            if (Game.Delta == Orientation)
            {
                if (IsAbleToStep(x + Game.Delta.X, y + Game.Delta.Y))
                {
                    command.DeltaX      = Game.Delta.X;
                    command.DeltaY      = Game.Delta.Y;
                    command.TransformTo = this;
                    if (Game.Map[x + Orientation.X, y + Orientation.Y] is Upgrade)
                    {
                        command.TransformTo = new PlayerUpgraded(Orientation);
                    }
                }

                Orientation  = Game.Delta;
                Game.Delta.X = 0;
                Game.Delta.Y = 0;
            }
            else if (!Game.Delta.IsEmpty)
            {
                Orientation         = Game.Delta;
                Game.Delta          = Point.Empty;
                command.DeltaX      = 0;
                command.DeltaY      = 0;
                command.TransformTo = this;
            }

            if (!Game.IsShoot || !IsAbleToStep(Orientation.X + x, Orientation.Y + y) || Game.Map[Orientation.X + x, Orientation.Y + y] is Upgrade)
            {
                return(command);
            }
            command.CreateTo = Game.Shells[this.GetType()](Orientation);
            Game.IsShoot     = false;
            return(command);
        }