Beispiel #1
0
 public BoatStats(string _name, BoatType _type, int _tCap, int _lCap, float _knots, int _hp)
 {
     boatName      = _name;
     boatType      = _type;
     troopCapacity = _tCap;
     lootCapasity  = _lCap;
     knots         = _knots;
     health        = _hp;
     sprite        = Resources.Load <Sprite>(_type.ToString());
 }
Beispiel #2
0
        public BoatStats(BoatType _type)
        {
            BoatStats _newStats = GetStatsForType(_type);

            boatName      = _newStats.boatName;
            boatType      = _newStats.boatType;
            troopCapacity = _newStats.troopCapacity;
            lootCapasity  = _newStats.lootCapasity;
            knots         = _newStats.knots;
            health        = _newStats.health;
            sprite        = Resources.Load <Sprite>(_type.ToString());
        }
Beispiel #3
0
        public void ChangeBoat(int boatId, BoatType boatType, int boatLength)
        {
            XmlNodeList boatNodes = _doc.SelectNodes("//member/boat");

            foreach (XmlNode boatNode in boatNodes)
            {
                if (int.Parse(boatNode.Attributes["id"].Value) == boatId)
                {
                    boatNode.Attributes["type"].Value   = boatType.ToString();
                    boatNode.Attributes["length"].Value = boatLength.ToString();
                }
            }
            _doc.Save(_path);
        }
Beispiel #4
0
        public void AddBoat(int memberId, BoatType boatType, int boatLength)
        {
            XmlNodeList memberNodes = _doc.SelectNodes("//memberRegistry/member");

            XmlElement xmlBoat = _doc.CreateElement("boat");

            xmlBoat.SetAttribute("id", _boatId.ToString());
            xmlBoat.SetAttribute("type", boatType.ToString());
            xmlBoat.SetAttribute("length", boatLength.ToString());

            foreach (XmlNode memberNode in memberNodes)
            {
                if (int.Parse(memberNode.Attributes["id"].Value) == memberId)
                {
                    memberNode.AppendChild(xmlBoat);
                }
            }
            _doc.Save(_path);
            _boatId++;
        }
