示例#1
0
 public Ship(int id, string name, string lootId, int health, int nanohull, int speed, int shield, double shieldAbsorb, int minDamage, int maxDamage, bool neutral, int laserColor,
             int batteries, int rockets, int cargo, Reward reward, DropRewards cargoDrop, int ai)
 {
     Id               = id;
     Name             = name;
     LootId           = lootId;
     Health           = health;
     Nanohull         = nanohull;
     Speed            = speed;
     Shield           = shield;
     ShieldAbsorption = shieldAbsorb;
     MinDamage        = minDamage;
     MaxDamage        = maxDamage;
     IsNeutral        = neutral;
     LaserColor       = laserColor;
     Batteries        = batteries;
     Rockets          = rockets;
     Cargo            = cargo;
     Reward           = reward;
     CargoDrop        = cargoDrop;
     AI               = ai;
     Damage           = GetDamage();
 }
        public void CreateShips()
        {
            using (var mySqlClient = SqlDatabaseManager.GetClient())
            {
                var queryTable = mySqlClient.ExecuteQueryTable("SELECT * FROM server_ships");
                if (queryTable != null)
                {
                    foreach (DataRow reader in queryTable.Rows)
                    {
                        //Informations
                        var shipId           = intConv(reader["ship_id"]);
                        var shipName         = stringConv(reader["name"]);
                        var shipLootId       = stringConv(reader["ship_lootid"]);
                        var shipHp           = intConv(reader["ship_hp"]);
                        var shipNano         = intConv(reader["nanohull"]);
                        var shipSpeed        = intConv(reader["base_speed"]);
                        var shipShield       = intConv(reader["shield"]);
                        var shipShieldAbsorb = intConv(reader["shieldAbsorb"]);
                        var shipMinDamage    = intConv(reader["minDamage"]);
                        var shipMaxDamage    = intConv(reader["maxDamage"]);
                        var shipNeutral      = Convert.ToBoolean(intConv(reader["isNeutral"]));
                        var shipLaserColor   = intConv(reader["laserID"]);
                        var shipBatteries    = intConv(reader["batteries"]);
                        var shipRockets      = intConv(reader["rockets"]);
                        var shipCargo        = intConv(reader["cargo"]);
                        var shipAi           = intConv(reader["isNeutral"]);

                        //Rewards
                        var shipExp     = intConv(reader["experience"]);
                        var shipHonor   = intConv(reader["honor"]);
                        var shipCredits = intConv(reader["credits"]);
                        var shipUridium = intConv(reader["uridium"]);

                        var rewards = new Dictionary <RewardTypes, int>();
                        rewards.Add(RewardTypes.EXPERIENCE, shipExp);
                        rewards.Add(RewardTypes.HONOR, shipHonor);
                        rewards.Add(RewardTypes.CREDITS, shipCredits);
                        rewards.Add(RewardTypes.URIDIUM, shipUridium);
                        var shipRewards = new Reward(rewards);

                        var shipOreDrop =
                            JsonConvert.DeserializeObject <OreCollection>(reader["dropJSON"].ToString());

                        var shipDrops = new DropRewards {
                            OreCollection = shipOreDrop
                        };

                        ////add to Storage
                        GameStorageManager.Instance.Ships.TryAdd(shipId, new Ship(
                                                                     shipId,
                                                                     shipName,
                                                                     shipLootId,
                                                                     shipHp,
                                                                     shipNano,
                                                                     shipSpeed,
                                                                     shipShield,
                                                                     shipShieldAbsorb,
                                                                     shipMinDamage,
                                                                     shipMaxDamage,
                                                                     shipNeutral,
                                                                     shipLaserColor,
                                                                     shipBatteries,
                                                                     shipRockets,
                                                                     shipCargo,
                                                                     shipRewards,
                                                                     shipDrops,
                                                                     shipAi
                                                                     ));
                    }
                }
            }

            //World.StorageManager.LoadCatalog();
            Out.QuickLog("Loaded " + GameStorageManager.Instance.Ships.Count + " ships to Game Storage.", LogKeys.DATABASE_LOG);
        }