public IList <GoalField> GetNotOccupiedGoalFields(TeamColour teamColour)
        {
            var possibleFields     = Fields.Cast <Field>().Where(f => f is GoalField);
            var possibleGoalFields = possibleFields.Cast <GoalField>().Where(f => f.Team == teamColour && f.Type == GoalFieldType.goal);

            return(possibleGoalFields.ToList());
        }
 public Team(TeamColour color, uint maxPlayerCount)
 {
     Color          = color;
     MaxPlayerCount = maxPlayerCount;
     Players        = new List <Player>();
     Leader         = null;
 }
Ejemplo n.º 3
0
 public GoalField(int x, int y, DateTime timeStamp, TeamColour team, GoalFieldType type, Player player = null) : base(x, y)
 {
     Type      = type;
     Team      = team;
     TimeStamp = timeStamp;
     Player    = player;
 }
Ejemplo n.º 4
0
            public TeamScoreDisplay(TeamColour teamColour)
            {
                this.teamColour = teamColour;

                RelativeSizeAxes = Axes.Y;
                Width            = 300;
            }
Ejemplo n.º 5
0
 public Player(Guid guid, ulong id, PlayerType type, TeamColour team)
 {
     this.Guid       = guid;
     this.Id         = id;
     this.PlayerType = type;
     this.TeamColour = team;
 }
Ejemplo n.º 6
0
 public JoinGameMessage(string name, TeamColour team, PlayerRole role, long playerId = -1)
 {
     GameName      = name;
     PrefferedTeam = team;
     PrefferedRole = role;
     PlayerId      = playerId;
 }
        public Field GetEmptyPositionForPlayer(TeamColour team)
        {
            //no player, TaskField or our GoalField
            var possibleFields = Fields.Cast <Field>().Where(f => (f is TaskField || (f is GoalField && !IsInEnemyGoalArea(f.Y, team))) && f.PlayerId == null);

            //maybe random is a bad idea (unfair?)
            return(possibleFields.RandomElementUsing(rnd));
        }
Ejemplo n.º 8
0
 public PlayerController(TeamColour team, PlayerRole role, PlayerSettingsConfiguration settings, string gameName = null)
 {
     clientSocket   = new TcpClient();
     PrefferedColor = team;
     PrefferedRole  = role;
     Settings       = settings;
     GameName       = gameName;
 }
Ejemplo n.º 9
0
        public DrawableTeamHeader(TeamColour colour)
        {
            Background.Colour = TournamentGame.GetTeamColour(colour);

            Text.Colour = TournamentGame.TEXT_COLOUR;
            Text.Text   = $"Team {colour}".ToUpperInvariant();
            Text.Scale  = new Vector2(0.6f);
        }
        private void EndGame(Wrapper.AddressableBoard board, TeamColour teamColour)
        {
            IList <Wrapper.GoalField> goalFields = board.GetNotOccupiedGoalFields(teamColour);

            if (goalFields.Count == 0)
            {
                endGame = true;
            }
        }
 public bool IsInEnemyGoalArea(long y, TeamColour myTeam)
 {
     if (myTeam == TeamColour.blue) //we are blue, enemy is red and on top
     {
         return(y >= Height - GoalsHeight);
     }
     //we are red, enemy is blue and on the bottom
     return(y < GoalsHeight);
 }
Ejemplo n.º 12
0
 private Player.Player PreparePlayerObject(TeamColour colour, ulong id, PlayerRole role = PlayerRole.member)
 {
     return new Player.Player(colour,role)
     {
         ID = id,
         GameId = 0,
         GUID = GetUniqueGUID()
     };
 }
Ejemplo n.º 13
0
        public Player.Player GetPlayer(string guid, ulong id, TeamColour tc, ActionType action)
        {
            var player = new Player.Player(tc, _guid: guid);

            player.ID = id;
            player.LastActionTaken = action;

            return(player);
        }
Ejemplo n.º 14
0
 public GoalField(GoalField field) : base(field.ToBase())
 {
     Type = field.Type;
     Team = field.Team;
     if (field.Player != null)
     {
         Player = new Player(field.Player);
     }
 }
Ejemplo n.º 15
0
 public Player(Player original)
 {
     Team     = original.Team;
     GUID     = original.GUID;
     ID       = original.ID;
     Location = new GameArea.GameObjects.Location(original.Location.X, original.Location.Y);
     if (original.piece != null)
     {
         this.piece = new GameArea.GameObjects.Piece(original.piece.ID, original.piece.TimeStamp, original.piece.Type, original.piece.PlayerId); // player can't see original piece (sham or goal info must be hidden)
     }
 }
