Ejemplo n.º 1
0
        public TestOutnumber()
        {
            BaseBattleStats baseBattleStats = new BaseBattleStats((ushort)UnitType.TestSwordsman,
                                                                  1,
                                                                  WeaponType.Sword,
                                                                  WeaponClass.Basic,
                                                                  ArmorType.Ground,
                                                                  ArmorClass.Leather,
                                                                  70,
                                                                  30,
                                                                  1,
                                                                  9,
                                                                  2,
                                                                  9,
                                                                  10,
                                                                  30,
                                                                  0);
            IBaseUnitStats baseUnitStats = new BaseUnitStats("TestSwordsman",
                                                             "SWORDSMAN_UNIT",
                                                             1001,
                                                             1,
                                                             new Resource(),
                                                             new Resource(),
                                                             baseBattleStats,
                                                             300,
                                                             300,
                                                             1);

            Ioc.Kernel.Get <UnitFactory>().AddType(baseUnitStats);
        }
Ejemplo n.º 2
0
 public BaseUnitStats(string name,
                      string spriteClass,
                      ushort type,
                      byte lvl,
                      Resource cost,
                      Resource upgradeCost,
                      BaseBattleStats battleStats,
                      int buildTime,
                      int upgradeTime,
                      byte upkeep)
 {
     Name        = name;
     SpriteClass = spriteClass;
     Type        = type;
     Lvl         = lvl;
     Cost        = cost;
     UpgradeCost = upgradeCost;
     Battle      = battleStats;
     BuildTime   = buildTime;
     UpgradeTime = upgradeTime;
     Upkeep      = upkeep;
 }
Ejemplo n.º 3
0
 public StructureBaseStats(string name,
                           string spriteClass,
                           ushort type,
                           byte lvl,
                           byte radius,
                           Resource cost,
                           BaseBattleStats baseBattleStats,
                           ushort maxLabor,
                           int buildTime,
                           int workerId,
                           byte size)
 {
     Name        = name;
     SpriteClass = spriteClass;
     Radius      = radius;
     Type        = type;
     Lvl         = lvl;
     Cost        = cost;
     Battle      = baseBattleStats;
     MaxLabor    = maxLabor;
     BuildTime   = buildTime;
     WorkerId    = workerId;
     Size        = size;
 }
Ejemplo n.º 4
0
        public virtual void Init(string filename)
        {
            using (var reader = new CsvReader(new StreamReader(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))))
            {
                String[] toks;
                var      col = new Dictionary <string, int>();
                for (int i = 0; i < reader.Columns.Length; ++i)
                {
                    if (reader.Columns[i].Length == 0)
                    {
                        continue;
                    }
                    col.Add(reader.Columns[i], i);
                }
                while ((toks = reader.ReadRow()) != null)
                {
                    if (toks[0].Length <= 0)
                    {
                        continue;
                    }
                    var resource = new Resource(int.Parse(toks[col["Crop"]]),
                                                int.Parse(toks[col["Gold"]]),
                                                int.Parse(toks[col["Iron"]]),
                                                int.Parse(toks[col["Wood"]]),
                                                int.Parse(toks[col["Labor"]]));

                    var upgradeResource = new Resource(int.Parse(toks[col["UpgrdCrop"]]),
                                                       int.Parse(toks[col["UpgrdGold"]]),
                                                       int.Parse(toks[col["UpgrdIron"]]),
                                                       int.Parse(toks[col["UpgrdWood"]]),
                                                       int.Parse(toks[col["UpgrdLabor"]]));

                    var stats = new BaseBattleStats(ushort.Parse(toks[col["Type"]]),
                                                    byte.Parse(toks[col["Lvl"]]),
                                                    (WeaponType)Enum.Parse(typeof(WeaponType), toks[col["Weapon"]].ToCamelCase()),
                                                    (WeaponClass)Enum.Parse(typeof(WeaponClass), toks[col["WpnClass"]].ToCamelCase()),
                                                    (ArmorType)Enum.Parse(typeof(ArmorType), toks[col["Armor"]].ToCamelCase()),
                                                    (ArmorClass)Enum.Parse(typeof(ArmorClass), toks[col["ArmrClass"]].ToCamelCase()),
                                                    decimal.Parse(toks[col["Hp"]]),
                                                    decimal.Parse(toks[col["Atk"]]),
                                                    byte.Parse(toks[col["Splash"]]),
                                                    byte.Parse(toks[col["Rng"]]),
                                                    byte.Parse(toks[col["Stl"]]),
                                                    byte.Parse(toks[col["Spd"]]),
                                                    ushort.Parse(toks[col["GrpSize"]]),
                                                    ushort.Parse(toks[col["Carry"]]),
                                                    resource.NormalizedCost);

                    var basestats = new BaseUnitStats(toks[col["Name"]],
                                                      toks[col["SpriteClass"]],
                                                      ushort.Parse(toks[col["Type"]]),
                                                      byte.Parse(toks[col["Lvl"]]),
                                                      resource,
                                                      upgradeResource,
                                                      stats,
                                                      int.Parse(toks[col["Time"]]),
                                                      int.Parse(toks[col["UpgrdTime"]]),
                                                      byte.Parse(toks[col["Upkeep"]]));

                    dict[int.Parse(toks[col["Type"]]) * 100 + int.Parse(toks[col["Lvl"]])] = basestats;
                }
            }
        }
