Beispiel #1
0
 public GoalData(
     AccumulatedFrame match,
     Player player,
     LastScore lastScore,
     float gameClock,
     Vector2 goalPos,
     float angleIntoGoal,
     bool backboard,
     Team.TeamColor goalColor,
     bool?leftHanded,
     float?underhandedness,
     List <Vector3> discTrajectory)
 {
     eventType            = EventType.goal;
     matchData            = match;
     GameClock            = gameClock;
     Player               = player;
     LastScore            = lastScore;
     GoalPos              = goalPos;
     GoalAngle            = angleIntoGoal;
     Backboard            = backboard;
     GoalColor            = goalColor;
     LeftHanded           = leftHanded;
     this.underhandedness = underhandedness;
     DiscTrajectory       = new List <Vector3>(discTrajectory);
 }
        public static string SendGameOver(Team.TeamColor avengers)
        {
            string file = @"..\..\JSONs\GameOver.json";
            string json = "";

            if (!File.Exists(file))
            {
                Console.WriteLine("DONE\n");
            }
            else
            {
                json = File.ReadAllText(file, Encoding.ASCII);
            }

            dynamic magic = Newtonsoft.Json.JsonConvert.DeserializeObject(json);

            magic.result = avengers == Team.TeamColor.RED ? "red" : "blue";

            return(JsonConvert.SerializeObject(magic));
        }
Beispiel #3
0
        public static string GetOverlayTeamName(Team.TeamColor team)
        {
            switch (team)
            {
            case Team.TeamColor.blue:
                switch (SparkSettings.instance.overlaysTeamSource)
                {
                case 0:
                    return(SparkSettings.instance.overlaysManualTeamNameBlue);

                case 1:
                    return(Program.CurrentRound.teams[Team.TeamColor.blue]?.vrmlTeamName);
                }

                break;

            case Team.TeamColor.orange:
                switch (SparkSettings.instance.overlaysTeamSource)
                {
                case 0:
                    return(SparkSettings.instance.overlaysManualTeamNameOrange);

                case 1:
                    return(Program.CurrentRound.teams[Team.TeamColor.orange]?.vrmlTeamName);
                }

                break;

            case Team.TeamColor.spectator:
            default:
                Logger.LogRow(Logger.LogType.Error, "Can't get team name from spectator team");
                break;
            }

            return("");
        }
Beispiel #4
0
        public void TestMethod_ForBoard() /* COMPLETE */
        {
            Piece p1 = new Piece()
            {
                pieceID = 0,
                isSham  = false,
                row     = 0,
                column  = 0
            };

            Piece p2 = new Piece()
            {
                pieceID = 1,
                isSham  = false,
                row     = 1,
                column  = 1
            };

            List <Piece> listp = new List <Piece>()
            {
                p1, p2
            };
            Board b = new Board();

            b.Pieces = listp;

            Player p_blue = new Player()
            {
                role = Player.Role.LEADER,
                //playerID = 0,
                Row    = 0,
                Column = 0,
                //toCheck = true,
                Team = Team.TeamColor.BLUE
            };

            Player p_red = new Player()
            {
                role = Player.Role.LEADER,
                //playerID = 1,
                Row    = 1,
                Column = 10,
                //toCheck = true,
                Team = Team.TeamColor.RED
            };
            Goal g1 = new Goal()
            {
                column = 0,
                row    = 1,
                isGoal = true
            };

            Goal g2 = new Goal()
            {
                column = 1,
                row    = 2,
                isGoal = true
            };

            List <Goal> listg = new List <Goal>()
            {
                g1, g2
            };

            b.DiscoveredBlueGoals   = listg;
            b.DiscoveredRedGoals    = listg;
            b.UndiscoveredBlueGoals = listg;
            b.UndiscoveredRedGoals  = listg;
            Team t_blue = new Team(Team.TeamColor.BLUE)
            {
                leader = p_blue
            };

            b.BlueTeam = t_blue;

            Team t_red = new Team(Team.TeamColor.RED)
            {
                leader = p_red
            };

            b.BlueTeam = t_red;

            Board.GoalHeight = 20;
            Board.Height     = 10;

            int col = 0, row = 0;

            int actual   = (int)b.getCellStatus(col, row);
            int expected = 16;

            Assert.AreEqual(expected, actual);

            bool actual2   = b.IsUndiscoveredGoal(col, row);
            bool expected2 = false;

            Assert.AreEqual(expected2, actual2);

            Team.TeamColor        col_blue  = Team.TeamColor.BLUE;
            Player.NeighborStatus actual3   = b.GetPlayersNeighbor(col, row, col_blue);
            Player.NeighborStatus expected3 = Player.NeighborStatus.BLOCKED;

            Assert.AreEqual(expected3, actual3);

            int col1 = 1, row1 = 1;

            Team.TeamColor        col_red = Team.TeamColor.RED;
            Player.NeighborStatus actual4 = b.GetPlayersNeighbor(col1, row1, col_red);
            Player.NeighborStatus expected4 = Player.NeighborStatus.BLOCKED;
            Assert.AreEqual(expected4, actual4);
            //Assert.IsFalse(b.IsUndiscoveredGoal(col, row));
        }