Ejemplo n.º 16
0
 private bool CheckIfNotEnteringWrongGoalArea(int x, int y, TeamColour team)
 {
     if (team == TeamColour.red && y < actualBoard.GoalAreaHeight ||
         team == TeamColour.blue && y >= actualBoard.Height - actualBoard.GoalAreaHeight)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 17
0
        public Player.Player GetPlayer(string guid, ulong id, TeamColour tc, ActionType action)
        {
            var player = new Player.Player(tc, _guid: guid);

            player.ID = id;
            player.LastActionTaken = action;

            player.myTeam    = new List <GameArea.GameObjects.Player>();
            player.otherTeam = new List <GameArea.GameObjects.Player>();

            return(player);
        }
Ejemplo n.º 18
0
        private void setMode(TeamColour colour, ChoiceType choiceType)
        {
            pickColour = colour;
            pickType   = choiceType;

            Color4 setColour(bool active) => active ? Color4.White : Color4.Gray;

            buttonRedBan.Colour   = setColour(pickColour == TeamColour.Red && pickType == ChoiceType.Ban);
            buttonBlueBan.Colour  = setColour(pickColour == TeamColour.Blue && pickType == ChoiceType.Ban);
            buttonRedPick.Colour  = setColour(pickColour == TeamColour.Red && pickType == ChoiceType.Pick);
            buttonBluePick.Colour = setColour(pickColour == TeamColour.Blue && pickType == ChoiceType.Pick);
        }
 public GoalDirectionInfo(List <GameArea.GameObjects.GoalField> goals, TeamColour team, GameArea.GameObjects.Location _PlayerLocation)
 {
     PlayerLocation = _PlayerLocation;
     Team           = team;
     if (team == TeamColour.red)
     {
         Goals = goals.OrderBy(q => q.Y).ThenBy(q => q.X).Where(q => q.Type == GoalFieldType.unknown).ToList();
     }
     else
     {
         Goals = goals.OrderByDescending(q => q.Y).ThenBy(q => q.X).Where(q => q.Type == GoalFieldType.unknown).ToList();
     }
 }
Ejemplo n.º 20
0
        public DrawableTeamWithPlayers(TournamentTeam team, TeamColour colour)
        {
            AutoSizeAxes = Axes.Both;

            InternalChildren = new Drawable[]
            {
                new FillFlowContainer
                {
                    AutoSizeAxes = Axes.Both,
                    Direction    = FillDirection.Vertical,
                    Spacing      = new Vector2(30),
                    Children     = new Drawable[]
                    {
                        new DrawableTeamTitleWithHeader(team, colour),
                        new FillFlowContainer
                        {
                            AutoSizeAxes = Axes.Both,
                            Direction    = FillDirection.Horizontal,
                            Padding      = new MarginPadding {
                                Left = 10
                            },
                            Spacing  = new Vector2(30),
                            Children = new Drawable[]
                            {
                                new FillFlowContainer
                                {
                                    Direction          = FillDirection.Vertical,
                                    AutoSizeAxes       = Axes.Both,
                                    ChildrenEnumerable = team?.Players.Select(createPlayerText).Take(5) ?? Enumerable.Empty <Drawable>()
                                },
                                new FillFlowContainer
                                {
                                    Direction          = FillDirection.Vertical,
                                    AutoSizeAxes       = Axes.Both,
                                    ChildrenEnumerable = team?.Players.Select(createPlayerText).Skip(5) ?? Enumerable.Empty <Drawable>()
                                },
                            }
                        },
                    }
                },
            };

            TournamentSpriteText createPlayerText(TournamentUser p) =>
            new TournamentSpriteText
            {
                Text   = p.Username,
                Font   = OsuFont.Torus.With(size: 24, weight: FontWeight.SemiBold),
                Colour = Color4.White,
            };
        }
Ejemplo n.º 21
0
        public Player GetPlayer(string guid, ulong id, TeamColour tc, ActionType action, IPlayerController controller = null)
        {
            controller = new PlayerControllerMock();
            var player = new Player(tc, _guid: guid);

            player.ID = id;
            player.LastActionTaken = action;
            player.Controller      = controller;
            controller.Player      = player;
            player.myTeam          = new List <GameArea.GameObjects.Player>();
            player.otherTeam       = new List <GameArea.GameObjects.Player>();

            return(player);
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Validates if an Player can move on a given field or disvover it
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="team"></param>
 /// <returns></returns>
 private bool ValidateFieldPosition(int x, int y, TeamColour team)
 {
     if (CheckIfNotOutOfBorad(x, y))
     {
         return(false);
     }
     else if (CheckIfNotEnteringWrongGoalArea(x, y, team))
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Ejemplo n.º 23
0
        /// <summary>
        /// FOR UNIT TESTING - set a piece of a given type in a given location
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="type"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool SetPieceInLocation(int x, int y, TeamColour team, PieceType type, ulong id)
        {
            var piece = new GameObjects.Piece(id, DateTime.Now, type);

            if (ValidateFieldPosition(x, y, team) && actualBoard.GetField(x, y) is GameObjects.TaskField)
            {
                (actualBoard.GetField(x, y) as GameObjects.TaskField).Piece = piece;
                UpdateDistancesFromAllPieces();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 24
0
 public Player(TeamColour team, PlayerRole role = PlayerRole.member, PlayerSettingsConfiguration settings = null, IPlayerController gameController = null, string _guid = "TEST_GUID", IGameMaster gm = null, ulong id = 0)
 {
     Settings      = settings;
     gameMaster    = gm;
     Team          = team;
     GUID          = _guid;
     Role          = role;
     Location      = new GameArea.GameObjects.Location(0, 0);
     Controller    = gameController;
     State         = AgentState.SearchingForGame;
     LastMoveTaken = MoveType.up;
     ID            = id;
     MyPlayerKnowledgeExchangeQueue    = new List <KnowledgeExchangeRequestAgent>();
     OtherPlayerKnowledgeExchangeQueue = new List <KnowledgeExchangeRequestAgent>();
 }
Ejemplo n.º 25
0
        private void setNextMode()
        {
            const TeamColour roll_winner = TeamColour.Red; //todo: draw from match

            var nextColour = (currentMatch.Value.PicksBans.LastOrDefault()?.Team ?? roll_winner) == TeamColour.Red ? TeamColour.Blue : TeamColour.Red;

            if (pickType == ChoiceType.Ban && currentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) >= 2)
            {
                setMode(pickColour, ChoiceType.Pick);
            }
            else
            {
                setMode(nextColour, currentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) >= 2 ? ChoiceType.Pick : ChoiceType.Ban);
            }
        }
Ejemplo n.º 26
0
        public DrawableTeamTitleWithHeader(TournamentTeam team, TeamColour colour)
        {
            AutoSizeAxes = Axes.Both;

            InternalChild = new FillFlowContainer
            {
                AutoSizeAxes = Axes.Both,
                Direction    = FillDirection.Vertical,
                Spacing      = new Vector2(0, 10),
                Children     = new Drawable[]
                {
                    new DrawableTeamHeader(colour),
                    new DrawableTeamTitle(team),
                }
            };
        }
Ejemplo n.º 27
0
        public List <GoalField> GoalFields(TeamColour team)
        {
            var goalFields = new List <GoalField>();

            for (int i = 0; i < Height; i++)
            {
                for (int j = 0; j < Width; j++)
                {
                    if (fields[j, i] is GoalField && ((GoalField)fields[j, i]).Team == team)
                    {
                        goalFields.Add((GoalField)fields[j, i]);
                    }
                }
            }
            return(goalFields);
        }
Ejemplo n.º 28
0
        public TeamScore(Bindable <int?> score, TeamColour colour, int count)
        {
            bool flip   = colour == TeamColour.Blue;
            var  anchor = flip ? Anchor.TopRight : Anchor.TopLeft;

            AutoSizeAxes = Axes.Both;

            InternalChild = counter = new TeamScoreStarCounter(count)
            {
                Anchor = anchor,
                Scale  = flip ? new Vector2(-1, 1) : Vector2.One,
            };

            currentTeamScore.BindValueChanged(scoreChanged);
            currentTeamScore.BindTo(score);
        }
        public void GoToGoalArea(TeamColour color)
        {
            if (!InGoalArea)
            {
                switch (color)
                {
                case TeamColour.red:
                    TryMove(MoveType.up, true);
                    break;

                case TeamColour.blue:
                    TryMove(MoveType.down, true);
                    break;
                }
            }
        }
Ejemplo n.º 30
0
        public ISoldierFactory GetTeam(TeamColour teamColour)
        {
            ISoldierFactory Team = null;

            switch (teamColour)
            {
            case TeamColour.Red:
                Team = new RedTeamFactory();
                break;

            case TeamColour.Blue:
                Team = new BlueTeamFactory();
                break;
            }
            return(Team);
        }
Ejemplo n.º 31
0
    public void AddScore(TeamColour colour, int val)
    {
        switch (colour)
        {
            case TeamColour.RED:
            {
                _RedScore += val;
                _RedScoreText.text = _RedScore.ToString();
            }
            break;

            case TeamColour.BLUE:
            {
                _BlueScore += val;
                _BlueScoreText.text = _BlueScore.ToString();
            }
            break;

            case TeamColour.GREEN:
            {
                _GreenScore += val;
                _GreenScoreText.text = _GreenScoreText.ToString();
            }
            break;

            case TeamColour.YELLOW:
            {
                _YellowScore += val;
                _YellowScoreText.text = _YellowScoreText.ToString();
            }
            break;

            default:
                break;
        }
    }