예제 #1
0
        public void TestShouldThrowExceptionIfFallsOffPlateau(OrientationType orientationType)
        {
            Tractor tractor = new Tractor();
            Invoker invoker = new Invoker();

            invoker.SetCommand(new MoveTurnCommand(tractor));
            while (tractor.OrientationType != orientationType)
            {
                invoker.ExecuteCommand();
            }

            try
            {
                int moveCount = Consts.FieldHeight > Consts.FieldWidth ? Consts.FieldHeight : Consts.FieldWidth;
                moveCount++;

                invoker.SetCommand(new MoveForwardsCommand(tractor));

                for (int i = 0; i < moveCount; i++)
                {
                    invoker.ExecuteCommand();
                }
            }
            catch (UnitInDitchException exc)
            {
                return;
            }

            Assert.Fail("Tractor is expected to fall off the plateau");
        }
예제 #2
0
    void HandleEnterExitTractorState()
    {
        if (!textIsUpdated)
        {
            textIsUpdated = true;
            HighlightObject(GameObject.FindGameObjectsWithTag("Tractor")[0]);
            tutorialText.text = "Let's go to the tractor and press "
                                + ControllableObject.kbEnterExitTractor.ToString() + ". "
                                + "You can enter and exit the tractor by pressing this key, and go around in the tractor by using the same keys to move the player.\n"
                                + "One thing to note, you cannot use a tractor not belonged to your team.\n"
                                + "Press " + readyKey.ToString() + " once you're ready to explore more!";
        }
        else if (Input.GetKeyDown(readyKey))
        {
            textIsUpdated = false;
            GameObject tractorGO = GameObject.FindGameObjectsWithTag("Tractor")[0];
            UnhighlightObject(tractorGO);

            Tractor tractor = tractorGO.GetComponent <Tractor>();
            if (tractor.HasFuel())
            {
                UpdateStates(state, TutorialState.HarvestHay);
            }
            else
            {
                UpdateStates(TutorialState.HarvestHay, TutorialState.RefillFuel);
            }
        }
    }
예제 #3
0
        /****
        ** State methods
        ****/
        /// <summary>Detect and fix tractor garages that started construction today.</summary>
        private void ProcessNewConstruction()
        {
            foreach (GarageMetadata metadata in this.GetGarages().ToArray())
            {
                this.HasAnyGarages = true;
                Building garage = metadata.Building;
                BuildableGameLocation location = metadata.Location;

                // skip if not built today
                if (garage is TractorGarage)
                {
                    continue;
                }

                // set construction days after it's placed
                if (!this.GaragesStartedToday.Contains(garage))
                {
                    garage.daysOfConstructionLeft.Value = this.GarageConstructionDays;
                    this.GaragesStartedToday.Add(garage);
                }

                // spawn tractor if built instantly by a mod
                if (!garage.isUnderConstruction())
                {
                    Guid tractorID = Guid.NewGuid();
                    this.GaragesStartedToday.Remove(garage);
                    location.destroyStructure(garage);
                    location.buildings.Add(new TractorGarage(tractorID, this.GetBlueprint(), new Vector2(garage.tileX, garage.tileY), 0));
                    if (this.Tractor == null)
                    {
                        this.Tractor = this.SpawnTractor(tractorID, location, garage.tileX + 1, garage.tileY + 1);
                    }
                }
            }
        }
예제 #4
0
        public void TestShouldTurnAndMoveInTheRightDirection()
        {
            var     mf      = new MoveForwardCommand();
            var     tc      = new TurnClockwiseCommand();
            Tractor tractor = new Tractor();

            tc.Execute(tractor);
            mf.Execute(tractor);
            Assert.AreEqual(1, tractor.GetPositionX());
            Assert.AreEqual(0, tractor.GetPositionY());

            tc.Execute(tractor);
            mf.Execute(tractor);
            Assert.AreEqual(1, tractor.GetPositionX());
            Assert.AreEqual(-1, tractor.GetPositionY());

            tc.Execute(tractor);
            mf.Execute(tractor);
            Assert.AreEqual(0, tractor.GetPositionX());
            Assert.AreEqual(-1, tractor.GetPositionY());

            tc.Execute(tractor);
            mf.Execute(tractor);
            Assert.AreEqual(0, tractor.GetPositionX());
            Assert.AreEqual(0, tractor.GetPositionY());
        }
