55 lines
1.8 KiB
C#
55 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using CzokoŚmieciarka.MonoGameView.DataModels.Enums;
|
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.GarbageCollector;
|
|
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
|
|
|
namespace CzokoŚmieciarka.MonoGameView.DataModels.Models.Steps
|
|
{
|
|
public class MoveStep : IStep
|
|
{
|
|
public MoveStep(Direction direction)
|
|
{
|
|
this._direction = direction;
|
|
}
|
|
public int ID { get
|
|
{
|
|
return (int)_direction + 4;
|
|
} }
|
|
private Direction _direction;
|
|
private IGarbageCollector _garbageCollector;
|
|
|
|
public bool Invoke(IGarbageCollector _garbageCollector, ICloneable [,] grid)
|
|
{
|
|
if(grid[_garbageCollector.Coords.X, _garbageCollector.Coords.Y] is Road1)
|
|
grid[_garbageCollector.Coords.X, _garbageCollector.Coords.Y] = new Road2(new Coords(_garbageCollector.Coords.X, _garbageCollector.Coords.Y));
|
|
var pass = false;
|
|
switch (_direction)
|
|
{
|
|
case Direction.Up:
|
|
pass = _garbageCollector.MoveUp();
|
|
break;
|
|
|
|
case Direction.Down:
|
|
pass = _garbageCollector.MoveDown();
|
|
break;
|
|
case Direction.Left:
|
|
pass = _garbageCollector.MoveLeft();
|
|
break;
|
|
case Direction.Right:
|
|
pass = _garbageCollector.MoveRight();
|
|
break;
|
|
}
|
|
if (pass)
|
|
{
|
|
_garbageCollector.Counter++;
|
|
}
|
|
return pass;
|
|
}
|
|
}
|
|
}
|