示例#1
0
        public override SensorFile ImportFile(string path, Boat boat)
        {
            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(path);
                StringBuilder log = new StringBuilder();
                FileInfo fi = new FileInfo(path);
                SensorFile file = new SensorFile("kml", fi.Name, DateTime.Now);
                file.Save();

                Dictionary<DateTime, CoordinatePoint> points = new Dictionary<DateTime, CoordinatePoint>();
                ExtractPoints(ref points, doc);

                foreach (DateTime dt in points.Keys)
                {
                    file.AddReading(dt, points[dt].Latitude.Value, points[dt].Longitude.Value, points[dt].HeightAboveGeoID, 0, 0, 0, 0, 0, 0, 0, 0, 0);
                }

                boat.AddFile(file);
                return file;
            }
            catch //(Exception e)
            {
                return null;
            }
        }
示例#2
0
 public static void AddBoat(Boat newBoat)
 {
     using (StreamWriter writer = new StreamWriter(BoatSavePath, true))
     {
         writer.WriteLine("{0} {1} {2} {3}", newBoat.OwnerId, newBoat.Type, newBoat.Length, newBoat.Width);
     }
 }
示例#3
0
 public static void DeleteBoat(Boat boatToDelete)
 {
     string boatToString = boatToDelete.OwnerId + " " + boatToDelete.Type + " " + boatToDelete.Width + " " + boatToDelete.Length;
     var file = System.IO.File.ReadAllLines(BoatSavePath);
     var fileWithoutMemberToDelete = file.Where(line => !line.Contains(boatToString));
     System.IO.File.WriteAllLines(BoatSavePath, fileWithoutMemberToDelete);
 }
        public void DeleteBoat(Member member, Boat boat)
        {
            // Delete Boat in BoatDAL
            BoatDAL.DeleteBoat(boat);

            // Delete in local MemberList
            member.Boats.Remove(boat);
        }
示例#5
0
 public Cell(Player Owner,Point location, Boat Type, State CurrentState)
 {
     BoatType = Type;
     BoatOwner = Owner;
     BoatState = CurrentState;
     Location = location;
     cells[location.X, location.Y] = this;
 }
示例#6
0
        public static void ChangeBoatInfo(Boat oldBoat, Boat newBoatInfo)
        {
            List<string> boatTextFile = new List<string>(File.ReadAllLines(BoatSavePath));

            string oldBoatString = oldBoat.OwnerId + " " + oldBoat.Type + " " + oldBoat.Width + " " + oldBoat.Length;

            int boatLineIndex = boatTextFile.FindIndex(line => line.Contains(oldBoatString));

            boatTextFile[boatLineIndex] = newBoatInfo.OwnerId + " " + newBoatInfo.Type + " " + newBoatInfo.Width + " " + newBoatInfo.Length;
            File.WriteAllLines(BoatSavePath, boatTextFile);
        }
示例#7
0
        static void Main(string[] args)
        {
            Vehicle vCar = new Car("Diesel","Fiat","600");
			Vehicle vMoto = new Motorbike("1500","Ducatti","1500");
			Vehicle vBoat = new Boat("10000","Vasque","3",3);
			
			ArrayList Vehicles = new ArrayList();
			Vehicles.add(vCar);
			Vehicles.add(vMoto);
			Vehicles.add(vBoat);
			
			list(Vehicles);
			
		}
示例#8
0
        public static List<Boat> BoatList(string ownerId)
        {
            List<string> boats = System.IO.File
                .ReadAllLines(BoatSavePath)
                .Where(i => i.Contains(ownerId))
                .ToList();
            List<Boat> boatList = new List<Boat>();

            foreach (var boat in boats)
            {
                string[] boatArray = boat.Split(' ');
                Boat newBoat = new Boat(boatArray[0], boatArray[1], int.Parse(boatArray[2]), int.Parse(boatArray[3]));
                boatList.Add(newBoat);
            }

            return boatList;
        }
示例#9
0
        public static List<Boat> ExtractBoats(string[] memberBoats)
        {
            string[] thisBoat;
            List<Boat> boats = new List<Boat>();
            if (memberBoats.Length != 0)
            {
                foreach (var boatString in memberBoats)
                {
                    if (!String.IsNullOrWhiteSpace(boatString))
                    {
                        thisBoat = boatString.Split('|');
                        Boat boat = new Boat(thisBoat[0], int.Parse(thisBoat[1]), int.Parse(thisBoat[2]));
                        boats.Add(boat);
                    }
                }
            }

            return boats;
        }
示例#10
0
 void Start()
 {
     boat      = transform.parent.gameObject.GetComponent <Boat>();
     safeZones = new List <GameObject>();
 }
示例#11
0
 void Start()
 {
     player        = GetComponent <Boat>();
     playerActions = CreateWithDefaultBindings();
 }
示例#12
0
    private Boat boat; // zoomed boat

    void Awake()
    {
        boat = GetComponentInParent <Boat>();
    }
示例#13
0
        public override void OnDoubleClick(Mobile from)
        {
            if (Boat == null || from == null)
            {
                return;
            }

            BaseBoat boat = BaseBoat.FindBoatAt(from, from.Map);

            int  range   = boat != null && boat == Boat ? 3 : 8;
            bool canMove = false;

            if (!Boat.IsRowBoat)
            {
                Boat.Refresh(from);
            }

            if (!from.InRange(Location, range))
            {
                from.SendLocalizedMessage(500295); //You are too far away to do that.
            }
            else if (!from.InLOS(Location))
            {
                from.SendLocalizedMessage(500950); //You cannot see that.
            }
            else if (Boat.IsMoving || Boat.IsTurning)
            {
                from.SendLocalizedMessage(1116611); //You can't use that while the ship is moving!
            }
            else if (BaseBoat.IsDriving(from))
            {
                from.SendLocalizedMessage(1116610); //You can't do that while piloting a ship!
            }
            else if (BaseHouse.FindHouseAt(from) != null)
            {
                from.SendLocalizedMessage(1149795); //You may not dock a ship while on another ship or inside a house.
            }
            else if (Boat == boat && !MoveToNearestDockOrLand(from))
            {
                from.SendLocalizedMessage(1149796); //You can not dock a ship this far out to sea. You must be near land or shallow water.
            }
            else if (boat == null || boat != null && Boat != boat)
            {
                if (Boat.HasAccess(from))
                {
                    canMove = true;
                }
                else
                {
                    from.SendLocalizedMessage(1116617); //You do not have permission to board this ship.
                }
            }

            if (canMove)
            {
                BaseCreature.TeleportPets(from, Location, Map);
                from.MoveToWorld(Location, Map);

                Boat.SendContainerPacket();
            }
        }