예제 #5
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="location">The location containing the garage.</param>
 /// <param name="building">The garage building.</param>
 /// <param name="tractor">The tractor for this garage (if found).</param>
 /// <param name="saveData">The garage save data.</param>
 public GarageMetadata(BuildableGameLocation location, Building building, Tractor tractor, CustomSaveBuilding saveData)
 {
     this.Location = location;
     this.Building = building;
     this.Tractor  = tractor;
     this.SaveData = saveData;
 }
예제 #6
0
        public void TestShouldMoveForward()
        {
            ArrayList unitModels = new ArrayList();

            UnitModel stone = new Stone();

            unitModels.Add(stone);

            UnitModel wild = new Wild();

            unitModels.Add(wild);

            UnitModel tractor = new Tractor();

            unitModels.Add(tractor);

            UnitModel tank = new Tank();

            unitModels.Add(tank);

            UnitModel guardTower = new GuardTower();

            unitModels.Add(guardTower);

            foreach (UnitModel unitModel in unitModels)
            {
                unitModel.Move("F");
                Console.WriteLine(unitModel.GetPositionX().ToString() + " " + unitModel.GetPositionY().ToString());
            }
            Console.WriteLine();
        }
예제 #7
0
        public void TestShouldMoveShot()
        {
            ArrayList unitModels = new ArrayList();

            Stone stone = new Stone();

            unitModels.Add(stone);

            Wild wild = new Wild();

            unitModels.Add(wild);

            Tractor tractor = new Tractor();

            unitModels.Add(tractor);

            Tank tank = new Tank();

            unitModels.Add(tank);

            GuardTower guardTower = new GuardTower();

            unitModels.Add(guardTower);

            foreach (UnitModel unitModel in unitModels)
            {
                unitModel.Move("S");
                //Console.WriteLine(unitModel.GetArmmo());
            }
            Console.WriteLine();
        }
예제 #8
0
        public void TestShouldTurnAndMoveInTheRightDirection()
        {
            Tractor tractor = new Tractor(new Field()
            {
                Height = 5, Width = 5
            });
            var moveCommand = new MoveForwardCommand(tractor);
            var turnCommand = new TurnClockwiseCommand(tractor);

            turnCommand.Execute();
            moveCommand.Execute();
            Assert.AreEqual(1, tractor.UnitPosition.X);
            Assert.AreEqual(0, tractor.UnitPosition.Y);

            turnCommand.Execute();
            moveCommand.Execute();
            Assert.AreEqual(1, tractor.UnitPosition.X);
            Assert.AreEqual(-1, tractor.UnitPosition.Y);

            turnCommand.Execute();
            moveCommand.Execute();
            Assert.AreEqual(0, tractor.UnitPosition.X);
            Assert.AreEqual(-1, tractor.UnitPosition.Y);

            turnCommand.Execute();
            moveCommand.Execute();
            Assert.AreEqual(0, tractor.UnitPosition.X);
            Assert.AreEqual(0, tractor.UnitPosition.Y);
        }
        public IActionResult AssignTractor(AssignTractorViewModel assignTractorViewModel)
        {
            if (ModelState.IsValid)
            {
                //Employee employee = new Employee()
                //{
                //    EmployeeID = assignTractorViewModel.EmployeeID,
                //    TractorID = assignTractorViewModel.TractorID
                //};


                Employee driver = empRepo.GetEmployeeWithId(assignTractorViewModel.EmployeeID);
                Tractor  truck  = truRepo.GetTractorWithId(assignTractorViewModel.TractorID);

                //this is where you need to update DriverTractorAssignmentHistory or do it in the repo.AssignTractor for abstraction purposes
                empRepo.AssignTractor(driver.EmployeeID, truck.TractorID);

                // changes the availability of tractor once assigned
                truRepo.ChangeStatusWithId(driver.TractorID.GetValueOrDefault());

                //adds it to drivertractor history
                dtRepo.AddHistory(driver, truck);

                return(Redirect("/Employee"));
            }
            ;
            return(View(assignTractorViewModel));
        }
