예제 #1
0
 public StructureBaseStats(StructureBaseStats copy) :
     this(copy.Name,
          copy.SpriteClass,
          copy.Type,
          copy.Lvl,
          copy.Radius,
          new Resource(copy.Cost),
          new BaseBattleStats(copy.Battle),
          copy.MaxLabor,
          copy.BuildTime,
          copy.WorkerId,
          copy.Size)
 {
 }
예제 #2
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;
                }
            }
        }
예제 #3
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);
        }