示例#14
0
        protected void BoatIslandCollision(Boat boat, Island island)
        {
            if (boat.Colour == island.Colour)
            {
                if (boat.carriedResources.Count > 0)//(boat.CarriedResource != null) // if carrying a resource
                {
                    //Plays the collect resource sound. This should maybe be in the CollectResource method
                    scoreCargo.Play();

                    foreach (Resource r in boat.carriedResources)
                    {
                        PlayersByColour[(int)boat.Colour].CollectResource(r);
                        island.AddResource(r);
                    }
                    //PlayersByColour[(int)boat.Colour].CollectResource(boat.CarriedResource);
                    //island.AddResource(boat.CarriedResource);

                   // if(boat.CarriedResource.Colour != boat.Colour)
                     //   PlayersByColour[(int)boat.Colour].score += RETURN_RESOURCE;

                    //boat.CarriedResource = null;
                    boat.carriedResources.Clear();
                }
            }
            else
            {
                if(!boat.CheckResourceIsCarried(island.ResourceType.islandType))//!boat.carriedResources.Contains(island.ResourceType))//if (boat.CarriedResource == null) // if not carrying a resource
                {
                    //PLAY THE SOUND
                    takeCargo.Play();
                    PlayersByColour[(int)island.Colour].score -= 200;
                    Resource r = new Resource(island.ResourceType);
                    boat.carriedResources.Add(r);
                    r.IsCarried = true;
                    r.position = boat.position;
                    //boat.CarriedResource = new Resource(island.ResourceType);
                    //boat.CarriedResource.IsCarried = true;
                }
            }
        }
示例#15
0
        public bool MoveToNearestDockOrLand(Mobile from)
        {
            if ((Boat != null && !Boat.Contains(from)) || !ValidateDockOrLand())
            {
                return(false);
            }

            Map map = Map;

            if (map == null)
            {
                return(false);
            }

            Rectangle2D rec;
            Point3D     nearest = Point3D.Zero;
            Point3D     p       = Point3D.Zero;

            if (Boat.IsRowBoat)
            {
                rec = new Rectangle2D(Boat.X - 8, Boat.Y - 8, 16, 16);
            }
            else
            {
                switch (Boat.Facing)
                {
                default:
                case Direction.North:
                case Direction.South:
                    if (X < Boat.X)
                    {
                        rec = new Rectangle2D(X - 8, Y - 8, 8, 16);
                    }
                    else
                    {
                        rec = new Rectangle2D(X, Y - 8, 8, 16);
                    }
                    break;

                case Direction.West:
                case Direction.East:
                    if (Y < Boat.Y)
                    {
                        rec = new Rectangle2D(X - 8, Y - 8, 16, 8);
                    }
                    else
                    {
                        rec = new Rectangle2D(X - 8, Y, 16, 8);
                    }
                    break;
                }
            }

            for (int x = rec.X; x <= rec.X + rec.Width; x++)
            {
                for (int y = rec.Y; y <= rec.Y + rec.Height; y++)
                {
                    p = new Point3D(x, y, map.GetAverageZ(x, y));

                    if (ValidateTile(from, ref p))
                    {
                        if (nearest == Point3D.Zero || from.GetDistanceToSqrt(p) < from.GetDistanceToSqrt(nearest))
                        {
                            nearest = p;
                        }
                    }
                }
            }

            if (nearest != Point3D.Zero)
            {
                BaseCreature.TeleportPets(from, nearest, Map);
                from.MoveToWorld(nearest, Map);

                return(true);
            }

            return(false);
        }
示例#16
0
 // Start is called before the first frame update
 void Start()
 {
     boat = player.GetComponent <Boat>();
     text = GetComponent <Text>();
 }
示例#17
0
 public void should_post_boat()
 {
     boat = null;
        Assert.Ignore("Implement edit");
 }
示例#18
0
 public void StartTask(Boat t)
 {
     t.Move(point.x, point.y, point.z);
 }
示例#19
0
 public bool TaskComplete(Boat t)
 {
     // moves the boat to a chosen point
     return(t.x == point.x && t.y == point.y && t.z == point.z);
 }
示例#20
0
 public void DisplaySingleBoat(Boat boat)
 {
     Console.WriteLine($"Boat type: {boat.BoatType.ToString()}, Boat Length: {boat.Length}, Boat Id: {boat.Id}");
 }
示例#21
0
 public void DisplayBoatUpdated(Boat boat)
 {
     Console.WriteLine($"Boat with Id: {boat.Id} was updated");
 }
示例#22
0
        public override bool OnMoveOver(Mobile from)
        {
            if (IsOpen)
            {
                if (from is BaseFactionGuard)
                {
                    return(false);
                }

                if ((from.Direction & Direction.Running) != 0 || Boat?.Contains(from) == false)
                {
                    return(true);
                }

                var map = Map;

                if (map == null)
                {
                    return(false);
                }

                int rx = 0, ry = 0;

                if (ItemID == 0x3ED4)
                {
                    rx = 1;
                }
                else if (ItemID == 0x3ED5)
                {
                    rx = -1;
                }
                else if (ItemID == 0x3E84)
                {
                    ry = 1;
                }
                else if (ItemID == 0x3E89)
                {
                    ry = -1;
                }

                for (var i = 1; i <= 6; ++i)
                {
                    var x = X + i * rx;
                    var y = Y + i * ry;
                    int z;

                    for (var j = -8; j <= 8; ++j)
                    {
                        z = from.Z + j;

                        if (map.CanFit(x, y, z, 16, false, false) && !SpellHelper.CheckMulti(new Point3D(x, y, z), map) &&
                            !Region.Find(new Point3D(x, y, z), map).IsPartOf <StrongholdRegion>())
                        {
                            if (i == 1 && j >= -2 && j <= 2)
                            {
                                return(true);
                            }

                            from.Location = new Point3D(x, y, z);
                            return(false);
                        }
                    }

                    z = map.GetAverageZ(x, y);

                    if (map.CanFit(x, y, z, 16, false, false) && !SpellHelper.CheckMulti(new Point3D(x, y, z), map) &&
                        !Region.Find(new Point3D(x, y, z), map).IsPartOf <StrongholdRegion>())
                    {
                        if (i == 1)
                        {
                            return(true);
                        }

                        from.Location = new Point3D(x, y, z);
                        return(false);
                    }
                }

                return(true);
            }

            return(false);
        }