예제 #10
0
        public void TestShouldTurnAndMoveInTheRightDirection()
        {
            Tractor tractor = new Tractor(3, 3);

            List <ICommand> commands = new List <ICommand>
            {
                new MoveTurnCommand(tractor),
                new MoveForwardsCommand(tractor)
            };

            Invoker invoker = new Invoker();

            invoker.SetCommand(new MacroCommand(commands));

            invoker.ExecuteCommand();
            Assert.AreEqual(4, tractor.GetPositionX);
            Assert.AreEqual(3, tractor.GetPositionY);

            invoker.ExecuteCommand();
            Assert.AreEqual(4, tractor.GetPositionX);
            Assert.AreEqual(2, tractor.GetPositionY);

            invoker.ExecuteCommand();
            Assert.AreEqual(3, tractor.GetPositionX);
            Assert.AreEqual(2, tractor.GetPositionY);

            invoker.ExecuteCommand();
            Assert.AreEqual(3, tractor.GetPositionX);
            Assert.AreEqual(3, tractor.GetPositionY);
        }
예제 #11
0
        public IActionResult Add(AddTractorViewModel addtractorViewModel)
        {
            if (ModelState.IsValid)
            {
                Tractor newTractor = new Tractor
                {
                    VinNumber   = addtractorViewModel.VinNumber,
                    Make        = addtractorViewModel.Make,
                    Model       = addtractorViewModel.Model,
                    DotInp      = addtractorViewModel.DotInp,
                    Plate       = addtractorViewModel.Plate,
                    TruckNumber = addtractorViewModel.TruckNumber,
                    RegDate     = addtractorViewModel.RegDate,
                    Year        = addtractorViewModel.Year
                };

                //add to tractorData
                context.Tractors.Add(newTractor);
                //always save changes
                context.SaveChanges();

                return(Redirect("/Tractor"));
            }
            ;
            return(View(addtractorViewModel));
        }
        public void TestShouldMoveForward()
        {
            var testing = new Tractor(new Map(5, 5));

            testing.ExecuteCommand(new MoveForwardCommand());
            Assert.AreEqual(0, testing.Position.X);
            Assert.AreEqual(1, testing.Position.Y);
        }
        public static void A_ObjectCanUseItsComponentsWithoutInheritance()
        {
            var tractor = new Tractor(50, 2015, 4);

            tractor.Turn(isTurnRight: true);

            tractor.LoadСargo(3);
        }
예제 #14
0
        public void TestShouldMoveForward()
        {
            Tractor tractor = new Tractor();

            tractor.Move("F");
            Assert.AreEqual(0, tractor.GetPositionX());
            Assert.AreEqual(1, tractor.GetPositionY());
        }
        ////////////// All DriverTractorHistories will be moved to Driver ///////////////////

        // this method will Add new driverTractorHistory to driverHistories Table
        public DriverTractorAssignmentHistory AddHistory(Employee employee, Tractor tractor)
        {
            DriverTractorAssignmentHistory history = new DriverTractorAssignmentHistory(employee, tractor);

            context.DriverTractorsAssignmentHistory.Add(history);
            context.SaveChanges();
            return(history);
        }
예제 #16
0
        /// <summary>Spawn a new tractor.</summary>
        /// <param name="location">The location in which to spawn a tractor.</param>
        /// <param name="tractorID">The tractor's unique horse ID.</param>
        /// <param name="tileX">The tile X position at which to spawn it.</param>
        /// <param name="tileY">The tile Y position at which to spawn it.</param>
        private Tractor SpawnTractor(Guid tractorID, BuildableGameLocation location, int tileX, int tileY)
        {
            Tractor tractor = new Tractor(tractorID, tileX, tileY, this.Config, this.Attachments, this.Helper.Content.GetActualAssetKey(this.GetTextureKey("tractor")), this.Helper.Translation, this.Helper.Reflection);

            tractor.SetLocation(location, new Vector2(tileX, tileY));
            tractor.SetPixelPosition(new Vector2(tractor.Position.X + 20, tractor.Position.Y));
            return(tractor);
        }
