Ejemplo n.º 1
0
        private static void UpdateTeamSettings(string TeamProjectName, string TeamName)
        {
            Console.WriteLine("==========Update Settings");

            TeamContext teamContext = new TeamContext(TeamProjectName, TeamName);

            TeamSetting teamSetting = WorkClient.GetTeamSettingsAsync(teamContext).Result;

            TeamSettingsPatch teamSettingsPatch = new TeamSettingsPatch();

            //update backlogs

            teamSettingsPatch.BacklogVisibilities = teamSetting.BacklogVisibilities;

            if (teamSettingsPatch.BacklogVisibilities.ContainsKey(BacklogCategories.Epic) && teamSettingsPatch.BacklogVisibilities[BacklogCategories.Epic])
            {
                teamSettingsPatch.BacklogVisibilities[BacklogCategories.Epic] = false;
            }
            if (teamSettingsPatch.BacklogVisibilities.ContainsKey(BacklogCategories.Feature) && teamSettingsPatch.BacklogVisibilities[BacklogCategories.Feature])
            {
                teamSettingsPatch.BacklogVisibilities[BacklogCategories.Feature] = false;
            }

            //more work
            teamSettingsPatch.WorkingDays = new DayOfWeek[] { DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday, DayOfWeek.Saturday };

            teamSetting = WorkClient.UpdateTeamSettingsAsync(teamSettingsPatch, teamContext).Result;

            GetTeamSettings(TeamProjectName, TeamName);
        }
Ejemplo n.º 2
0
        public TeamSetting UpdateTeamSetting(TeamSetting teamSetting)
        {
            return(ExecuteFaultHandledOperation(() =>
            {
                var groupNames = new List <string>()
                {
                    BudgetModuleDefinition.GROUP_ADMINISTRATOR, BudgetModuleDefinition.GROUP_BUSINESS
                };
                AllowAccessToOperation(BudgetModuleDefinition.SOLUTION_NAME, groupNames);

                ITeamSettingRepository teamSettingRepository = _DataRepositoryFactory.GetDataRepository <ITeamSettingRepository>();

                TeamSetting updatedEntity = null;

                if (teamSetting.TeamSettingId == 0)
                {
                    updatedEntity = teamSettingRepository.Add(teamSetting);
                }
                else
                {
                    updatedEntity = teamSettingRepository.Update(teamSetting);
                }

                return updatedEntity;
            }));
        }
Ejemplo n.º 3
0
        public TeamSetting UpdateTeamSettings()
        {
            IDictionary <string, bool> backlogVisibilities = new Dictionary <string, bool>()
            {
                { "Microsoft.EpicCategory", false },
                { "Microsoft.FeatureCategory", true },
                { "Microsoft.RequirementCategory", true }
            };

            TeamSettingsPatch updatedTeamSettings = new TeamSettingsPatch()
            {
                BugsBehavior        = BugsBehavior.AsTasks,
                WorkingDays         = new DayOfWeek[] { DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday },
                BacklogVisibilities = backlogVisibilities
            };

            VssConnection  connection = Context.Connection;
            WorkHttpClient workClient = connection.GetClient <WorkHttpClient>();

            Guid projectId = ClientSampleHelpers.FindAnyProject(this.Context).Id;
            var  context   = new TeamContext(projectId);

            TeamSetting result = workClient.UpdateTeamSettingsAsync(updatedTeamSettings, context).Result;

            Console.WriteLine("Backlog iteration: {0}", result.BacklogIteration.Name);
            Console.WriteLine("Bugs behavior: {0}", result.BugsBehavior);
            Console.WriteLine("Default iteration : {0}", result.DefaultIterationMacro);
            Console.WriteLine("Working days: {0}", String.Join(",", result.WorkingDays.Select <DayOfWeek, string>(dow => { return(dow.ToString()); })));

            return(result);
        }
Ejemplo n.º 4
0
        public TeamSetting GetTeamSettings(string project)
        {
            VssConnection  connection     = new VssConnection(_uri, _credentials);
            WorkHttpClient workHttpClient = connection.GetClient <WorkHttpClient>();
            var            teamContext    = new TeamContext(project);
            TeamSetting    result         = workHttpClient.GetTeamSettingsAsync(teamContext).Result;

            return(result);
        }
Ejemplo n.º 5
0
        public static HttpResponseMessage Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequestMessage req,
            [Table("gamesettings", Connection = "AzureWebJobsStorage")] CloudTable inTable,
            TraceWriter log)
        {
            log.Info("### Get Team Settings Triggered ###");

            // Get Team Settings
            TableQuery <TeamSetting> query = new TableQuery <TeamSetting>().Take(1);
            TeamSetting ts = inTable.ExecuteQuery(query).FirstOrDefault();

            // Return team settings
            return(req.CreateResponse(HttpStatusCode.OK, ts));
        }