示例#23
0
 public void Init()
 {
     boat = new Boat();
 }
示例#24
0
        public void Summon(Player player, EntityTypeEnum entityType, bool noAi = true, BlockPos spawnPos = null)
        {
            EntityType petType;

            try
            {
                petType = (EntityType)Enum.Parse(typeof(EntityType), entityType.Value, true);
            }
            catch (ArgumentException e)
            {
                return;
            }

            if (!Enum.IsDefined(typeof(EntityType), petType))
            {
                player.SendMessage("No entity found");
                return;
            }

            var coordinates = player.KnownPosition;

            if (spawnPos != null)
            {
                if (spawnPos.XRelative)
                {
                    coordinates.X += spawnPos.X;
                }
                else
                {
                    coordinates.X = spawnPos.X;
                }

                if (spawnPos.YRelative)
                {
                    coordinates.Y += spawnPos.Y;
                }
                else
                {
                    coordinates.Y = spawnPos.Y;
                }

                if (spawnPos.ZRelative)
                {
                    coordinates.Z += spawnPos.Z;
                }
                else
                {
                    coordinates.Z = spawnPos.Z;
                }
            }

            var world = player.Level;

            Mob    mob    = null;
            Entity entity = null;

            EntityType type = (EntityType)(int)petType;

            switch (type)
            {
            case EntityType.Chicken:
                mob = new Chicken(world);
                break;

            case EntityType.Cow:
                mob = new Cow(world);
                break;

            case EntityType.Pig:
                mob = new Pig(world);
                break;

            case EntityType.Sheep:
                mob = new Sheep(world);
                break;

            case EntityType.Wolf:
                mob = new Wolf(world)
                {
                    Owner = player
                };
                break;

            case EntityType.Villager:
                mob = new Villager(world);
                break;

            case EntityType.MushroomCow:
                mob = new MushroomCow(world);
                break;

            case EntityType.Squid:
                mob = new Squid(world);
                break;

            case EntityType.Rabbit:
                mob = new Rabbit(world);
                break;

            case EntityType.Bat:
                mob = new Bat(world);
                break;

            case EntityType.IronGolem:
                mob = new IronGolem(world);
                break;

            case EntityType.SnowGolem:
                mob = new SnowGolem(world);
                break;

            case EntityType.Ocelot:
                mob = new Ocelot(world);
                break;

            case EntityType.Zombie:
                mob = new Zombie(world);
                break;

            case EntityType.Creeper:
                mob = new Creeper(world);
                break;

            case EntityType.Skeleton:
                mob = new Skeleton(world);
                break;

            case EntityType.Spider:
                mob = new Spider(world);
                break;

            case EntityType.ZombiePigman:
                mob = new ZombiePigman(world);
                break;

            case EntityType.Slime:
                mob = new Slime(world);
                break;

            case EntityType.Enderman:
                mob = new Enderman(world);
                break;

            case EntityType.Silverfish:
                mob = new Silverfish(world);
                break;

            case EntityType.CaveSpider:
                mob = new CaveSpider(world);
                break;

            case EntityType.Ghast:
                mob = new Ghast(world);
                break;

            case EntityType.MagmaCube:
                mob = new MagmaCube(world);
                break;

            case EntityType.Blaze:
                mob = new Blaze(world);
                break;

            case EntityType.ZombieVillager:
                mob = new ZombieVillager(world);
                break;

            case EntityType.Witch:
                mob = new Witch(world);
                break;

            case EntityType.Stray:
                mob = new Stray(world);
                break;

            case EntityType.Husk:
                mob = new Husk(world);
                break;

            case EntityType.WitherSkeleton:
                mob = new WitherSkeleton(world);
                break;

            case EntityType.Guardian:
                mob = new Guardian(world);
                break;

            case EntityType.ElderGuardian:
                mob = new ElderGuardian(world);
                break;

            case EntityType.Horse:
                var random = new Random();
                mob = new Horse(world, random.NextDouble() < 0.10, random);
                break;

            case EntityType.PolarBear:
                mob = new PolarBear(world);
                break;

            case EntityType.Shulker:
                mob = new Shulker(world);
                break;

            case EntityType.Dragon:
                mob = new Dragon(world);
                break;

            case EntityType.SkeletonHorse:
                mob = new SkeletonHorse(world);
                break;

            case EntityType.Wither:
                mob = new Wither(world);
                break;

            case EntityType.Evoker:
                mob = new Evoker(world);
                break;

            case EntityType.Vindicator:
                mob = new Vindicator(world);
                break;

            case EntityType.Vex:
                mob = new Vex(world);
                break;

            case EntityType.Npc:
                if (Config.GetProperty("EnableEdu", false))
                {
                    mob = new Npc(world);
                }
                else
                {
                    mob = new PlayerMob("test", world);
                }
                break;

            case EntityType.Boat:
                entity = new Boat(world);
                break;
            }

            if (mob != null)
            {
                mob.NoAi = noAi;
                var direction = Vector3.Normalize(player.KnownPosition.GetHeadDirection()) * 1.5f;
                mob.KnownPosition = new PlayerLocation(coordinates.X + direction.X, coordinates.Y, coordinates.Z + direction.Z, coordinates.HeadYaw, coordinates.Yaw);
                mob.SpawnEntity();
            }
            else if (entity != null)
            {
                entity.NoAi = noAi;
                var direction = Vector3.Normalize(player.KnownPosition.GetHeadDirection()) * 1.5f;
                entity.KnownPosition = new PlayerLocation(coordinates.X + direction.X, coordinates.Y, coordinates.Z + direction.Z, coordinates.HeadYaw, coordinates.Yaw);
                entity.SpawnEntity();
            }
        }