예제 #17
0
        public void CanGetTractor()
        {
            Tractor actual = _testRepo.GetTractor(1);

            Assert.AreEqual("Johnny Reb", actual.Name);
            Assert.AreEqual("Kenny Webb", actual.Driver);
            Assert.AreEqual(9990, actual.Weight);
        }
예제 #18
0
        public ActionResult DeleteConfirmed(int id)
        {
            Tractor tractor = db.Tractors.Find(id);

            db.Tractors.Remove(tractor);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #19
0
        /// <summary>
        /// we add two tractors in tractor collection
        /// </summary>
        /// <param name="tractors"></param>
        public static void CreateTractors(LinkedList <Tractor> tractors)
        {
            Tractor tractor = new Tractor(1.5, 2, "petrol", 40, 3000, "F", "CDI", "red", 98783);

            tractors.AddLast(tractor);

            tractor = new Tractor(2, 2, "petrol", 60, 3000, "F", "DDI", "blue", 42222);
            tractors.AddLast(tractor);
        }
        static void Main(string[] args)
        {
            Auto    p1 = new Auto("p1");
            Auto    p2 = new Auto("p2");
            Tractor t1 = new Tractor();

            Console.WriteLine("p1 {0} - p2 {1} - p3 {2}", p1.id.ToString(), p2.id.ToString(), t1.id.ToString());
            Console.Read();
        }
예제 #21
0
        public IActionResult CompleteAssignment(int id)
        {
            Employee driverToUnassignTractor = empRepo.GetEmployeeWithId(id);
            Tractor  tractorToBeUnassigned   = truRepo.GetTractorWithId(driverToUnassignTractor.TractorID.GetValueOrDefault());

            UnassignTractorViewModel unassignTractorViewModel = new UnassignTractorViewModel(driverToUnassignTractor, tractorToBeUnassigned);

            return(View(unassignTractorViewModel));
        }
예제 #22
0
        public void CanDeleteTractor()
        {
            Tractor actual = _testRepo.DeleteTractor(1);

            Assert.AreEqual("Johnny Reb", actual.Name);

            actual = _testRepo.DeleteTractor(42);
            Assert.IsNull(actual);
        }
예제 #23
0
        /// <summary>Restore tractor and garage data removed by <see cref="StashCustomData"/>.</summary>
        /// <remarks>The Robin construction logic is derived from <see cref="NPC.reloadSprite"/> and <see cref="StardewValley.Farm.resetForPlayerEntry"/>.</remarks>
        private void RestoreCustomData()
        {
            // get save data
            CustomSaveData saveData = this.Helper.ReadJsonFile <CustomSaveData>(this.GetDataPath(Constants.SaveFolderName));

            if (saveData?.Buildings == null)
            {
                return;
            }

            // add tractor + garages
            BluePrint blueprint = this.GetBlueprint();

            BuildableGameLocation[] locations = CommonHelper.GetLocations().OfType <BuildableGameLocation>().ToArray();
            foreach (CustomSaveBuilding garageData in saveData.Buildings)
            {
                // get location
                BuildableGameLocation location = locations.FirstOrDefault(p => this.GetMapName(p) == (garageData.Map ?? "Farm"));
                if (location == null)
                {
                    this.Monitor.Log($"Ignored tractor garage in unknown location '{garageData.Map}'.");
                    continue;
                }

                // add garage
                TractorGarage garage = new TractorGarage(garageData.TractorID, blueprint, garageData.Tile, Math.Max(0, garageData.DaysOfConstructionLeft - 1));
                location.buildings.Add(garage);

                // add Robin construction
                if (garage.isUnderConstruction() && !this.IsRobinBusy)
                {
                    this.IsRobinBusy = true;
                    NPC robin = Game1.getCharacterFromName("Robin");

                    // update Robin
                    robin.Sprite.setCurrentAnimation(new List <FarmerSprite.AnimationFrame>
                    {
                        new FarmerSprite.AnimationFrame(24, 75),
                        new FarmerSprite.AnimationFrame(25, 75),
                        new FarmerSprite.AnimationFrame(26, 300, false, false, farmer => this.Helper.Reflection.GetMethod(robin, "robinHammerSound").Invoke(farmer)),
                        new FarmerSprite.AnimationFrame(27, 1000, false, false, farmer => this.Helper.Reflection.GetMethod(robin, "robinVariablePause").Invoke(farmer))
                    });
                    robin.ignoreScheduleToday = true;
                    Game1.warpCharacter(robin, location, new Vector2(garage.tileX + garage.tilesWide / 2, garage.tileY + garage.tilesHigh / 2));
                    robin.position.X += Game1.tileSize / 4;
                    robin.position.Y -= Game1.tileSize / 2;
                    robin.CurrentDialogue.Clear();
                    robin.CurrentDialogue.Push(new Dialogue(Game1.content.LoadString("Strings\\StringsFromCSFiles:NPC.cs.3926"), robin));
                }

                // spawn tractor
                if (this.Tractor == null && !garage.isUnderConstruction())
                {
                    this.Tractor = this.SpawnTractor(garageData.TractorID, location, garage.tileX + 1, garage.tileY + 1);
                }
            }
        }
예제 #24
0
        public static void A_ChildObjectsCanBeUsedAsBase()
        {
            Vehicle tractor = new Tractor(50, 2015, 4);
            Vehicle bicycle = new Bicycle(30);

            var washer = new CarWash();

            washer.Wash(tractor);
            washer.Wash(bicycle);
        }
예제 #25
0
 public ActionResult Edit([Bind(Include = "Id,CarringCapacity,Model,Mileage,PurchaseDate,WriteOffDate,Cat")] Tractor tractor)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tractor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tractor));
 }
