示例#1
0
文件: Ship.cs 项目: MRH4287/GameShare
 /// <summary>
 /// Erstellt ein neues Schiff
 /// </summary>
 /// <param name="type">Typ des Schiffes</param>
 /// <param name="UID">Der Besitzer des Schiffes</param>
 /// <param name="name">Der Name des Schiffes</param>
 /// <param name="fleet">Die Flotte, in der das Schiff ist</param>
 /// <param name="states">Die Zustände die ein Schiff hat</param>
 public Ship(ShipClass type, User UID, string name, int fleet, string states)
 {
     this.type = type;
     this.uid = UID;
     this.name = name;
     this.fleet = fleet;
     this.states = states;
 }
示例#2
0
        /// <summary>
        /// Erzeugt eine neue SchiffsKlasse
        /// </summary>
        /// <param name="ID">ID</param>
        /// <param name="data">GameData</param>
        /// <returns>ShipClass</returns>
        public static ShipClass create(int ID, GameData data)
        {
            MySqlDataReader Reader = data.Query("SELECT * FROM `PX_ships` WHERE `ID` = '" + ID + "'");
            Reader.Read();

            string name = (string)Reader["Name"];

            int power = (int)Reader["Power"];
            int health = (int)Reader["health"];
            int power2 = (int)Reader["Power2"];
            int power3 = (int)Reader["Power3"];
            int power4 = (int)Reader["Power4"];
            int resistend1 = (int)Reader["Resistend1"];
            int resistend2 = (int)Reader["Resistend2"];
            int resistend3 = (int)Reader["Resistend3"];
            int resistend4 = (int)Reader["Resistend4"];

            string names = (string)Reader["names"];
            int speed = (int)Reader["speed"];
            int globallimit = (int)Reader["globallimit"];
            int time = (int)Reader["time"];

            string need_techS = (string)Reader["need_tech"];
            string skillsS = (string)Reader["skills"];
            string raceS = (string)Reader["race"];

            byte[] picture = (byte[])Reader["picture"];

            ShipClass ship = new ShipClass(ID, name);

            ship.names = names;
            ship.speed = speed;
            ship.globallimit = globallimit;
            ship.time = time;

            ship.need_tech_temp = need_techS;
            ship.skills_temp = skillsS;
            ship.race_temp = raceS;

            ship.health = health;
            ship.power = power;
            ship.power2 = power2;
            ship.power3 = power3;
            ship.power4 = power4;
            ship.resistend1 = resistend1;
            ship.resistend2 = resistend2;
            ship.resistend3 = resistend3;
            ship.resistend4 = resistend4;

            string costs = (string)Reader["costs"];
            string[] costs_A1 = costs.Split(new string[] { "&" }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string value in costs_A1)
            {
                try
                {
                    string[] costs_A2 = value.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);

                    ResType type = (ResType)Enum.Parse(typeof(ResType), costs_A2[0]);
                    double cost = double.Parse(costs_A2[1]);

                    ship.price[type] = cost;

                }
                catch
                {
                    // Unsinnige Mysql Daten
                }
            }

            try
            {
                ship.picture = GraphicLibary.GraphicHelper.getPicture(picture);
            }
            catch
            {
                ship.picture = new System.Drawing.Bitmap(1, 1);
            }

            Reader.Close();
            return ship;
        }