示例#25
0
 public void should_get_boat()
 {
     boat = null;
        Assert.Ignore("Implement read");
 }
示例#26
0
文件: Boat.cs 项目: Lattyware/lgj2.0
	//True if current object is winner
	public bool isWinner(Boat enemy) {
		
		if(numVikings<=enemy.numVikings) {
			
			numVikings=0;
			enemy.unloadVikings(numVikings);
			
			return false;
			
		} else {
			
			unloadVikings(enemy.numVikings);
			enemy.numVikings=0;
			
			return true;
			
		}
	}
示例#27
0
 protected BoatController(Boat boat)
 {
     this.boat = boat;
 }
        private void PrintAddBoat(object member)
        {
            Member m = (Member)member;
            Boat b = new Boat();

            string boatlength = _menuView.GetUserInputLine("Enter new boat length (meters with 1 decimal)");
            decimal boatLengthDecimal;

            if (!decimal.TryParse(boatlength, out boatLengthDecimal))
            {
                _menuView.PrintError();
                return;
            }

            b.BoatLength = boatLengthDecimal;

            // Validate input
            if (!Validate(m))
            {
                ShowErrorMessages();
            }
            else
            {
                MenuContainer menu = new MenuContainer("Choose new boat type");

                menu.menuItems.Add(new MenuItem("S", "Sailboat"));
                menu.menuItems.Add(new MenuItem("M", "Motorsailer"));
                menu.menuItems.Add(new MenuItem("C", "Canoe"));
                menu.menuItems.Add(new MenuItem("O", "Other"));

                switch (_menuView.GetUserOption(menu))
                {
                    case "S": b.BoatType = "Sailboat";
                        break;
                    case "M": b.BoatType = "Motorsailer";
                        break;
                    case "C": b.BoatType = "Canoe";
                        break;
                    case "O": b.BoatType = "Other";
                        break;
                }

                // Try to save input
                try
                {
                    _memberService.SaveBoat(m, b);
                }
                catch (Exception e)
                {
                    // Print out error
                    _menuView.PrintError(e.Message);
                }
            }
        }
示例#29
0
        protected void BoatResourceCollision(Boat boat, Resource resource, List<Resource> collectedResources)
        {
            if (boat.Colour == resource.Colour)
            {
                takeCargo.Play(); // should be returnCargo
                PlayersByColour[(int)boat.Colour].score += 200;
                collectedResources.Add(resource);
            }
            else
            {
                //if (boat.CarriedResource == null) // if not carrying a resource
                //{
                    //PLAY THE SOUND
                    takeCargo.Play();
                    boat.carriedResources.Add(resource);
                    resource.IsCarried = true;
                    collectedResources.Add(resource);

                    //boat.CarriedResource = resource;
                    //boat.CarriedResource.IsCarried = true;
                    //collectedResources.Add(resource);
                //}
            }
        }
        public Boat GetBoat(Member member, Boat boat)
        {
            // Return null if the boat has no valid id. It's a new boat perhaps?
            if (boat.BoatId == 0)
            {
                return null;
            }

            return member.Boats.Find(x => (x.BoatId == boat.BoatId));
        }
示例#31
0
 public decimal GetSalary(Sailor sailor, Boat boat)
 {
     throw new NotImplementedException();   /* your code here */
 }
 public void SaveBoat(Member member, Boat boat)
 {
     // If boat does not exist in member
     if (GetBoat(member, boat) == null)
     {
         AddBoat(member, boat);
     }
     else
     {
         UpdateBoat(member, boat);
     }
 }
示例#33
0
        static void Main(string[] args)
        {
            var address = new AddressBookBuilder();

            address.ActualNumber = 1830;
            address.StreetName   = "Meridain Ave";
            address.LocationName = "South Beach Apt";
            Console.WriteLine(address);
            //
            var oldBoat = new Boat("Trirton", "Outboard Engine type");

            oldBoat.Buy("Frank");
            Console.WriteLine(oldBoat);
            //

            /*var horse = new Animal {Name = "Mr. Ed", FavoriteFood = "Grass",Greeting = "Hello Wilbur"}; //No constructor in class so we set out here.
             * horse.Speak();
             * horse.Eat();*/
            //
            var horse2 = new Horse {
                Name = "Clippity Clop"
            };

            horse2.Speak();
            horse2.Eat();
            horse2.ShoeMyHorse();
            //
            var Betsy = new Cow {
                Name = "Betsy"
            };

            Betsy.Speak();
            Betsy.Eat();
            Betsy.GiveMilk();
            //
            var lancelot  = new Knight();
            var legolas   = new Archer();
            var merlin    = new Wizard();
            var sgtPatton = new RifleSoldier();
            var pvtGump   = new GrenadierSoldier();
            //
            var modernArmy = new List <Soldier>();

            modernArmy.Add(sgtPatton);
            modernArmy.Add(pvtGump);

            modernArmy.ForEach(fighter => fighter.Attack());
            //
            var army = new List <Warrior>();

            army.Add(lancelot);
            army.Add(legolas);
            army.Add(merlin);

            army.ForEach(fighter => fighter.Attack());
            //
            var pegasus1 = new Pegasus(40, 30);

            pegasus1.IncreaseSpeed(20);
            pegasus1.DecreaseSpeed(10);
            pegasus1.FlapWings(10);
            pegasus1.Glide(5);
            Console.WriteLine(pegasus1);
            //
            var car1 = new Car("Volks", "GTI", 210, 25000);

            car1.IncreaseHP(50);
            car1.DecreaseHP(20);
            car1.IncreaseValue(6000);
            car1.DecreaseValue(1000);
            Console.WriteLine(car1);
            //
            var sportsCar1 = new SportsCar("Porsche", "911", 350, 90000);

            sportsCar1.IncreaseHP(50);
            sportsCar1.CustomParts.IncreaseValue(20);


            sportsCar1.IncreaseHpToSportCarLevels();
            Console.WriteLine(sportsCar1);
            //

            Console.ReadLine();
        }
        private void UpdateBoat(Member member, Boat boat)
        {
            // Update boat in BoatDAL
            BoatDAL.EditBoat(boat);

            // Update boat in local MembersList
            int _index = member.Boats.IndexOf(GetBoat(member, boat));
            member.Boats[_index] = boat;
        }