Beispiel #5
0
        public void ShowFormUpdateBoat(Member selected)
        {
            int id;

            Console.WriteLine("**UpdateBoat**");
            Console.Write("Enter ID of boat to be updated: ");
            int.TryParse(Console.ReadLine(), out id);
            Console.Clear();

            BoatId = id;
            BoatType type = (from t in selected.Boats
                             where t.Id == id
                             select t.BoatType).FirstOrDefault();
            float length = (from t in selected.Boats
                            where t.Id == id
                            select t.Length).FirstOrDefault();

            Console.WriteLine("**Current values**");
            Console.WriteLine("Type: " + type.ToString());
            Console.WriteLine("Length: " + length.ToString());
            Console.WriteLine();
            Console.WriteLine("**Update information**");
            ShowFormAddBoat(selected);
        }
        public static Boat RandomBoat()
        {
            //BoatType randomBoatType = (BoatType)rand.Next(Enum.GetNames(typeof(BoatType)).Length);
            Func <int, int, int> propertyRange    = (min, max) => rand.Next(min, max + 1);
            Func <BoatType>      selectRandomType = () => (BoatType)rand.Next(Enum.GetNames(typeof(BoatType)).Length);


            BoatType randomBoatType = selectRandomType();
            int      topSpeedKnots;
            int      weight;
            string   ID;
            string   prefix;
            int      specialProperty;


            switch (randomBoatType)
            {
            case BoatType.ROWBOAT:
                prefix          = "R-";
                ID              = GenerateName(prefix);
                weight          = propertyRange(100, 300);
                topSpeedKnots   = propertyRange(0, 3);   //upp till 3 knop
                specialProperty = propertyRange(1, 6);   //antal passagerare i det här fallet
                return(new Rowboat(ID, weight, topSpeedKnots, specialProperty));


            case BoatType.MOTORBOAT:
                prefix          = "M-";
                ID              = GenerateName(prefix);
                weight          = propertyRange(200, 3000);
                topSpeedKnots   = propertyRange(0, 60);    //upp till 60 knop
                specialProperty = propertyRange(10, 1000); //hästkrafter i det här fallet
                return(new Motorboat(ID, weight, topSpeedKnots, specialProperty));


            case BoatType.SAILBOAT:
                prefix          = "S-";
                ID              = GenerateName(prefix);
                weight          = propertyRange(800, 6000);
                topSpeedKnots   = propertyRange(0, 12);
                specialProperty = propertyRange(10, 60);     //fot i det här fallet
                return(new Sailboat(ID, weight, topSpeedKnots, specialProperty));


            case BoatType.CARGOSHIP:
                prefix          = "L-";
                ID              = GenerateName(prefix);
                weight          = propertyRange(3000, 20000);
                topSpeedKnots   = propertyRange(0, 20);
                specialProperty = propertyRange(0, 500);     //hästkrafter i det här fallet
                return(new Cargoship(ID, weight, topSpeedKnots, specialProperty));



            case BoatType.CATAMARAN:
                prefix          = "K-";
                ID              = GenerateName(prefix);
                topSpeedKnots   = propertyRange(0, 12);      //upp till 12 knop
                weight          = propertyRange(1200, 8000); // exclusive max därav +1
                specialProperty = propertyRange(1, 4);       //sängplatser i det här fallet
                return(new Catamaran(ID, weight, topSpeedKnots, specialProperty));

            default:
                throw new NotImplementedException("Not yet implemented!\n " + randomBoatType.ToString());
            }
        }
        /// <summary>
        /// <para>Performs the Search Method:
        /// Search Motor Boats
        /// using the parameters provided - can use null if the parameter is not required.
        /// </para>
        /// DOES NOT REQUIRE AUTHENTICATION.
        /// </summary>
        /// <param name="searchString">One or more keywords to use in a search query.</param>
        /// <param name="sortOrder">Sort the returned record-set by a single specified sort order.</param>
        /// <param name="priceMin">Minimum price.</param>
        /// <param name="priceMax">Maximum price.</param>
        /// <param name="type">Type of the Motor Boat.</param>
        /// <param name="lengthMin">Minimum length of a boat in metres.</param>
        /// <param name="lengthMax">Maximum length of a boat in metres.</param>
        /// <param name="dateFrom">Return only listings started from this date.</param>
        /// <param name="page">Page number.</param>
        /// <param name="rows">Number of rows per page.</param>
        /// <returns>MotorBoats.</returns>
        public MotorBoats SearchMotorBoats(string searchString, SortOrder sortOrder, decimal priceMin, decimal priceMax, BoatType type, int? lengthMin, int? lengthMax, DateTime dateFrom, int? page, int? rows)
        {
            var url = String.Format(Constants.Culture, "{0}/{1}/Boats{2}", Constants.SEARCH, Constants.MOTORS, Constants.XML);
            _addAnd = false;

            // create the parameters for the query string
            var conditions = "?";
            conditions += SearchMethods.ConstructQueryHelper(Constants.SEARCH_STRING, searchString, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.SORT_ORDER, string.Empty + sortOrder, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.PRICE_MIN, string.Empty + priceMin, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.PRICE_MAX, string.Empty + priceMax, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.TYPE, type.ToString(), _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.LENGTH_MIN, string.Empty + lengthMin, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.LENGTH_MAX, string.Empty + lengthMax, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.DATE_FROM, Client.DateToStringConverter(dateFrom), _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.PAGE, string.Empty + page, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.ROWS, string.Empty + rows, _addAnd);

            // add the parameters to the query string if there are any
            if (conditions.Equals("?"))
            {
                url += conditions;
            }

            // perform the request
            return this.SearchMotorBoats(url);
        }