예제 #26
0
        public void TestShouldMoveForward()
        {
            var     mf      = new MoveForwardCommand();
            Tractor tractor = new Tractor();

            mf.Execute(tractor);

            Assert.AreEqual(0, tractor.GetPositionX());
            Assert.AreEqual(1, tractor.GetPositionY());
        }
예제 #27
0
        public void TestShouldMoveForward()
        {
            Tractor tractor = new Tractor();
            Invoker invoker = new Invoker();

            invoker.SetCommand(new MoveForwardsCommand(tractor));
            invoker.ExecuteCommand();

            Assert.AreEqual(0, tractor.GetPositionX);
            Assert.AreEqual(1, tractor.GetPositionY);
        }
예제 #28
0
        public ActionResult Create([Bind(Include = "Id,CarringCapacity,Model,Mileage,PurchaseDate,WriteOffDate,Cat")] Tractor tractor)
        {
            if (ModelState.IsValid)
            {
                db.Tractors.Add(tractor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tractor));
        }
        public DriverTractorHistoryViewModel(Employee driver, Tractor tractor, DriverTractorAssignmentHistory driverTractorAssignmentHistory)
        {
            FirstName  = driver.FirstName;
            MiddleName = driver.MiddleName;
            LastName   = driver.LastName;

            EmployeeId = driver.EmployeeID;
            TractorId  = tractor.TractorID;

            TractorNumber = tractor.TruckNumber;
        }
예제 #30
0
    public void damageTractor()
    {
        Tractor tractorState = (Tractor)localScripts[0];

        if (tractorState.state == TractorState.Empty || tractorState.state == TractorState.HasHayOnly)
        {
            tractorState.RemoveFuel();
            depleteFuelAS.Play();
            callChangeStats(tractorState.timeMove, harvestHay, tractorState.timeHarvestRequired);
        }
    }
예제 #31
0
    public static void Main()
    {
        var tractor = new Tractor();
        if (tractor is IGo) {
            tractor.PullPlough();
        }

        var horse = new Horse();
        if (horse is IGo) {
            horse.PullPlough();
        }
    }