public override void AgentAction(float[] vectorAction, string textAction) { var num = Mathf.FloorToInt(vectorAction[0]); var player = num / numOfActions; var action = (AllMoves)(num % numOfActions); var move = new MoveTransaction() { player = player, action = action, team = Team }; FootballMatch.ScheduleTransaction(move); }
void ProcessMoves() { for (int i = 0; i < moveTransactions.Count; i++) { MoveTransaction move = moveTransactions[i]; // @TODO: know if its a player, which color it is, and the obj blackPlayers[move.index] = new Player(move.endPos); move.obj.transform.position = Pos2DTo3D(move.endPos); } moveTransactions.Clear(); }
public void ScheduleTransaction(MoveTransaction moveTransaction) { if (moveTransaction.team == Team.Blue) { bluePlayerMove = moveTransaction; } else { redPlayerMove = moveTransaction; } if (bluePlayerMove != null && redPlayerMove != null) { ExecuteMoves(); bluePlayerMove = null; redPlayerMove = null; } }
void CreateMoveTransactions(List <Player> players, List <GameObject> playerObjs, ActionType action) { Vector2 dir = ActionTypeToDirection(action); Debug.Log(dir); for (int i = 0; i < players.Count; i++) { Player p = players[i]; MoveTransaction move = new MoveTransaction(); move.index = i; move.obj = playerObjs[i]; move.startPos = p.pos; move.endPos = p.pos + dir; moveTransactions.Add(move); } // @TODO: create moves for pieces of both colors, and invalidate certain moves // What happens when you push against a structure that has a part that doesnt move? // Does nothing move, or do we allow the players to become separated? Could be interesting! }