class Program
{
public static int mineral = 50;
static void Main(string[] args)
{
CommandCenter commandCenter = new CommandCenter(0, 0);
SCV scv = new SCV(0, 0);
Minerals minerals = new Minerals(3, 2, 1500);
for (int i = 0; i < 2; i++)
{
scv.Gather(minerals.x, minerals.y, minerals);
scv.ReturnCargo(commandCenter.x, commandCenter.y);
Console.WriteLine("현재 미네랄: {0}", mineral);
}
}
}
class CommandCenter
{
public int x;
public int y;
public CommandCenter(int x, int y)
{
Console.WriteLine("{0}가 (x:{1} ,y:{2}) 위치에 생성 되었습니다.", this, x, y);
this.x = x;
this.y = y;
}
}
class SCV
{
public Minerals piece;
private int x;
private int y;
//생성자
public SCV(int x, int y)
{
Console.WriteLine("{0}가 (x:{1} ,y:{2}) 위치에 생성 되었습니다.", this, x, y);
this.x = x;
this.y = y;
}
public void Move(int x, int y)
{
Console.WriteLine("목표 위치: ({0},{1})", x, y);
Console.WriteLine("현재 위치: ({0},{1})", this.x, this.y);
while (this.x != x || this.y != y)
{
if (this.x < x)
{
this.x++;
}
else if (this.x > x)
{
this.x--;
}
else if (this.y < y)
{
this.y++;
}
else if (this.y > y)
{
this.y--;
}
Console.WriteLine("현재 위치: ({0},{1})", this.x, this.y);
}
Console.WriteLine("이동 완료");
}
public void Gather(int x, int y, Minerals minerals)
{
Move(x, y);
if (minerals.deposits < 8)
{
this.piece = new Minerals(minerals.deposits);
minerals.deposits = 0;
}
else
{
this.piece = new Minerals(8);
minerals.deposits -= 8;
}
Console.WriteLine("채취한 미네랄: {0}, 남은 미네랄: {1}", this.piece.deposits, minerals.deposits);
}
public void ReturnCargo(int x, int y)
{
Move(x, y);
Console.WriteLine("미네랄 {0}을 반환합니다.", this.piece.deposits);
Program.mineral += this.piece.deposits;
this.piece.deposits = 0;
}
//public void Build(int x, int y, int mineral)
//{
// if(mineral < 151)
// {
// Console.WriteLine("미네랄이 부족합니다.");
// }
// else
// {
// Move(x, y);
// }
//}
}
class Minerals
{
public int deposits;
public int x;
public int y;
//생성자
public Minerals(int x, int y, int deposits)
{
this.x = x;
this.y = y;
this.deposits = deposits;
Console.WriteLine("{0}({1})가 (x:{2} ,y:{3}) 위치에 생성 되었습니다.", this, this.deposits, x, y);
}
public Minerals(int deposits)
{
this.deposits = deposits;
}
}
class Barracks
{
private int x;
private int y;
public Barracks(int x, int y)
{
Console.WriteLine("{0}가 (x:{1} ,y:{2}) 위치에 생성 되었습니다.", this, x, y);
this.x = x;
this.y = y;
}
}