Ejemplo n.º 6
0
        public TeamSetting GetTeamSettings()
        {
            VssConnection  connection = Context.Connection;
            WorkHttpClient workClient = connection.GetClient <WorkHttpClient>();

            Guid projectId = ClientSampleHelpers.FindAnyProject(this.Context).Id;
            Guid teamId    = ClientSampleHelpers.FindAnyTeam(this.Context, projectId).Id;

            var         context = new TeamContext(projectId, teamId);
            TeamSetting result  = workClient.GetTeamSettingsAsync(context).Result;

            Console.WriteLine("Backlog iteration: {0}", result.BacklogIteration.Name);
            Console.WriteLine("Bugs behavior: {0}", result.BugsBehavior);
            Console.WriteLine("Default iteration : {0}", result.DefaultIterationMacro);

            return(result);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Get general team settings
        /// </summary>
        /// <param name="TeamProjectName"></param>
        /// <param name="TeamName"></param>
        static void GetTeamSettings(string TeamProjectName, string TeamName)
        {
            Console.WriteLine("==========Get Team Settings");

            TeamContext teamContext = new TeamContext(TeamProjectName, TeamName);

            TeamSetting teamSetting = WorkClient.GetTeamSettingsAsync(teamContext).Result;

            Console.WriteLine("Settings for the team " + TeamName);
            Console.WriteLine("Backlog Iteration    : " + teamSetting.BacklogIteration.Name);
            Console.WriteLine("Default Iteration    : " + teamSetting.DefaultIteration.Name);
            Console.WriteLine("Macro of Iteration   : " + teamSetting.DefaultIterationMacro);
            Console.WriteLine("Categories of backlog:");
            foreach (string bkey in teamSetting.BacklogVisibilities.Keys)
            {
                if (teamSetting.BacklogVisibilities[bkey])
                {
                    Console.WriteLine("\t" + bkey);
                }
            }
            Console.WriteLine("Working days         :");
            foreach (var wday in teamSetting.WorkingDays)
            {
                Console.WriteLine("\t" + wday.ToString());
            }

            switch (teamSetting.BugsBehavior)
            {
            case BugsBehavior.AsRequirements:
                Console.WriteLine("Bugs Behavior: Bugs in a requirements backlog.");
                break;

            case BugsBehavior.AsTasks:
                Console.WriteLine("Bugs Behavior: Bugs in a sprint backlog as tasks.");
                break;

            case BugsBehavior.Off:
                Console.WriteLine("Bugs Behavior: Find bugs through queries.");
                break;
            }
        }
Ejemplo n.º 8
0
        public TeamSetting GetTeamSetting(int teamSettingId)
        {
            return(ExecuteFaultHandledOperation(() =>
            {
                var groupNames = new List <string>()
                {
                    BudgetModuleDefinition.GROUP_ADMINISTRATOR, BudgetModuleDefinition.GROUP_BUSINESS
                };
                AllowAccessToOperation(BudgetModuleDefinition.SOLUTION_NAME, groupNames);

                ITeamSettingRepository teamSettingRepository = _DataRepositoryFactory.GetDataRepository <ITeamSettingRepository>();

                TeamSetting teamSettingEntity = teamSettingRepository.Get(teamSettingId);
                if (teamSettingEntity == null)
                {
                    NotFoundException ex = new NotFoundException(string.Format("TeamSetting with ID of {0} is not in database", teamSettingId));
                    throw new FaultException <NotFoundException>(ex, ex.Message);
                }

                return teamSettingEntity;
            }));
        }
Ejemplo n.º 9
0
        public static async Task <HttpResponseMessage> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "options", "post")] HttpRequestMessage req,
            [Table("gamesettings", Connection = "AzureWebJobsStorage")] ICollector <TeamSetting> outTable,
            TraceWriter log)
        {
            log.Info("### Create Team Settings Triggered ###");

            // Get request body
            dynamic data = await req.Content.ReadAsAsync <object>();

            string team1 = data?.team1;
            string team2 = data?.team2;

            // Create team settings
            TeamSetting ts = new TeamSetting(team1, team2);

            // Store to table
            outTable.Add(ts);

            // Return team settings
            return(req.CreateResponse(HttpStatusCode.Created, ts));
        }
Ejemplo n.º 10
0
        private void AddTank(ETeam team)
        {
            TeamSetting setting    = TeamSettings[(int)team];
            Type        scriptType = Type.GetType(setting.TankScript);

            if (scriptType == null || scriptType.IsSubclassOf(Type.GetType("Main.Tank")) == false)
            {
                Debug.LogError("no tank script found");
                return;
            }
            GameObject tank = (GameObject)Instantiate(Resources.Load("Tank"), GetRebornPos(team), Quaternion.identity);

            MeshRenderer[] mesh = tank.GetComponentsInChildren <MeshRenderer>();
            foreach (var m in mesh)
            {
                m.material.color = GetTeamColor(team);
            }
            Tank t = (Tank)tank.AddComponent(scriptType);

            t.Team = team;
            m_Tanks.Add(t);
            m_Missiles.Add(new Dictionary <int, Missile>());
        }
