void unitMoveOperation(MultipleUnitBase _unitStats, UserControl _unit) { // vertical move if (WallCollision.heroCanMove ( _unitStats.CurrentPositionY, _canvasStartY, _unitStats.CurrentVectorY, _unitStats.Height, _canvasHeight ) ) { Canvas.SetTop(_unit, (_unitStats.CurrentPositionY + _unitStats.CurrentVectorY)); } //horisontal move if (WallCollision.heroCanMove ( _unitStats.CurrentPositionX, _canvasStartX, _unitStats.CurrentVectorX, _unitStats.Widht, _canvasWidth ) ) { Canvas.SetLeft(_unit, (_unitStats.CurrentPositionX + _unitStats.CurrentVectorX)); } }
public static void controls(MultipleUnitBase _playerStats) { if (Keyboard.IsKeyDown(Key.Up)) { _playerStats.CurrentVectorY = -_playerStats.MovementSpeed; _playerStats.AngleChanges = true; } if (Keyboard.IsKeyDown(Key.Down)) { _playerStats.CurrentVectorY = _playerStats.MovementSpeed; _playerStats.AngleChanges = true; } if (Keyboard.IsKeyDown(Key.Left)) { _playerStats.CurrentVectorX = -_playerStats.MovementSpeed; _playerStats.AngleChanges = true; } if (Keyboard.IsKeyDown(Key.Right)) { _playerStats.CurrentVectorX = _playerStats.MovementSpeed; _playerStats.AngleChanges = true; } }
void ResetMovesParametr(UserControl UnitControl, MultipleUnitBase Unitparameters) { Unitparameters.AngleChanges = false; Unitparameters.CurrentVectorX = 0; Unitparameters.CurrentVectorY = 0; Unitparameters.CurrentPositionX = Canvas.GetLeft(UnitControl); Unitparameters.CurrentPositionY = Canvas.GetTop(UnitControl); }
void unitAngleChangingOperation(MultipleUnitBase _unitStats, UserControl _unit) { double new_angle = AngleControler.SetPlayerAngle (_unitStats.CurrentVectorY, _unitStats.CurrentVectorX, _unitStats.CurrentAngle, _unitStats.AngleChanges); RotateTransform rt = new RotateTransform(new_angle); _unit.RenderTransform = rt; _unitStats.CurrentAngle = new_angle; }