You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
1.7 KiB
76 lines
1.7 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Runtime.Remoting;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace WorkField.Model
|
|
{
|
|
/// <summary>
|
|
/// Стадион
|
|
/// </summary>
|
|
public class CStadium
|
|
{
|
|
private System.Threading.Timer _timer;
|
|
|
|
/// <summary>
|
|
/// Ширина
|
|
/// </summary>
|
|
public int Width;
|
|
/// <summary>
|
|
/// Длина
|
|
/// </summary>
|
|
public int Height;
|
|
/// <summary>
|
|
/// Список работников
|
|
/// </summary>
|
|
public List<CPlayer> PlayerList;
|
|
|
|
public CStadium (int width, int height)
|
|
{
|
|
Width = width;
|
|
Height = height;
|
|
PlayerList = new List<CPlayer>();
|
|
|
|
_timer = new Timer(h_tick, null,
|
|
new TimeSpan(0, 0, 0, 0, 300),
|
|
new TimeSpan(0, 0, 0, 0, 1000)
|
|
);
|
|
}
|
|
|
|
private void h_tick(object x)
|
|
{
|
|
this.Move();
|
|
}
|
|
|
|
internal void Move()
|
|
{
|
|
foreach (CPlayer pPlayer in PlayerList) {
|
|
pPlayer.Move();
|
|
}
|
|
}
|
|
|
|
public bool IsPosition(int newX, int newY)
|
|
{
|
|
string sFilename = "1.bmp";
|
|
Bitmap pB = new Bitmap(sFilename);
|
|
if (newX < 0) return false;
|
|
if (newY < 0) return false;
|
|
if (newX > pB.Width) return false;
|
|
if (newY > pB.Height) return false;
|
|
//for (int xx = 0; xx < pB.Width; xx++) {
|
|
// for (int yy = 0; yy < pB.Height; yy++) {
|
|
Color pColor = pB.GetPixel(newX, newY);
|
|
return !(pColor.R == Color.Black.R
|
|
&& pColor.G == Color.Black.G
|
|
&& pColor.B == Color.Black.B
|
|
);
|
|
// }
|
|
//}
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|