Ejemplo n.º 5
0
        public void Init(string filename)
        {
            using (var reader = new CsvReader(new StreamReader(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))))
            {
                String[] toks;
                var      col = new Dictionary <string, int>();
                for (int i = 0; i < reader.Columns.Length; ++i)
                {
                    col.Add(reader.Columns[i], i);
                }
                while ((toks = reader.ReadRow()) != null)
                {
                    if (toks[0].Length <= 0)
                    {
                        continue;
                    }
                    var resource = new Resource(int.Parse(toks[col["Crop"]]),
                                                int.Parse(toks[col["Gold"]]),
                                                int.Parse(toks[col["Iron"]]),
                                                int.Parse(toks[col["Wood"]]),
                                                int.Parse(toks[col["Labor"]]));

                    var stats = new BaseBattleStats(ushort.Parse(toks[col["Type"]]),
                                                    byte.Parse(toks[col["Lvl"]]),
                                                    (WeaponType)Enum.Parse(typeof(WeaponType), toks[col["Weapon"]].ToCamelCase()),
                                                    (WeaponClass)Enum.Parse(typeof(WeaponClass), toks[col["WpnClass"]].ToCamelCase()),
                                                    (ArmorType)Enum.Parse(typeof(ArmorType), toks[col["Armor"]].ToCamelCase()),
                                                    (ArmorClass)Enum.Parse(typeof(ArmorClass), toks[col["ArmrClass"]].ToCamelCase()),
                                                    decimal.Parse(toks[col["Hp"]]),
                                                    decimal.Parse(toks[col["Atk"]]),
                                                    byte.Parse(toks[col["Splash"]]),
                                                    byte.Parse(toks[col["Rng"]]),
                                                    byte.Parse(toks[col["Stl"]]),
                                                    byte.Parse(toks[col["Spd"]]),
                                                    0,
                                                    0,
                                                    0);
                    int workerId = int.Parse(toks[col["Worker"]]);

                    if (workerId == 0)
                    {
                        workerId = byte.Parse(toks[col["Lvl"]]) == 0
                                           ? 0
                                           : Ioc.Kernel.Get <ActionRequirementFactory>()
                                   .GetActionRequirementRecordBestFit(int.Parse(toks[col["Type"]]), byte.Parse(toks[col["Lvl"]]))
                                   .Id;
                    }

                    var basestats = new StructureBaseStats(toks[col["Name"]],
                                                           toks[col["SpriteClass"]],
                                                           ushort.Parse(toks[col["Type"]]),
                                                           byte.Parse(toks[col["Lvl"]]),
                                                           byte.Parse(toks[col["Radius"]]),
                                                           resource,
                                                           stats,
                                                           ushort.Parse(toks[col["MaxLabor"]]),
                                                           int.Parse(toks[col["Time"]]),
                                                           workerId,
                                                           byte.Parse(toks[col["Size"]]));

                    logger.Trace(string.Format("{0}:{1}", int.Parse(toks[col["Type"]]) * 100 + int.Parse(toks[col["Lvl"]]), toks[col["Name"]]));

                    dict[int.Parse(toks[col["Type"]]) * 100 + int.Parse(toks[col["Lvl"]])] = basestats;
                }
            }
        }
Ejemplo n.º 6
0
        public Group()
        {
            player = new Player(playerId,
                                DateTime.MinValue,
                                SystemClock.Now,
                                "player " + playerId,
                                string.Empty,
                                PlayerRights.Basic);
            playerId++;
            BaseBattleStats baseBattleStats = new BaseBattleStats(type: 2000,
                                                                  lvl: 1,
                                                                  weapon: WeaponType.Sword,
                                                                  wpnClass: WeaponClass.Elemental,
                                                                  armor: ArmorType.Building3,
                                                                  armrClass: ArmorClass.Stone,
                                                                  maxHp: 500,
                                                                  atk: 0,
                                                                  splash: 0,
                                                                  range: 0,
                                                                  stealth: 0,
                                                                  speed: 0,
                                                                  groupSize: 1,
                                                                  carry: 0,
                                                                  normalizedCost: 0);
            StructureBaseStats structureBaseStats = new StructureBaseStats(name: "MainBuilding",
                                                                           spriteClass: "",
                                                                           type: 2000,
                                                                           lvl: 1,
                                                                           radius: 0,
                                                                           cost: null,
                                                                           baseBattleStats: baseBattleStats,
                                                                           maxLabor: 0,
                                                                           buildTime: 0,
                                                                           workerId: 0);
            StructureStats structurestats = new StructureStats(structureBaseStats);

            var main = new Structure(structurestats);

            city = Ioc.Kernel.Get <ICityFactory>()
                   .CreateCity(id: cityId,
                               owner: player,
                               name: "city " + cityId,
                               resource: Formula.Current.GetInitialCityResources(),
                               radius: Formula.Current.GetInitialCityRadius(),
                               ap: 0);

            main.ObjectId = 1;
            city.Add(main.ObjectId, main, false);
            player.Add(city);
            cityId++;

            AttackStub = new TroopStub(0, city);
            AttackStub.AddFormation(FormationType.Normal);
            obj = new TroopObject(AttackStub);
            using (Concurrency.Current.Lock(city))
            {
                city.Troops.Add(AttackStub);
                city.Add(obj);
            }

            TroopObject = new TroopObject(AttackStub)
            {
                X = city.X, Y = city.Y
            };
            TroopObject.BeginUpdate();
            TroopObject.Stats = new TroopStats(Formula.Current.GetTroopRadius(AttackStub, null),
                                               Formula.Current.GetTroopSpeed(AttackStub));
            TroopObject.EndUpdate();

            city.Add(TroopObject);
        }