public TaskDirectionInfo(GameArea.GameObjects.TaskField left, GameArea.GameObjects.TaskField right, GameArea.GameObjects.TaskField up, GameArea.GameObjects.TaskField down) { Left = left; Right = right; Up = up; Down = down; }
/// <summary> /// Sets info about discovered TaskField /// </summary> /// <param name="location"></param> /// <param name="dx"></param> /// <param name="dy"></param> /// <param name="field"></param> /// <param name="TaskFieldList"></param> public void SetInfoAboutDiscoveredTaskField(GameObjects.Location location, int dx, int dy, GameObjects.Field field, List <GameObjects.TaskField> TaskFieldList) { //basic information GameObjects.TaskField responseField = new GameObjects.TaskField(location.X + dx, location.Y + dy, DateTime.Now) { TimeStamp = DateTime.Now, DistanceToPiece = (field as GameObjects.TaskField).DistanceToPiece }; //anoter Player on the field if (field.HasPlayer()) { responseField.PlayerId = (long)field.Player.ID; responseField.Player = field.Player; } else { responseField.PlayerId = -1; responseField.Player = null; } //piece on the field GameObjects.Piece piece = (field as GameObjects.TaskField).Piece; if (piece != null) { responseField.Piece = piece; } else { responseField.Piece = null; } TaskFieldList.Add(responseField); }
public TaskField(TaskField task) : base(task.ToBase()) { DistanceToPiece = task.DistanceToPiece; if (task.Piece != null) { Piece = new Piece(task.Piece); } if (task.Player != null) { Player = new Player(task.Player); } }
public GameBoard(int width, int taskAreaHeight, int goalAreaHeight, GoalFieldType defaultGoalType = GoalFieldType.unknown) { Width = width; TaskAreaHeight = taskAreaHeight; GoalAreaHeight = goalAreaHeight; fields = new Field[width, taskAreaHeight + 2 * goalAreaHeight]; for (int i = 0; i < GoalAreaHeight; i++) { for (int j = 0; j < Width; j++) { fields[j, i] = new GoalField(j, i, DateTime.Now, TeamColour.blue, defaultGoalType); fields[j, i + taskAreaHeight + goalAreaHeight] = new GoalField(j, i + taskAreaHeight + goalAreaHeight, DateTime.Now, TeamColour.red, defaultGoalType); } } for (int i = GoalAreaHeight; i < Height - GoalAreaHeight; i++) { for (int j = 0; j < Width; j++) { fields[j, i] = new TaskField(j, i, DateTime.Now); } } }
// ------------ additional methods #region addition api methods /// <summary> /// Handles Player's request - place a Piece on a TaskField /// </summary> public GameObjects.TaskField[] TryPlacePieceOnTaskField(GameObjects.Location location, string playerGuid) { GameObjects.TaskField fieldMessage = null; var currentTaskField = actualBoard.GetField(location.X, location.Y) as GameObjects.TaskField; var Player = Players.Where(q => q.GUID == playerGuid).First(); // if TaskField is not occupied if (currentTaskField.Piece == null) { fieldMessage = new GameObjects.TaskField(location.X, location.Y, DateTime.Now) { PlayerId = (long)Player.ID, Piece = Player.GetPiece, TimeStamp = DateTime.Now }; var piece = Player.GetPiece; piece.PlayerId = 0; currentTaskField.Piece = piece; // the piece is put on the field Player.SetPiece(null); // the piece is no longer possesed by an Player UpdateDistancesFromAllPieces(); } return(new GameObjects.TaskField[] { fieldMessage }); // fieldMessage is null if TaskField is occupied }