Beispiel #5
0
        //CHANGED NOW
        public Player.NeighborStatus GetPlayersNeighbor(int column, int row, Team.TeamColor team)
        {
            /* End of the board */
            if ((column < 0) || (row < 0) || (row >= Height) || (column >= Width))
            {
                return(Player.NeighborStatus.BLOCKED);
            }

            /* Goal Area */
            if (row < GoalHeight)
            {
                if (team == Team.TeamColor.BLUE)
                {
                    Team.TeamCell teamCell = BlueTeam.isDiscovered(column, row);
                    if (teamCell == Team.TeamCell.FREE)
                    {
                        return(Player.NeighborStatus.GOAL_AREA);
                    }
                    if (teamCell == Team.TeamCell.DISCOVERED_GOAL)
                    {
                        return(Player.NeighborStatus.DISCOVERED_GOAL);
                    }
                    if (teamCell == Team.TeamCell.DISCOVERED_NONGOAL)
                    {
                        return(Player.NeighborStatus.DISCOVERED_NONGOAL);
                    }
                }
                else
                {
                    return(Player.NeighborStatus.BLOCKED);
                }
            }
            if (Height - row - 1 < GoalHeight)
            {
                if (team == Team.TeamColor.RED)
                {
                    Team.TeamCell teamCell = RedTeam.isDiscovered(column, row);
                    if (teamCell == Team.TeamCell.FREE)
                    {
                        return(Player.NeighborStatus.GOAL_AREA);
                    }
                    if (teamCell == Team.TeamCell.DISCOVERED_GOAL)
                    {
                        return(Player.NeighborStatus.DISCOVERED_GOAL);
                    }
                    if (teamCell == Team.TeamCell.DISCOVERED_NONGOAL)
                    {
                        return(Player.NeighborStatus.DISCOVERED_NONGOAL);
                    }
                }
                else
                {
                    return(Player.NeighborStatus.BLOCKED);
                }
            }

            /* Other player */
            foreach (Player p in RedTeam.members)
            {
                if (p.Column == column && p.Row == row)
                {
                    return(Player.NeighborStatus.BLOCKED);
                }
            }
            if (RedTeam.leader.Column == column && RedTeam.leader.Row == row)
            {
                return(Player.NeighborStatus.BLOCKED);
            }

            foreach (Player p in BlueTeam.members)
            {
                if (p.Column == column && p.Row == row)
                {
                    return(Player.NeighborStatus.BLOCKED);
                }
            }
            if (BlueTeam.leader.Column == column && BlueTeam.leader.Row == row)
            {
                return(Player.NeighborStatus.BLOCKED);
            }

            /* Piece */
            foreach (Piece p in Pieces)
            {
                if (p.column == column && p.row == row)
                {
                    return(Player.NeighborStatus.PIECE);
                }
            }

            /* Free cell */
            return(Player.NeighborStatus.FREE);
        }