示例#35
0
        /// <summary>
        /// Deletes a unit from the fleet
        /// </summary>
        /// <param name="uuid"></param>
        /// <returns>A list of all player IDs which were assigned to
        /// positions on this ship</returns>
        public List <int> DeleteUnit(string uuid)
        {
            FleetUnit unit = GetUnit(uuid);

            // Clear all lookups
            List <int> removedPos = new List <int>();

            if (unit is Ship)
            {
                Ship ship = unit as Ship;
                foreach (OpPosition pos in ship.positions)
                {
                    // Unassign the position from the user
                    if (pos.filledById != -1)
                    {
                        removedPos.Add(pos.filledById);
                        ClearPosition(pos.uuid);
                    }

                    positionsLookup.Remove(pos.uuid);
                }

                // Remove from the fleet
                fleetLookup.Remove(uuid);
                fleetList.Remove(ship);
            }
            else if (unit is Wing)
            {
                // Remove each boat from the lookup
                Wing wing = unit as Wing;
                foreach (Boat boat in wing.members)
                {
                    boatLookup.Remove(boat.uuid);

                    // Unassign each position on the board
                    foreach (OpPosition pos in boat.positions)
                    {
                        if (pos.filledById != -1)
                        {
                            removedPos.Add(pos.filledById);
                            ClearPosition(pos.uuid);
                        }

                        positionsLookup.Remove(pos.uuid);
                    }
                }

                // Remove from the fleet
                fleetLookup.Remove(uuid);
                fleetList.Remove(wing);
            }
            else if (unit is Boat)
            {
                Boat boat = unit as Boat;
                if (boat.wingUUID == "")
                {
                    throw new ArgumentException(
                              "Boat must have wingUUID to be added");
                }

                // Remove all positions from the lookup
                foreach (OpPosition pos in boat.positions)
                {
                    if (pos.filledById != -1)
                    {
                        removedPos.Add(pos.filledById);
                        ClearPosition(pos.uuid);
                    }

                    positionsLookup.Remove(pos.uuid);
                }

                // Remove boat from lookup and wing
                boatLookup.Remove(boat.uuid);
                Wing wing = GetUnit(boat.wingUUID) as Wing;
                wing.members.Remove(boat);
            }

            return(removedPos);
        }
示例#36
0
 public void SetBoat(Boat boat)
 {
     this.m_Boat = boat;
 }
示例#37
0
 public void addBoat(Boat newBoat)
 {
     dailyBoats.Add(newBoat);
 }
示例#38
0
        /// <summary>
        /// Adds a unit to the fleet
        /// </summary>
        /// <param name="unit"></param>
        public void AddUnit(FleetUnit unit)
        {
            // Check that this ship is not already in the list
            if (GetUnit(unit.uuid) != null)
            {
                throw new ArgumentException(
                          $"Ship {unit.uuid} already in fleet");
            }

            // Add relevant members to lookup dictionaries
            if (unit is Ship)
            {
                Ship ship = unit as Ship;

                // Add all positions
                foreach (OpPosition p in ship.positions)
                {
                    positionsLookup.Add(p.uuid, p);
                    if (p.filledById != -1)
                    {
                        assignedPositionAdded?.Invoke(p);
                    }
                }

                fleetLookup.Add(unit.uuid, unit);
                fleetList.Add(unit);
            }
            else if (unit is Wing)
            {
                Wing wing = unit as Wing;

                // Add each boat
                foreach (Boat b in wing.members)
                {
                    boatLookup.Add(b.uuid, b);

                    // Add each position to the lookup
                    foreach (OpPosition p in b.positions)
                    {
                        positionsLookup.Add(p.uuid, p);
                        if (p.filledById != -1)
                        {
                            assignedPositionAdded?.Invoke(p);
                        }
                    }
                }

                fleetLookup.Add(unit.uuid, unit);
                fleetList.Add(unit);
            }
            else if (unit is Boat)
            {
                Boat boat = unit as Boat;

                Wing wing = GetUnit(boat.wingUUID) as Wing;
                wing.members.Add(boat);
                boat.callsign = $"{wing.callsign} {wing.members.Count}";

                // Add all positions
                foreach (OpPosition p in boat.positions)
                {
                    positionsLookup.Add(p.uuid, p);
                    if (p.filledById != -1)
                    {
                        assignedPositionAdded?.Invoke(p);
                    }
                }

                boatLookup.Add(boat.uuid, boat);
            }
        }
示例#39
0
        public int solution1(int[] R, int X, int M)
        {
            if (R.Length * X * 2 > M)
                return -1;

            Array.Sort(R);

            int result = 0;
            Stack<Boat> prev = new Stack<Boat>();

            for (int i = 0; i < R.Length; i++)
            {
                if (prev.Count == 0)
                {
                    Boat temp;
                    if (R[i] >= X)
                        temp = new Boat(R[i] - X, R[i] + X, 0);
                    else
                        temp = new Boat(0, 2 * X, X - R[i]);
                    prev.Push(temp);
                }
                else
                {
                    Boat park = prev.Peek();
                    if (park.right < R[i] - X)
                    {
                        Boat temp = new Boat(R[i] - X, R[i] + X, 0);
                        prev.Push(temp);
                    }
                    else
                    {
                        Boat merge = prev.Pop();
                        Boat temp = new Boat(park.right, park.right + 2 * X, park.right + X - R[i]);
                        int adjst = Convert.ToInt32(Math.Ceiling((double)(temp.rope - merge.rope) / 2));
                        temp.sMax = merge.rope;
                        temp.left = merge.left; //temp = merge + temp;

                        if (adjst == 0)
                        {
                            temp.rope = Math.Max(temp.rope, merge.rope);
                            prev.Push(temp);
                        }
                        else
                        {
                            while (adjst > 0 && prev.Count > 0)
                            {
                                merge = prev.Pop();
                                if (temp.left - merge.right <= adjst)
                                {
                                    int partial = temp.left - merge.right;
                                    temp.left = merge.left;
                                    temp.right = temp.right - partial;
                                    temp.rope = temp.rope - partial;
                                    temp.sMax = Math.Max(temp.sMax + partial, merge.rope);

                                    adjst = adjst - partial;
                                    if (adjst == 0)
                                        prev.Push(temp);
                                    if (merge.rope > temp.rope)
                                    {
                                        temp.rope = merge.rope;
                                        temp.sMax = merge.rope;
                                        prev.Push(temp);
                                        continue;
                                    }
                                }
                                else
                                {
                                    prev.Push(merge);
                                    temp.left = temp.left - adjst;
                                    temp.right = temp.right - adjst;
                                    temp.rope = temp.sMax + adjst; // temp.rope - adjst;
                                    prev.Push(temp);
                                    adjst = 0;
                                }
                            }
                            if (prev.Count == 0)
                            {
                                if (temp.left > adjst)
                                {
                                    temp.left = temp.left - adjst;
                                    temp.rope = temp.rope - adjst;
                                }
                                else
                                {
                                    temp.rope = temp.rope - temp.left;
                                    temp.left = 0;
                                }
                                prev.Push(temp);
                            }
                        }
                    }
                }
            }
            while (prev.Count > 0)
            {
                if (prev.Peek().rope > result)
                    result = prev.Peek().rope;
                prev.Pop();
            }
            return result;
        }