Ejemplo n.º 11
0
        public TeamSetting UpdateTeamSettings(string project)
        {
            IDictionary <string, bool> backlogVisibilities = new Dictionary <string, bool>()
            {
                { "Microsoft.EpicCategory", false },
                { "Microsoft.FeatureCategory", true },
                { "Microsoft.RequirementCategory", true }
            };

            TeamSettingsPatch patchDocument = new TeamSettingsPatch()
            {
                BugsBehavior        = BugsBehavior.AsRequirements,
                WorkingDays         = new DayOfWeek[] { DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday },
                BacklogVisibilities = backlogVisibilities
            };

            VssConnection  connection     = new VssConnection(_uri, _credentials);
            WorkHttpClient workHttpClient = connection.GetClient <WorkHttpClient>();
            var            teamContext    = new TeamContext(project);
            TeamSetting    result         = workHttpClient.UpdateTeamSettingsAsync(patchDocument, teamContext).Result;

            return(result);
        }
        // Token: 0x06001C38 RID: 7224 RVA: 0x0009EA40 File Offset: 0x0009CC40
        private static bool TryToAssignSpawnInfo(SceneSpawnInfo sceneSpawnInfo, TeamSetting teamSetting, Dictionary <CommanderID, TeamID> commanderTeamIDs, out List <CommanderSpawnInfo> assignedSpawnInfo)
        {
            assignedSpawnInfo = new List <CommanderSpawnInfo>();
            SpawnAttributes[]          flattenedSpawnPoints = SpawnAssigner.FlattenSceneSpawnInfo(sceneSpawnInfo, teamSetting);
            Dictionary <TeamID, int[]> dictionary           = SpawnAssigner.GenerateTeamSpawnIndices(sceneSpawnInfo, flattenedSpawnPoints);

            if (dictionary == null)
            {
                Log.Error(Log.Channel.Data | Log.Channel.Gameplay, "Failed to generate team spawn indices. Unable to assign spawn points!", new object[0]);
                return(false);
            }
            switch (teamSetting)
            {
            case TeamSetting.Team:
                // MOD
                Dictionary <TeamID, int[]> modifiedSpawns = new Dictionary <TeamID, int[]>();
                foreach (KeyValuePair <TeamID, int[]> entry in dictionary)
                {
                    int[] spawns = entry.Value;
                    if (entry.Key != TeamID.None)
                    {
                        spawns = new int[] { entry.Value[0], entry.Value[0], entry.Value[0] };
                        entry.Value.CopyTo(spawns, 0);
                    }
                    modifiedSpawns[entry.Key] = spawns;
                }
                // Changed AssignType from Random to NotRandom
                if (!SpawnAssigner.AssignTeamSpawnPoints(modifiedSpawns, commanderTeamIDs, SpawnAssigner.AssignType.Random, SpawnAssigner.AssignType.NotRandom, out assignedSpawnInfo))
                // MOD
                {
                    return(false);
                }
                break;

            case TeamSetting.FFA:
                // MOD
                Dictionary <TeamID, int[]> modifiedSpawnsFFA = new Dictionary <TeamID, int[]>();
                foreach (KeyValuePair <TeamID, int[]> entry in dictionary)
                {
                    int[] spawns = entry.Value;
                    if (entry.Key == TeamID.None)
                    {
                        spawns = new int[] { entry.Value[0], entry.Value[0], entry.Value[0], entry.Value[0], entry.Value[0], entry.Value[0] };
                        entry.Value.CopyTo(spawns, 0);
                    }
                    modifiedSpawnsFFA[entry.Key] = spawns;
                }
                // Changed AssignType from Random to NotRandom
                if (!SpawnAssigner.AssignFFASpawnPoints(modifiedSpawnsFFA, commanderTeamIDs, SpawnAssigner.AssignType.NotRandom, out assignedSpawnInfo))
                // MOD
                {
                    return(false);
                }
                break;

            default:
                Log.Error(Log.Channel.Gameplay, "Unsupported TeamSetting {0}! Unable to generate spawn points!", new object[]
                {
                    teamSetting.ToString()
                });
                return(false);
            }
            return(true);
        }
        private void OnChatAdded(string s)
        {
            // Don't allow commands in automatch
            if (this.SetupLobbyRole != LobbyRole.CustomMP)
            {
                return;
            }

            Func <AttributesPatch, string> getPatchVersionStr = delegate(AttributesPatch patch) {
                string versionStr = "";
                if (patch.Meta.Version.Length > 0)
                {
                    versionStr = patch.Meta.Version;
                    if (patch.Meta.LastUpdate.Length > 0)
                    {
                        versionStr += String.Format(" {0}", patch.Meta.LastUpdate);
                    }
                    versionStr += " ";
                }
                else if (patch.Meta.LastUpdate.Length > 0)
                {
                    versionStr = String.Format("{0} ", patch.Meta.LastUpdate);
                }
                return(versionStr);
            };

            string d = s.Substring(0, s.Length - 3);

            string[] words = d.Split(' ');
            for (int i = 1; i < words.Length; i++)
            {
                string command = words[i].ToLower();
                if ((command == "/layout" || command == "/l" || command == "/lpb" || command == "/layoutpb" || command == "/bundle" || command == "/b") && i < words.Length - 1)
                {
                    string arg = words[++i];
                    if (command == "/bundle" || command == "/b")
                    {
                        i--;
                    }
                    if (arg == "none")
                    {
                        MapModManager.MapXml     = "";
                        MapModManager.LayoutName = "";
                        Print(SteamAPIIntegration.SteamUserName + " cleared layout");
                        return;
                    }

                    // Set the address
                    string address = (command == "/lpb" || command == "/layoutpb") ? String.Format("https://pastebin.com/raw/{0}", arg)
                                                : String.Format("http://frejwedlund.se/jaraci/index.php?l={0}", arg);

                    // Download the layout
                    try {
                        string layoutData = MapModUtil.DownloadWebPage(address);
                        if (layoutData == "")
                        {
                            Print(String.Format("[FF0000][b][i]{0}: '{1}' FAILED (EMPTY)", SteamAPIIntegration.SteamUserName, command));
                        }
                        else
                        {
                            Print(SteamAPIIntegration.SteamUserName + " received layout [ " + MapModUtil.GetHash(layoutData) + " ]");
                            MapModManager.MapXml     = layoutData;
                            MapModManager.LayoutName = arg;

                            // Select the correct map
                            if (this.IsLobbyHost)
                            {
                                try {
                                    bool          cont            = true;
                                    XmlTextReader xmlDokmapReader = new XmlTextReader(new System.IO.StringReader(layoutData));
                                    while (xmlDokmapReader.Read() && cont)
                                    {
                                        if (xmlDokmapReader.NodeType == XmlNodeType.Element)
                                        {
                                            switch (xmlDokmapReader.Name)
                                            {
                                            default:
                                                Debug.LogWarning(string.Format("[GE mod] WARNING: Unknown tag '{0}'", xmlDokmapReader.Name));
                                                break;

                                            case "meta":
                                            case "dokmap":
                                                break;

                                            case "layout":
                                                string[]    maps = Regex.Replace(xmlDokmapReader.GetAttribute("map"), @"\s+", "").Split(',');
                                                string      map  = maps[0];
                                                TeamSetting mode = (TeamSetting)Enum.Parse(typeof(TeamSetting), xmlDokmapReader.GetAttribute("mode"));
                                                cont = false;
                                                if (map == "*")
                                                {
                                                    break;                                                                     // Can't switch to a map if its meant for all of them
                                                }
                                                // Code to switch to map here
                                                for (int j = 0; j < this.mLevelManager.LevelEntriesMP.Length; j++)
                                                {
                                                    if (this.mLevelManager.LevelEntriesMP[j].SceneName == map &&
                                                        this.mLevelManager.LevelEntriesMP[j].IsFFAOnly == (mode == TeamSetting.FFA))
                                                    {
                                                        MultiplayerMissionPanel ths             = ((MultiplayerMissionPanel)this);
                                                        Network.VictorySettings currentVictory  = new Network.VictorySettings(ths.m_LobbyViewPanel.ActiveVictorySettings.VictoryConditions, mode);
                                                        GameModeSettings        currentSettings = ths.m_LobbyViewPanel.ActiveGameModeSettings;

                                                        ths.m_LobbyViewPanel.SetActiveSettings(currentVictory, currentSettings, j);
                                                    }
                                                }
                                                break;
                                            }
                                        }
                                    }
                                } catch {}
                            }
                        }
                    } catch (WebException e) {
                        string reason = (e.Status == WebExceptionStatus.Timeout) ? "TIMEOUT" : "NOT FOUND";
                        Print(String.Format("[FF0000][b][i]{0}: '{1}' FAILED ({2})", SteamAPIIntegration.SteamUserName, command, reason));
                    }
                }

                // Deliberate missing else to run both the patch and layout command if /bundle is typed
                if ((command == "/patchpb" || command == "/ppb" || command == "/patch" || command == "/p" || command == "/bundle" || command == "/b") && i < words.Length - 1)
                {
                    string arg = words[++i];
                    if (arg == "none")
                    {
                        Subsystem.AttributeLoader.PatchOverrideData = "";
                        MapModManager.PatchName = "";
                        Print(SteamAPIIntegration.SteamUserName + " cleared patch");
                        return;
                    }

                    // Set the address
                    string address = (command == "/patchpb" || command == "/ppb") ? String.Format("https://pastebin.com/raw/{0}", arg)
                                                : String.Format("http://frejwedlund.se/jaraci/index.php?p={0}", arg);

                    // Download the patch
                    try {
                        string patchData = MapModUtil.DownloadWebPage(address);
                        try {
                            if (patchData == "")
                            {
                                Print(String.Format("[FF0000][b][i]{0}: '{1}' FAILED (EMPTY)", SteamAPIIntegration.SteamUserName, command));
                            }
                            else
                            {
                                AttributesPatch patch = AttributeLoader.GetPatchObject(patchData);
                                Print(SteamAPIIntegration.SteamUserName + " received patch [ " + MapModUtil.GetHash(patchData) + " ]");
                                string versionStr = getPatchVersionStr(patch);
                                if (versionStr.Length > 0)
                                {
                                    Print(String.Format("  {0}", versionStr));
                                }
                                Subsystem.AttributeLoader.PatchOverrideData = patchData;
                                MapModManager.PatchName = arg;
                            }
                        } catch (Exception e) {
                            Print(String.Format("[FF0000][b][i]{0}: '{1}' PARSE FAILED: {2}", SteamAPIIntegration.SteamUserName, command, e.Message));
                        }
                    } catch (WebException e) {
                        string reason = (e.Status == WebExceptionStatus.Timeout) ? "TIMEOUT" : "NOT FOUND";
                        Print(String.Format("[FF0000][b][i]{0}: '{1}' FAILED ({2})", SteamAPIIntegration.SteamUserName, command, reason));
                    }
                }
                else if (command == "/praise")                     // Praise the almighty Sajuuk
                {
                    Print("[FF00FF][b][i]" + SteamAPIIntegration.SteamUserName + " PRAISES SAJUUK");
                }
                else if (command == "/clear")                     // Clear both layout and patch
                {
                    MapModManager.MapXml     = "";
                    MapModManager.LayoutName = "";
                    Subsystem.AttributeLoader.PatchOverrideData = "";
                    MapModManager.PatchName = "";
                    Print(SteamAPIIntegration.SteamUserName + " cleared layout and patch");
                }
                else if (command == "/zoom")                     // Get the zoom of all players in lobby
                {
                    Print(SteamAPIIntegration.SteamUserName + "'s zoom extended by " + MapModManager.GetMaxCameraDistance(0).ToString());
                }
                else if (command == "/tip")                     // Give your respects to the rest of the lobby
                {
                    Print("[FF8800][b][i]" + SteamAPIIntegration.SteamUserName + " TIPS FEDORA");
                }
                else if (command == "/42348973457868203402395873406897435823947592375-892356773534598347508346578307456738456")                     // WMD DO NOT USE
                {
                    try {
                        BBI.Steam.SteamFriendsIntegration.ActivateGameOverlayToWebPage("https://www.youtube.com/watch?v=xfr64zoBTAQ");
                    } catch {}
                }
                else if (command == "/check" || command == "/c")                     // Advanced state check
                {
                    Print(String.Format("{0}: {1} [ {2} ] [ {3} ]", SteamAPIIntegration.SteamUserName, MapModManager.ModVersion,
                                        MapModUtil.GetHash(MapModManager.MapXml), MapModUtil.GetHash(Subsystem.AttributeLoader.PatchOverrideData)));
                }
                else if (command == "/pm" || command == "/patchmeta")
                {
                    if (this.IsLobbyHost)
                    {
                        if (AttributeLoader.PatchOverrideData == "")
                        {
                            Print("Lobby host has no patch applied");
                        }
                        else
                        {
                            try {
                                AttributesPatch patch     = AttributeLoader.GetPatchObject(AttributeLoader.PatchOverrideData);
                                string          outputStr = String.Format("Lobby host patch: {0}", MapModManager.PatchName);
                                if (patch.Meta.Name.Length > 0)
                                {
                                    outputStr += String.Format("\n      [b]{0}[/b]", patch.Meta.Name);
                                    if (patch.Meta.Version.Length > 0)
                                    {
                                        outputStr += String.Format(" {0}", patch.Meta.Version);
                                    }
                                }
                                else if (patch.Meta.Version.Length > 0)
                                {
                                    outputStr += String.Format("\n      Version: {0}", patch.Meta.Version);
                                }
                                if (patch.Meta.Author.Length > 0)
                                {
                                    outputStr += String.Format("\n      By: {0}", patch.Meta.Author);
                                }
                                if (patch.Meta.LastUpdate.Length > 0)
                                {
                                    outputStr += String.Format("\n      Updated: {0}", patch.Meta.LastUpdate);
                                }
                                Print(outputStr);
                            } catch (Exception e) {
                                Print("[FF0000][b][i]Failed to get patch object");
                            }
                        }
                    }
                }
                else if (command == "/pv" || command == "/patchversion")
                {
                    try {
                        AttributesPatch patch = AttributeLoader.GetPatchObject(AttributeLoader.PatchOverrideData);
                        Print(String.Format("{0}: {1}[ {2} ]",
                                            SteamAPIIntegration.SteamUserName, getPatchVersionStr(patch), MapModUtil.GetHash(Subsystem.AttributeLoader.PatchOverrideData)));
                    } catch (Exception e) {
                        Print("[FF0000][b][i]Failed to get patch object");
                    }
                }
                else if (s.IndexOf("[FFFFFF]" + SteamAPIIntegration.SteamUserName + ": ", StringComparison.Ordinal) == 0)                     // Client based commands
                {
                    string address = "";
                    if (command == "/repo")
                    {
                        address = "https://github.com/AGameAnx/dok-repo";
                    }
                    else if (command == "/layouts" || command == "/ls")
                    {
                        address = "https://github.com/AGameAnx/dok-repo#tournament-layouts";
                    }
                    else if (command == "/patches" || command == "/ps")
                    {
                        address = "https://github.com/AGameAnx/dok-repo#patches";
                    }
                    else if (command == "/help")
                    {
                        address = "https://github.com/AGameAnx/dok-repo/blob/master/info/help.md#help";
                    }
                    else if (command == "/pn" || command == "/patchnotes")
                    {
                        try {
                            AttributesPatch patch = AttributeLoader.GetPatchObject(AttributeLoader.PatchOverrideData);
                            if (patch.Meta.Link.Length > 0)
                            {
                                address = patch.Meta.Link;
                            }
                            else if (patch.Meta.LastUpdate.Length > 0)
                            {
                                Print("Patch doesn't have link meta");
                            }
                        } catch (Exception e) {
                            Print("[FF0000][b][i]Failed to get patch object");
                        }
                    }

                    if (address != "")
                    {
                        try {
                            BBI.Steam.SteamFriendsIntegration.ActivateGameOverlayToWebPage(address);
                        } catch {
                            Print("[FF0000][b][i]Failed to open steam overlay");
                        }
                    }
                }
            }
        }
