Первая лабораторная работа. Исправлена проверка SetPosition, название класса.
This commit is contained in:
parent
c61311f5b5
commit
4a3fdebbdf
@ -3,13 +3,13 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using static ContainerShip.EntityContainerShip;
|
using static ContainerShip.EntityShip;
|
||||||
|
|
||||||
namespace ContainerShip
|
namespace ContainerShip
|
||||||
{
|
{
|
||||||
internal class DrawingShip
|
internal class DrawingShip
|
||||||
{
|
{
|
||||||
public EntityContainerShip Ship { private set; get; }
|
public EntityShip Ship { private set; get; }
|
||||||
private float _startPosX;
|
private float _startPosX;
|
||||||
private float _startPosY;
|
private float _startPosY;
|
||||||
private int? _pictureWidth = null;
|
private int? _pictureWidth = null;
|
||||||
@ -35,7 +35,7 @@ namespace ContainerShip
|
|||||||
/// <param name="bodyColor">Цвет кузова</param>
|
/// <param name="bodyColor">Цвет кузова</param>
|
||||||
public void Init(int speed, float weight, Color bodyColor)
|
public void Init(int speed, float weight, Color bodyColor)
|
||||||
{
|
{
|
||||||
Ship = new EntityContainerShip();
|
Ship = new EntityShip();
|
||||||
Ship.Init(speed, weight, bodyColor);
|
Ship.Init(speed, weight, bodyColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,11 +47,11 @@ namespace ContainerShip
|
|||||||
{
|
{
|
||||||
// Проверки
|
// Проверки
|
||||||
Random rn = new Random();
|
Random rn = new Random();
|
||||||
if (x < 0 || x > width)
|
if (x < 0 || x + _shipWidth> width)
|
||||||
{
|
{
|
||||||
x = rn.Next(0, width - _shipWidth);
|
x = rn.Next(0, width - _shipWidth);
|
||||||
}
|
}
|
||||||
if (y < 0 || y > height)
|
if (y < 0 || y + _shipHeight > height)
|
||||||
{
|
{
|
||||||
y = rn.Next(0, height - _shipHeight);
|
y = rn.Next(0, height - _shipHeight);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ContainerShip
|
namespace ContainerShip
|
||||||
{
|
{
|
||||||
internal class EntityContainerShip
|
internal class EntityShip
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Скорость
|
/// Скорость
|
Loading…
Reference in New Issue
Block a user