示例#40
0
文件: BulletInfo.cs 项目: Iilun/IC06
 public BulletInfo(int type, Boat boat)
 {
     this.type = type;
     this.boat = boat;
 }
 // Boat
 public void SaveBoat(int memberId, Boat boat)
 {
     // If boat does not exist in member
     SaveBoat(new Member { Id = memberId }, boat);
 }
        public void SwimMoveStrategyTest()
        {
            var vehicle = new Boat();

            Assert.AreEqual("Swim strategy", vehicle.MovingType.Move());
        }
        private void AddBoat(Member member, Boat boat)
        {
            // Add boat in BoatDAL
            BoatDAL.RegisterNewBoat(boat, member);

            // Add member id to boat, in case this is not done.
            boat.MemberId = member.Id;

            // Add boat in local MemberList
            member.Boats.Add(boat);
        }
示例#44
0
 protected void BoatPowerUpCollision(Boat boat, PowerUp powerUp, List <PowerUp> collectedPowerUps)
 {
     boat.GainPowerUp(powerUp);
     collectedPowerUps.Add(powerUp);
 }
 public void DeleteBoat(int memberId, Boat boat)
 {
     DeleteBoat(GetMember(memberId), boat);
 }
示例#46
0
        public Boat createBoat()
        {
            int    boatLen      = 0;
            int    boatType     = 0;
            int    boatDraft    = 0;
            string strBoatOwner = string.Empty;
            string strBoatName  = string.Empty;


            Boat Boat = null;

            while (true)
            {
                Console.WriteLine("Enter Boat Length");
                string strBoatLength = Console.ReadLine();
                if (!string.IsNullOrEmpty(strBoatLength))
                {
                    int.TryParse(strBoatLength, out boatLen);
                }
                if (boatLen < 1)
                {
                    Console.WriteLine("Boat Length Cannot be less tha 1 meter");
                }
                if (boatLen > marinaLength || boatLen < 1)
                {
                    Console.WriteLine("Boat Length Cannot be Greater than Marina Length or less than 1 meter");
                }
                //else if(boatLen>(Marina.getCurrentCapacityMarinaLength()-Marina.MarinaLength))
                else if (boatLen > (marinaLength - Marina.getCurrentCapacityMarinaLength()))
                {
                    throw new ArgumentException("The current marina capacity of " + Marina.getCurrentCapacityMarinaLength().ToString() + " will not be enough to accomodate this boat");
                }
                else
                {
                    break;
                }
            }
            while (true)
            {
                Console.WriteLine("Enter Boat Draft");
                string strBoatDraft = Console.ReadLine();
                if (!string.IsNullOrEmpty(strBoatDraft))
                {
                    int.TryParse(strBoatDraft, out boatDraft);
                }
                if (boatDraft < 1)
                {
                    Console.WriteLine("Boat Draft Cannot be less tha 1 meter");
                }
                if (boatDraft > 5 || boatDraft < 1)
                {
                    Console.WriteLine("Boat Draft Cannot be Greater than 5 meters or less than 1 meter");
                }
                else
                {
                    break;
                }
            }
            //check reservation here
            bool proceed = calculateBoatResrvation();

            if (proceed)
            {
                while (true)
                {
                    Console.WriteLine("Enter Boat Owner");
                    strBoatOwner = Console.ReadLine();
                    if (!string.IsNullOrEmpty(strBoatOwner))
                    {
                        break;
                    }
                }

                while (true)
                {
                    Console.WriteLine("Enter Boat Name");
                    strBoatName = Console.ReadLine();
                    if (!string.IsNullOrEmpty(strBoatName))
                    {
                        break;
                    }
                }



                Console.WriteLine("Choose Boat Type:");
                while (true)
                {
                    try
                    {
                        boatType = DisplayManager.displayBoatTypesMenu();
                        break;
                    }
                    catch (Exception ex)
                    {
                        DisplayManager.displayMessage(ex.Message);
                    }
                }


                switch (boatType)
                {
                case 1:

                    MotorBoat MB        = (Factory.MotorBoat)BoatFactory.BuildBoat(boatType);
                    int       mbSubtype = BoatFactory.BuildBoatSubTypes(boatType);
                    MB.DriveType = MB.GetEnumNameFromValue(mbSubtype);
                    Boat         = MB;
                    break;

                case 2:

                    // NarrowBoat NB = new NarrowBoat("NarrowBoat", boatType);
                    NarrowBoat NB        = (Factory.NarrowBoat)BoatFactory.BuildBoat(boatType);
                    int        nbSubtype = BoatFactory.BuildBoatSubTypes(boatType);
                    NB.SternType = NB.GetEnumNameFromValue(nbSubtype);
                    Boat         = NB;
                    break;

                case 3:

                    //SailingBoat SB = new SailingBoat("Sailing", boatType);
                    SailingBoat SB        = (Factory.SailingBoat)BoatFactory.BuildBoat(boatType);
                    int         sbSubtype = BoatFactory.BuildBoatSubTypes(boatType);
                    SB.SailingType = SB.GetEnumNameFromValue(sbSubtype);
                    Boat           = SB;
                    break;

                default:
                    break;
                }

                if (Boat != null)
                {
                    Boat.BoatLength  = boatLen;
                    Boat.NameOfBoat  = strBoatName;
                    Boat.NameOfOwner = strBoatOwner;
                    Boat.BoatDraft   = boatDraft;
                    Factory.BoatHelperClass.showDetails(Boat);
                }
            }
            else
            {
                throw new Exception("User terminated Booking transaction");
            }



            return(Boat);
        }