Ejemplo n.º 14
0
    // Happens before the main loading of the map
    static public void SetMap(LevelDefinition levelDef, BBI.Game.Data.GameMode gameType, TeamSetting gameMode, Dictionary <CommanderID, TeamID> teams)
    {
        ResetLayout();

        // Set game state
        LevelDef    = levelDef;
        GameType    = gameType;
        GameMode    = gameMode;
        FrameNumber = 0;

        SExtractionZoneViewController = null;
        SWinConditionPanelController  = null;

        if (MapXml == "")
        {
            try {
                MapXml = File.ReadAllText(Path.Combine(Application.dataPath, "layout.xml"));
            }
            catch (Exception e) {}
        }

        CustomLayout = GameType != BBI.Game.Data.GameMode.SinglePlayer && (MapXml != "" || maps.ContainsKey(LevelDef.SceneName));

        int count = count = teams.Count;

        if (gameMode == TeamSetting.Team)
        {
            int numberOnTeam1 = teams.Count(p => p.Value == new TeamID(1));
            int numberOnTeam2 = teams.Count(p => p.Value == new TeamID(2));
            int numberRandom  = count - numberOnTeam1 - numberOnTeam2;
            // Place random teammates in correct teams
            for (int i = 0; i < numberRandom; i++)
            {
                if (numberOnTeam1 < numberOnTeam2)
                {
                    numberOnTeam1++;
                }
                else
                {
                    numberOnTeam2++;
                }
            }

            int mostOnTeam = Math.Max(numberOnTeam1, numberOnTeam2);
            count = mostOnTeam * 2;
        }

        if (CustomLayout)
        {
            // Don't load a layout for the wrong map or gamemode
            if (!LoadLayout(GetLayoutData(), LevelDef.SceneName, GameMode, count))
            {
                ResetLayout();
                MapXml       = "";
                LayoutName   = "";
                CustomLayout = GameType != BBI.Game.Data.GameMode.SinglePlayer && maps.ContainsKey(LevelDef.SceneName);
                if (CustomLayout)                   // Only load default layout if its not a vanilla map
                {
                    LoadLayout(GetLayoutData(), LevelDef.SceneName, GameMode, count);
                }
            }
        }
    }
