Esempio n. 1
0
 public UnitModelCount(UnitModelBase unit, int count)
 {
     ID    = unit.ID;
     Name  = unit.Name;
     Race  = unit.Race;
     Count = count;
 }
Esempio n. 2
0
        public List <string> GetUpgrades(DbBreakpoint bp)
        {
            List <string> upgrades = new List <string>();

            if (bp == null || String.IsNullOrEmpty(bp.dbUpgradesString))
            {
                return(upgrades);
            }
            foreach (string upgradestring in bp.dbUpgradesString.Split("|"))
            {
                int id = 0;
                if (int.TryParse(upgradestring, out id))
                {
                    UnitModelBase upgrade = DSdata.Upgrades.FirstOrDefault(s => s.ID == id);
                    if (upgrade != null)
                    {
                        upgrades.Add(upgrade.Name);
                    }
                }
                else
                {
                    upgrades.Add(upgradestring);
                }
            }
            return(upgrades);
        }
Esempio n. 3
0
        public Dictionary <string, int> GetUnits(DbBreakpoint bp)
        {
            Dictionary <string, int> units = new Dictionary <string, int>();

            if (bp == null || String.IsNullOrEmpty(bp.dsUnitsString))
            {
                return(units);
            }
            foreach (string unitstring in bp.dsUnitsString.Split("|"))
            {
                var ent = unitstring.Split(",");
                if (!units.ContainsKey(ent[0]))
                {
                    units[ent[0]] = int.Parse(ent[1]);
                }
                else
                {
                    units[ent[0]] += int.Parse(ent[1]);
                }
            }
            foreach (var ent in units.Keys.ToArray())
            {
                int id = 0;
                if (int.TryParse(ent, out id))
                {
                    UnitModelBase bunit = DSdata.Units.SingleOrDefault(s => s.ID == id);
                    if (bunit != null)
                    {
                        units.Add(bunit.Name, units[ent]);
                        units.Remove(ent);
                    }
                }
            }
            return(units.OrderByDescending(o => o.Value).ToDictionary(p => p.Key, p => p.Value));
        }
Esempio n. 4
0
        public List <UnitModelCount> GetUnits()
        {
            List <UnitModelCount> Units = new List <UnitModelCount>();

            if (!String.IsNullOrEmpty(dsUnitsString))
            {
                foreach (string unitstring in dsUnitsString.Split("|"))
                {
                    var ent = unitstring.Split(",");
                    if (ent.Length == 2)
                    {
                        int           id   = 0;
                        UnitModelBase unit = null;
                        if (int.TryParse(ent[0], out id))
                        {
                            unit = DSdata.Units.FirstOrDefault(x => x.ID == id);
                            if (unit == null)
                            {
                                unit = new UnitModelBase(Fix.UnitName(ent[0]), "");
                            }
                        }
                        else
                        {
                            unit = new UnitModelBase(Fix.UnitName(ent[0]), "");
                        }

                        int c = 0;
                        if (int.TryParse(ent[1], out c))
                        {
                            Units.Add(new UnitModelCount(unit, c));
                        }
                    }
                }
            }
            return(Units);
        }
Esempio n. 5
0
        public List <UnitModel> GetDbUnits(DSPlayer pl, DbBreakpoint bp, int objective)
        {
            List <UnitModel> Units = new List <UnitModel>();

            if (bp == null || String.IsNullOrEmpty(bp.dbUnitsString))
            {
                return(Units);
            }

            foreach (string unitstring in bp.dbUnitsString.Split("|"))
            {
                var       ent  = unitstring.Split(",");
                UnitModel unit = new UnitModel();
                unit.Name = ent[0];
                unit.Race = pl.RACE;
                unit.Pos  = new Vector2(int.Parse(ent[1]), int.Parse(ent[2]));
                int id = 0;
                if (int.TryParse(ent[0], out id))
                {
                    UnitModelBase bunit = DSdata.Units.FirstOrDefault(f => f.ID == id);
                    if (bunit != null)
                    {
                        unit.Name = bunit.Name;
                    }
                }

                Vector2 vec  = Fix.RotatePoint(unit.Pos, center, -45);
                float   newx = 0;
                float   newy = 0;

                // Rotated Nexus/CC
                // 1
                // 77.08831, 114.34315
                // 173.25484, 120

                // 2
                // 77.08831, 125.656685
                // 167.59798, 125.656685


                if (pl.REALPOS > 3)
                {
                    newx = (vec.X - 62.23907f) / 2;
                }
                else
                {
                    newx = (vec.X - 176.79037f) / 2;
                }

                newy = vec.Y - 107.97919f;

                if (objective == 2)
                {
                    newy -= 11.313535f / 2;
                    newx += 5.65686f / 2;
                }
                unit.RotatePos = new Vector2(newx, newy);

                Units.Add(unit);
            }

            return(Units);
        }