示例#47
0
 public void Dispose()
 {
     boat = null;
 }
示例#48
0
        static void Main(string[] args)
        {
            Queue QueueObj = new MarinaBerthClassLibrary.Queue();

            //Marina.mainMenu();
            //this boolean will be used to
            //short cirucit the flow in order to diplay the header menu once
            bool   check      = true;
            string strProceed = "";
            //get user input
            //  int userInput = DisplayManager.displayHeaderMenu();
            int userInput = 0;

            while (userInput != 4)
            {
                //has this loop run previously?
                //false mean ,this an n+1 iteration
                //if (check==false)
                //{
                //    userInput = DisplayManager.displayHeaderMenu();
                //}

                userInput = DisplayManager.displayHeaderMenu();

                Boat newBoat = new Boat();
                switch (userInput)
                {
                case 1:
                    //clear
                    DisplayManager.clearScreen();
                    //record a booking
                    //
                    DisplayManager.drawRectangle(" Please follow the Screen Instruction to enter Boat Details".ToUpper().PadLeft(60).PadRight(70) + string.Empty);
                    check = false;
                    //use while loop here
                    newBoat = BoatDataCapture.captureBoat();
                    DisplayManager.ShowBoatCaptureMessage();
                    if (newBoat.NameOfBoat != null)
                    {
                        //add to queue

                        QueueObj.Enqueue(newBoat);
                        DisplayManager.displayInvalidInputMessage("Do you wish to enter another boat?\n\n Please Enter Either 'Y' or 'N' to proceed");
                        strProceed = DisplayManager.getUserInputStr();
                        while (strProceed.ToUpper() == "Y")
                        {
                            DisplayManager.clearScreen();
                            newBoat = BoatDataCapture.captureBoat();
                            QueueObj.Enqueue(newBoat);
                            DisplayManager.displayInvalidInputMessage("Do you wish to enter another boat?\n\n Please Enter Either 'Y' or 'N' to proceed");
                            strProceed = DisplayManager.getUserInputStr();
                        }
                    }


                    DisplayManager.displayInvalidMainMenuAndReturnToMainMenu("Going Back to Main Menu", 2000);
                    DisplayManager.clearScreen();


                    break;

                case 2:
                    check = false;
                    //Delete a Booking
                    break;

                case 3:
                    check = false;
                    // display all
                    DisplayManager.clearScreen();

                    Console.WriteLine(QueueObj.PrintElements());
                    strProceed = string.Empty;
                    DisplayManager.displayInvalidInputMessage("\nTo go back to Main Menu Please Enter Either 'Y' or 'N' to proceed");
                    while (strProceed.ToUpper() == "N" || strProceed.Equals(string.Empty))
                    {
                        strProceed = DisplayManager.getUserInputStr();
                        DisplayManager.clearScreen();
                        DisplayManager.displayInvalidInputMessage("To go back to Main Menu\n Please Enter Either 'Y' or 'N' to proceed");
                    }
                    DisplayManager.displayInvalidMainMenuAndReturnToMainMenu("Going Back to Main Menu", 2000);
                    DisplayManager.clearScreen();
                    break;

                case 4:
                    check = false;
                    DisplayManager.exitApplication();
                    break;

                default:
                    check = false;
                    //DisplayManager.displayInvalidInputMessage("Please Enter a valid menu option to proceed");
                    DisplayManager.clearScreen();
                    DisplayManager.displayInvalidMainMenuAndReturnToMainMenu("Invalid menu Option.Returning user back to MainMenu".ToUpper(), 5000);

                    DisplayManager.displayHeaderMenu();
                    break;
                }
            }
        }
示例#49
0
 public void should_delete_boat()
 {
     boat = null;
        Assert.Ignore("Implement delete");
 }
示例#50
0
        /// <summary>
        /// Hard coded configuration for a game.
        /// </summary>
        public void setConfiguration()
        {
            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                BoatType destroyer       = new BoatType("destroyer", 1, 2);
                BoatType crusader        = new BoatType("crusader", 1, 3);
                BoatType aircraftCarrier = new BoatType("aircraft-carrier", 1, 5);
                BoatType submarine       = new BoatType("submarine", 1, 5);
                db.BoatTypesDbSet.Add(destroyer);
                db.BoatTypesDbSet.Add(crusader);
                db.BoatTypesDbSet.Add(aircraftCarrier);
                db.BoatTypesDbSet.Add(submarine);

                Player playerIa = new Player("IA", true);
                Player player   = new Player("Toto", false);

                Game game = Game.Instance;
                System.Console.WriteLine("game before" + Game.Instance.ToString());
                game.Width    = 15;
                game.Height   = 15;
                game.PlayerIa = playerIa;
                game.Player   = player;
                db.GamesDbSet.Add(game);
                System.Console.WriteLine("game after" + Game.Instance.ToString());


                db.PlayersDbSet.Add(playerIa);
                db.PlayersDbSet.Add(player);

                Boat boat1 = new Boat(destroyer);
                boat1.Width       = 2;
                boat1.Height      = 3;
                boat1.Orientation = true;
                boat1.Player      = playerIa;

                Boat boat2 = new Boat(crusader);
                boat2.Width       = 1;
                boat2.Height      = 4;
                boat2.Orientation = false;
                boat2.Player      = playerIa;

                Boat boat3 = new Boat(aircraftCarrier);
                boat3.Width       = 2;
                boat3.Height      = 2;
                boat3.Orientation = true;
                boat3.Player      = playerIa;

                Boat boat4 = new Boat(submarine);
                boat4.Width       = 1;
                boat4.Height      = 2;
                boat4.Orientation = false;
                boat4.Player      = playerIa;

                Boat boat5 = new Boat(destroyer);
                boat5.Width       = 2;
                boat5.Height      = 3;
                boat5.Orientation = true;
                boat5.Player      = player;

                Boat boat6 = new Boat(crusader);
                boat6.Width       = 1;
                boat6.Height      = 4;
                boat6.Orientation = false;
                boat6.Player      = player;

                Boat boat7 = new Boat(aircraftCarrier);
                boat7.Width       = 2;
                boat7.Height      = 2;
                boat7.Orientation = true;
                boat7.Player      = player;

                Boat boat8 = new Boat(submarine);
                boat8.Width       = 1;
                boat8.Height      = 2;
                boat8.Orientation = false;
                boat8.Player      = player;

                db.BoatsDbSet.Add(boat1);
                db.BoatsDbSet.Add(boat2);
                db.BoatsDbSet.Add(boat3);
                db.BoatsDbSet.Add(boat4);
                db.BoatsDbSet.Add(boat5);
                db.BoatsDbSet.Add(boat6);
                db.BoatsDbSet.Add(boat7);
                db.BoatsDbSet.Add(boat8);

                db.SaveChanges();
                this.txtX.Text = game.ToString();
            }
        }