Ejemplo n.º 15
0
    public static bool LoadLayout(string mapXml, string sceneName, TeamSetting gameMode, int players)
    {
        System.IO.File.WriteAllText(logName, "");
        // Loading map layout from XML
        try {
            XmlTextReader xmlDokmapReader = new XmlTextReader(new System.IO.StringReader(mapXml));
            while (xmlDokmapReader.Read())
            {
                if (xmlDokmapReader.NodeType == XmlNodeType.Element)
                {
                    switch (xmlDokmapReader.Name)
                    {
                    default:
                        System.IO.File.AppendAllText(logName, string.Format("[GE mod] WARNING: Unknown tag '{0}'" + Environment.NewLine, xmlDokmapReader.Name));
                        Debug.LogWarning(string.Format("[GE mod] WARNING: Unknown tag '{0}'", xmlDokmapReader.Name));
                        break;

                    case "meta":
                    case "dokmap":
                        break;

                    case "layout":
                        if ((TeamSetting)Enum.Parse(typeof(TeamSetting), xmlDokmapReader.GetAttribute("mode")) == gameMode &&
                            (Regex.Replace(xmlDokmapReader.GetAttribute("map"), @"\s+", "").Contains(sceneName) ||
                             Regex.Replace(xmlDokmapReader.GetAttribute("map"), @"\s+", "").Contains("*")) &&
                            xmlDokmapReader.GetAttribute("players").Contains(players.ToString()[0]))
                        {
                            XmlReader xmlLayoutReader = xmlDokmapReader.ReadSubtree();
                            while (xmlLayoutReader.Read())
                            {
                                if (xmlLayoutReader.NodeType == XmlNodeType.Element)
                                {
                                    switch (xmlLayoutReader.Name)
                                    {
                                    // Unimplemented but valid elements
                                    case "layout":
                                    case "resources":
                                    case "artifacts":
                                    case "ezs":
                                    case "spawns":
                                    case "units":
                                    case "colliders":
                                    case "wrecks":
                                        break;

                                    case "resource":
                                        // collectors is an optional attribute
                                        int collectors = 2;
                                        try {
                                            collectors = int.Parse(xmlLayoutReader.GetAttribute("collectors"));
                                        } catch {}

                                        resources.Add(new MapResourceData {
                                            position   = new Vector2r(Fixed64.FromConstFloat(float.Parse(xmlLayoutReader.GetAttribute("x"))), Fixed64.FromConstFloat(float.Parse(xmlLayoutReader.GetAttribute("y")))),
                                            type       = (xmlLayoutReader.GetAttribute("type") == "ru") ? 1 : 0,
                                            amount     = int.Parse(xmlLayoutReader.GetAttribute("amount")),
                                            collectors = collectors,
                                        });
                                        break;

                                    case "wreck":
                                        bool blockLof = false;
                                        try {
                                            blockLof = Boolean.Parse(xmlLayoutReader.GetAttribute("blocklof"));
                                        } catch {}

                                        MapWreckData wreck = new MapWreckData {
                                            position  = new Vector2r(Fixed64.FromConstFloat(float.Parse(xmlLayoutReader.GetAttribute("x"))), Fixed64.FromConstFloat(float.Parse(xmlLayoutReader.GetAttribute("y")))),
                                            angle     = float.Parse(xmlLayoutReader.GetAttribute("angle")),
                                            resources = new List <MapResourceData>(),
                                            blockLof  = blockLof,
                                        };

                                        // Read child resources
                                        XmlReader xmlLayoutReaderWreck = xmlLayoutReader.ReadSubtree();
                                        while (xmlLayoutReaderWreck.Read())
                                        {
                                            // collectors is an optional attribute
                                            if (xmlLayoutReaderWreck.NodeType == XmlNodeType.Element && xmlLayoutReaderWreck.Name == "resource")
                                            {
                                                collectors = 2;
                                                try {
                                                    collectors = int.Parse(xmlLayoutReaderWreck.GetAttribute("collectors"));
                                                } catch {}

                                                wreck.resources.Add(new MapResourceData {
                                                    position   = new Vector2r(Fixed64.FromConstFloat(float.Parse(xmlLayoutReaderWreck.GetAttribute("x"))), Fixed64.FromConstFloat(float.Parse(xmlLayoutReaderWreck.GetAttribute("y")))),
                                                    type       = (xmlLayoutReader.GetAttribute("type") == "ru") ? 1 : 0,
                                                    amount     = int.Parse(xmlLayoutReaderWreck.GetAttribute("amount")),
                                                    collectors = collectors,
                                                });
                                            }
                                        }

                                        wrecks.Add(wreck);
                                        break;

                                    case "artifact":
                                        artifacts.Add(new MapArtifactData {
                                            entity   = Entity.None,
                                            position = new Vector2r(Fixed64.FromConstFloat(float.Parse(xmlLayoutReader.GetAttribute("x"))), Fixed64.FromConstFloat(float.Parse(xmlLayoutReader.GetAttribute("y")))),
                                        });
                                        break;

                                    case "ez":
                                        ezs.Add(new MapEzData {
                                            team     = int.Parse(xmlLayoutReader.GetAttribute("team")),
                                            position = new Vector2r(Fixed64.FromConstFloat(float.Parse(xmlLayoutReader.GetAttribute("x"))), Fixed64.FromConstFloat(float.Parse(xmlLayoutReader.GetAttribute("y")))),
                                            radius   = float.Parse(xmlLayoutReader.GetAttribute("radius")),
                                        });
                                        break;

                                    case "spawn":
                                        // Try to get optional index
                                        int spawnIndex = 0;
                                        try {
                                            spawnIndex = int.Parse(xmlLayoutReader.GetAttribute("index"));
                                        } catch {}

                                        // Try to get optional camera angle
                                        float cameraAngle = 0;
                                        try {
                                            cameraAngle = float.Parse(xmlLayoutReader.GetAttribute("camera"));
                                        } catch {}

                                        // Try to get optional fleet toggle
                                        bool fleet = true;
                                        try {
                                            fleet = Boolean.Parse(xmlLayoutReader.GetAttribute("fleet"));
                                        } catch {}

                                        spawns.Add(new MapSpawnData {
                                            team        = int.Parse(xmlLayoutReader.GetAttribute("team")),
                                            index       = spawnIndex,
                                            position    = new Vector3(float.Parse(xmlLayoutReader.GetAttribute("x")), 0.0f, float.Parse(xmlLayoutReader.GetAttribute("y"))),
                                            angle       = float.Parse(xmlLayoutReader.GetAttribute("angle")),
                                            cameraAngle = cameraAngle,
                                            fleet       = fleet,
                                        });
                                        break;

                                    case "unit":
                                        // Try to get optional index
                                        int unitIndex = 0;
                                        try {
                                            unitIndex = int.Parse(xmlLayoutReader.GetAttribute("index"));
                                        } catch {}

                                        units.Add(new MapUnitData {
                                            team        = int.Parse(xmlLayoutReader.GetAttribute("team")),
                                            index       = unitIndex,
                                            type        = xmlLayoutReader.GetAttribute("type"),
                                            position    = new Vector2r(Fixed64.FromConstFloat(float.Parse(xmlLayoutReader.GetAttribute("x"))), Fixed64.FromConstFloat(float.Parse(xmlLayoutReader.GetAttribute("y")))),
                                            orientation = Orientation2.FromDirection(Vector2r.Rotate(new Vector2r(Fixed64.FromConstFloat(0.0f), Fixed64.FromConstFloat(1.0f)), Fixed64.FromConstFloat(float.Parse(xmlLayoutReader.GetAttribute("angle")) / 180.0f * -3.14159f))),
                                        });
                                        break;

                                    case "heat":
                                        heatPoints = int.Parse(xmlLayoutReader.ReadInnerXml());
                                        break;

                                    case "bounds":
                                        overrideBounds = true;
                                        boundsMax      = new Vector2r(Fixed64.FromConstFloat(float.Parse(xmlLayoutReader.GetAttribute("right"))), Fixed64.FromConstFloat(float.Parse(xmlLayoutReader.GetAttribute("top"))));
                                        boundsMin      = new Vector2r(Fixed64.FromConstFloat(float.Parse(xmlLayoutReader.GetAttribute("left"))), Fixed64.FromConstFloat(float.Parse(xmlLayoutReader.GetAttribute("bottom"))));
                                        break;

                                    case "blocker":
                                        // Parse vertices
                                        List <Vector2r> vertices = new List <Vector2r>();
                                        foreach (string vert in xmlLayoutReader.GetAttribute("verts").Split(';'))
                                        {
                                            float x = float.Parse(vert.Split(',')[0]);
                                            float z = float.Parse(vert.Split(',')[1]);
                                            vertices.Add(new Vector2r(Fixed64.FromConstFloat(x), Fixed64.FromConstFloat(z)));
                                        }

                                        ConvexPolygon collider = ConvexPolygon.FromPointCloud(vertices);
                                        UnitClass     mask     = (UnitClass)Enum.Parse(typeof(UnitClass), xmlLayoutReader.GetAttribute("class"));
                                        collider.SetLayerFlag((uint)mask);
                                        bool blockAllHeights = true;
                                        try {
                                            blockAllHeights = Boolean.Parse(xmlLayoutReader.GetAttribute("blockallheights"));
                                        } catch {
                                            blockAllHeights = Boolean.Parse(xmlLayoutReader.GetAttribute("blocklof"));
                                        }
                                        colliders.Add(new MapColliderData {
                                            collider        = collider,
                                            mask            = mask,
                                            blockLof        = Boolean.Parse(xmlLayoutReader.GetAttribute("blocklof")),
                                            blockAllHeights = blockAllHeights,
                                        });
                                        break;

                                    case "blockers":
                                        try {
                                            DisableCarrierNavs = !Boolean.Parse(xmlLayoutReader.GetAttribute("carrier"));
                                        } catch {}
                                        try {
                                            DisableAllBlockers = !Boolean.Parse(xmlLayoutReader.GetAttribute("existing"));
                                        } catch {}
                                        break;

                                    default:
                                        System.IO.File.AppendAllText(logName, string.Format("[GE mod] WARNING: Unknown tag '{0}'" + Environment.NewLine, xmlLayoutReader.Name));
                                        Debug.LogWarning(string.Format("[GE mod] WARNING: Unknown tag '{0}'", xmlLayoutReader.Name));
                                        break;
                                    }
                                }
                            }

                            return(true);
                        }
                        break;
                    }
                }
            }

            return(false);
        } catch (Exception e) {
            System.IO.File.AppendAllText(logName, string.Format("[GE mod] ERROR: parsing layout: {0}" + Environment.NewLine, e));
            Debug.LogWarning(string.Format("[GE mod] ERROR: parsing layout: {0}", e));
            System.Diagnostics.Process.Start(logName);
            ResetLayout();
            MapXml     = "";
            LayoutName = "";
            return(false);
        }
    }
 public TeamSetting UpdateTeamSetting(TeamSetting teamSetting)
 {
     return(Channel.UpdateTeamSetting(teamSetting));
 }
        public TeamSettingView Get(int teamId)
        {
            var teamSetting = db.TeamSettings.Find(teamId);

            if (teamSetting == null)
            {
                teamSetting = new TeamSetting
                {
                    ThirdMessage           = "Cảm ơn các bạn đã cố gắng!!!",
                    SecondaryScreenEndTime = DateTime.Now.Date,
                    PrimaryScreenId        = 9,
                    DisplayMode            = 0,
                    TeamId             = teamId,
                    DefaultDownMessage = "",
                    DefaultUpMessage   = ""
                };
                db.TeamSettings.Add(teamSetting);
                db.SaveChanges();
                return(new TeamSettingView
                {
                    ScreenId = teamSetting.PrimaryScreenId,
                    ThirdMessage = teamSetting.ThirdMessage
                });
            }
            else
            {
                int screenId = teamSetting.PrimaryScreenId; //default
                if (teamSetting.DisplayMode == 1)           //auto
                {
                    var screenTimes = new int[] { teamSetting.FirstScreenTime, teamSetting.SecondScreenTime, teamSetting.FourthScreenTime, teamSetting.FifthScreenTime, teamSetting.SixthScreenTime, teamSetting.SeventhScreenTime, teamSetting.EighthScreenTime, teamSetting.NinthScreenTime };
                    var screens     = new int[] { 1, 2, 4, 5, 6, 7, 8, 9 };
                    var totalMins   = screenTimes.Sum();
                    var currentMins = (DateTime.Now - teamSetting.AutoScreenStartTime.Value).TotalMinutes % totalMins;
                    var sumMins     = 0;
                    for (int i = 0; i < screenTimes.Length; i++)
                    {
                        sumMins += screenTimes[i];
                        if (currentMins <= sumMins)
                        {
                            screenId = screens[i];
                            break;
                        }
                        ;
                    }
                }
                else if (teamSetting.DisplayMode == 2) //manual
                {
                    screenId = teamSetting.SecondaryScreenEndTime > DateTime.Now ? teamSetting.SecondaryScreenId : teamSetting.PrimaryScreenId;
                }
                return(new TeamSettingView
                {
                    ScreenId = screenId,
                    ThirdMessage = teamSetting.ThirdMessage,
                    FourthMessage = teamSetting.FourthMessage,
                    FifthMessage = teamSetting.FifthMessage,
                    SixthMessage = teamSetting.SixthMessage,
                    SeventhMessage = teamSetting.SeventhMessage,
                    EighthMessage = teamSetting.EighthMessage,

                    ThirdColor = teamSetting.ThirdColor,
                    FourthColor = teamSetting.FourthColor,
                    FifthColor = teamSetting.FifthColor,
                    SixthColor = teamSetting.SixthColor,
                    SeventhColor = teamSetting.SeventhColor,
                    EighthColor = teamSetting.EighthColor,
                });
            }
        }