コード例 #1
0
 internal Battle()
 {
     Bots          = new List <BotBattleStatus>();
     Details       = new BattleDetails();
     ModOptions    = new Dictionary <string, string>();
     Rectangles    = new Dictionary <int, BattleRect>();
     DisabledUnits = new List <string>();
     Password      = "******";
     Nat           = NatMode.None;
     Users         = new List <UserBattleStatus>();
 }
コード例 #2
0
        public Battle(string engineVersion, string password, int port, int maxplayers, int rank, Map map, string title, Mod mod, BattleDetails details) : this()
        {
            if (!String.IsNullOrEmpty(password))
            {
                Password = password;
            }
            if (port == 0)
            {
                HostPort = 8452;
            }
            else
            {
                HostPort = port;
            }
            try {
                var ports = IPGlobalProperties.GetIPGlobalProperties().GetActiveUdpListeners().OrderBy(x => x.Port).Select(x => x.Port).ToList();
                if (ports.Contains(HostPort))
                {
                    var blockedPort = HostPort;
                    while (ports.Contains(HostPort))
                    {
                        HostPort++;
                    }
                    Trace.TraceWarning("Host port {0} was used, using backup port {1}", blockedPort, HostPort);
                }
            } catch {}



            EngineVersion = engineVersion;
            MaxPlayers    = maxplayers;
            Rank          = rank;
            this.map      = map;
            MapName       = map.Name;
            MapHash       = 0;
            Title         = title;
            this.mod      = mod;
            ModName       = mod.Name;
            ModHash       = 0;
            if (details != null)
            {
                Details = details;
            }
        }
コード例 #3
0
 internal Battle()
 {
     Bots = new List<BotBattleStatus>();
     Details = new BattleDetails();
     ModOptions = new Dictionary<string, string>();
     Rectangles = new Dictionary<int, BattleRect>();
     DisabledUnits = new List<string>();
     Password = "******";
     Nat = NatMode.None;
     Users = new List<UserBattleStatus>();
 }
コード例 #4
0
        public static void ScriptAddTeam(StringBuilder script, int teamNum, List<StartPos> positions, int userNum, UserBattleStatus status, Mod mod, BattleDetails Details)
        {
            // BOT TEAM
            script.AppendFormat("  [TEAM{0}]\n", teamNum);
            script.AppendLine("  {");
            script.AppendFormat("     TeamLeader={0};\n", userNum);
            script.AppendFormat("     AllyTeam={0};\n", status.AllyNumber);
            script.AppendFormat(CultureInfo.InvariantCulture,"     RGBColor={0:F5} {1:F5} {2:F5};\n",
                                (status.TeamColor & 255)/255.0,
                                ((status.TeamColor >> 8) & 255)/255.0,
                                ((status.TeamColor >> 16) & 255)/255.0);
            var side = "mission";
            if (mod.Sides.Length > status.Side) side = mod.Sides[status.Side];
            script.AppendFormat("     Side={0};\n", side);

            script.AppendFormat("     Handicap={0};\n", 0);
            if (mod.IsMission)
            {
                script.AppendFormat("      StartPosX={0};\n", 0);
                script.AppendFormat("      StartPosZ={0};\n", 0);
            }
            else
            {
                if ((Details.StartPos == BattleStartPos.Random || Details.StartPos == BattleStartPos.Fixed) && positions.Count > teamNum)
                {
                    var pos = positions[teamNum];
                    script.AppendFormat("      StartPosX={0};\n", pos.x);
                    script.AppendFormat("      StartPosZ={0};\n", pos.z);
                }
            }
            script.AppendLine("  }");
        }
コード例 #5
0
        public Battle(string engineVersion, string password, int port, int maxplayers, int rank, Map map, string title, Mod mod, BattleDetails details): this()
        {
            if (!String.IsNullOrEmpty(password)) Password = password;
            if (port == 0) HostPort = 8452; else HostPort = port;
            try {
                var ports = IPGlobalProperties.GetIPGlobalProperties().GetActiveUdpListeners().OrderBy(x => x.Port).Select(x=>x.Port).ToList();
                if (ports.Contains(HostPort)) {
                    var blockedPort = HostPort;
                    while (ports.Contains(HostPort)) HostPort++;
                    Trace.TraceWarning("Host port {0} was used, using backup port {1}", blockedPort, HostPort);
                }
            } catch {}




            EngineVersion = engineVersion;
            MaxPlayers = maxplayers;
            Rank = rank;
            this.map = map;
            MapName = map.Name;
            MapHash = 0;
            Title = title;
            this.mod = mod;
            ModName = mod.Name;
            ModHash = 0;
            if (details != null) Details = details;
        }
コード例 #6
0
        public static void ScriptAddTeam(StringBuilder script, int teamNum, List <StartPos> positions, int userNum, UserBattleStatus status, Mod mod, BattleDetails Details)
        {
            // BOT TEAM
            script.AppendFormat("  [TEAM{0}]\n", teamNum);
            script.AppendLine("  {");
            script.AppendFormat("     TeamLeader={0};\n", userNum);
            script.AppendFormat("     AllyTeam={0};\n", status.AllyNumber);
            script.AppendFormat(CultureInfo.InvariantCulture, "     RGBColor={0:F5} {1:F5} {2:F5};\n",
                                (status.TeamColor & 255) / 255.0,
                                ((status.TeamColor >> 8) & 255) / 255.0,
                                ((status.TeamColor >> 16) & 255) / 255.0);
            var side = "mission";

            if (mod.Sides.Length > status.Side)
            {
                side = mod.Sides[status.Side];
            }
            script.AppendFormat("     Side={0};\n", side);

            script.AppendFormat("     Handicap={0};\n", 0);
            if (mod.IsMission)
            {
                script.AppendFormat("      StartPosX={0};\n", 0);
                script.AppendFormat("      StartPosZ={0};\n", 0);
            }
            else
            {
                if ((Details.StartPos == BattleStartPos.Random || Details.StartPos == BattleStartPos.Fixed) && positions.Count > teamNum)
                {
                    var pos = positions[teamNum];
                    script.AppendFormat("      StartPosX={0};\n", pos.x);
                    script.AppendFormat("      StartPosZ={0};\n", pos.z);
                }
            }
            script.AppendLine("  }");
        }
コード例 #7
0
 public void UpdateBattleDetails(BattleDetails bd)
 {
     var objList = new List<object>();
     con.SendCommand("SETSCRIPTTAGS", bd.GetParamList());
 }
コード例 #8
0
 void OnSetScriptTags(string[] args)
 {
     var bd = new BattleDetails();
     bd.Parse(Utils.Glue(args), MyBattle.ModOptions);
     MyBattle.Details = bd;
     MyBattle.ScriptTags.AddRange(args);
     BattleDetailsChanged(this, new TasEventArgs(args));
 }