示例#51
0
 public void should_get_boats()
 {
     boat = null;
        Assert.Ignore("Implement browse");
 }
示例#52
0
 static Boat CreateCar(Boat boat)
 {
     Console.WriteLine($"Boat {boat.Id} saved to database");
     return(boat);
 }
示例#53
0
 public void should_put_boat()
 {
     boat = null;
        Assert.Ignore("Implement add");
 }
示例#54
0
 static void DeleteCar(Boat boat)
 {
     Console.WriteLine($"Boat {boat.Id} deleted from database");
 }
示例#55
0
 static Boat UpdateCar(Boat boat)
 {
     Console.WriteLine($"Boat {boat.Id} updated in database");
     return(boat);
 }
示例#56
0
        public override bool OnMoveOver(Mobile from)
        {
            if (IsOpen)
            {
                if ((from.Direction & Direction.Running) != 0 || Boat?.Contains(from) == false)
                {
                    return(true);
                }

                var map = Map;

                if (map == null)
                {
                    return(false);
                }

                int rx = 0, ry = 0;

                if (ItemID == 0x3ED4)
                {
                    rx = 1;
                }
                else if (ItemID == 0x3ED5)
                {
                    rx = -1;
                }
                else if (ItemID == 0x3E84)
                {
                    ry = 1;
                }
                else if (ItemID == 0x3E89)
                {
                    ry = -1;
                }

                for (var i = 1; i <= 6; ++i)
                {
                    var x = X + i * rx;
                    var y = Y + i * ry;
                    int z;

                    for (var j = -8; j <= 8; ++j)
                    {
                        z = from.Z + j;

                        if (map.CanFit(x, y, z, 16, false, false) && new Point3D(x, y, z).GetMulti(map) == null)
                        {
                            if (i == 1 && j >= -2 && j <= 2)
                            {
                                return(true);
                            }

                            from.Location = new Point3D(x, y, z);
                            return(false);
                        }
                    }

                    z = map.GetAverageZ(x, y);

                    if (map.CanFit(x, y, z, 16, false, false) && new Point3D(x, y, z).GetMulti(map) == null)
                    {
                        if (i == 1)
                        {
                            return(true);
                        }

                        from.Location = new Point3D(x, y, z);
                        return(false);
                    }
                }

                return(true);
            }

            return(false);
        }
示例#57
0
 protected void BoatPowerUpCollision(Boat boat, PowerUp powerUp, List<PowerUp> collectedPowerUps)
 {
     boat.GainPowerUp(powerUp);
     collectedPowerUps.Add(powerUp);
 }
示例#58
0
        public override void OnDoubleClick(Mobile from)
        {
            if (Boat == null)
            {
                return;
            }

            if (from.InRange(GetWorldLocation(), 8))
            {
                if (Boat.Contains(from))
                {
                    if (IsOpen)
                    {
                        Close();
                    }
                    else
                    {
                        Open();
                    }
                }
                else
                {
                    if (!IsOpen)
                    {
                        if (!Locked)
                        {
                            Open();
                        }
                        else if (from.AccessLevel >= AccessLevel.GameMaster)
                        {
                            from.LocalOverheadMessage(
                                MessageType.Regular,
                                0x00,
                                502502
                                ); // That is locked but your godly powers allow access
                            Open();
                        }
                        else
                        {
                            from.LocalOverheadMessage(MessageType.Regular, 0x00, 502503); // That is locked.
                        }
                    }
                    else if (!Locked)
                    {
                        from.Location = new Point3D(X, Y, Z + 3);
                    }
                    else if (from.AccessLevel >= AccessLevel.GameMaster)
                    {
                        from.LocalOverheadMessage(
                            MessageType.Regular,
                            0x00,
                            502502
                            ); // That is locked but your godly powers allow access
                        from.Location = new Point3D(X, Y, Z + 3);
                    }
                    else
                    {
                        from.LocalOverheadMessage(MessageType.Regular, 0x00, 502503); // That is locked.
                    }
                }
            }
        }
示例#59
0
 protected void BulletBoatCollision(Bullet bullet, Boat boat, List<Bullet> removedBullets)
 {
     // TODO
     if (bullet.HostileToPlayer[(int)boat.Colour])
     {
         //Plays the sound!
         impactSound.Play();
         removedBullets.Add(bullet);
         boat.Hit(bullet);
     }
 }
示例#60
0
    /// <summary>
    /// spawns the shot
    /// </summary>
    /// <param name="boat">boat it comes from</param>
    /// <param name="right">If set to <c>true</c> shoots to the right.</param>
    public void Spawn(Boat otherBoat, bool right)
    {
        //sends shot at the other ship

        velocity = (otherBoat.transform.position - transform.position).normalized * speed;
    }