This script is in charge of making the player dive. This accomplishes moving the player down as well as rotating their position.
Inheritance: NetworkBehaviour
    /// <summary>
    /// Initializes the variables and objects that are needed by this script.
    /// </summary>
    void Start ()
    {
        PlayerMovement = GetComponent<GoalBallPlayerMovementV1>();
        CatchThrow = GetComponent<CatchThrowV2>();
        dive = GetComponent<Dive>();
        gameTimer = GameObject.FindGameObjectWithTag("GameController").GetComponent<GameTimer>();
	}
Example #2
0
        public void SetUp()
        {
            _judges  = new List <Judge>();
            _divers  = new List <Diver>();
            _contest = new Contest(0, "Nunit Test Contest", "2015-02-02", "Badhuset", 1, 1, 1, 5);

            _judges.Add(new Judge(0, "Mr. Test"));
            _judges.Add(new Judge(1, "Mrs. Fest"));
            _judges.Add(new Judge(2, "Konstapel Kuk"));
            _judges.Add(new Judge(3, "Domherre"));
            _judges.Add(new Judge(4, "McFlash"));

            _divers.Add(new Diver(0, "Kalle"));
            _divers.Add(new Diver(1, "Greger"));
            _divers.Add(new Diver(2, "Skitunge"));

            _contest.AddDivers(_divers);
            _contest.AddJudges(_judges);


            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    Dive dive = new Dive(0, null, j + 1, _contest);
                    _contest.Divers[i].AddDive(dive);

                    for (int k = 0; k < 5; k++)
                    {
                        Score s = new Score(0, null, _judges[k], (k + j) % 11);
                        dive.AddScore(s);
                    }
                }
            }
        }
        private void NewDiveButton_Click(object sender, RoutedEventArgs e)
        {
            Dive toAdd = GetDive(DiveCodeText.Text, Board);

            diveList.Add(toAdd);
            DiveListBox.Items.Add(toAdd);
        }
Example #4
0
        public async Task <IActionResult> AddCompetitors(int CompetitorName)
        {
            int competitionId = (int)TempData["CompetitionId"];

            var newLink = new CompetitionCompetitor
            {
                CompetitionId = competitionId,
                CompetitorId  = CompetitorName
            };


            if (!_context.CompetitionCompetitor.Any(cc => cc.CompetitorId == newLink.CompetitorId && cc.CompetitionId == newLink.CompetitionId))
            {
                _context.CompetitionCompetitor.Add(newLink);
            }

            int DivesToCreate = 5;

            // Create 5 dives associated to the added competitor
            for (int i = 0; i < DivesToCreate; i++)
            {
                var newDive = new Dive
                {
                    CompetitionId = competitionId,
                    CompetitorId  = CompetitorName
                };

                _context.Dive.Add(newDive);
            }

            _context.SaveChanges();
            return(RedirectToAction("AddCompetitors"));
        }
Example #5
0
        /// <summary>
        /// Return equipment to warehouse
        /// </summary>
        /// <param name="dive"></param>
        public void ReturnEquipment(Dive dive, List <Diver> diverList)
        {
            DateTime diveDate = dive.dateTime;

            Writer.PrintEquipmentReturnHeading(dive);

            foreach (Diver diver in diverList)
            {
                for (int i = diver.EquipmentList.Count() - 1; i >= 0; i--)
                {
                    // Check whether diver must return the equipment
                    if (evictionStrategy.DidLoanDateExpired(diveDate, diver.EquipmentList[i]) ||
                        evictionStrategy.CheckIfEnoughDiversForDive(dive, diver))
                    {
                        // Calculate return date
                        DateTime returnDate = diveDate >= diver.EquipmentList[i].loanDate.AddDays(diver.EquipmentList[i].maxLoanDays) ?
                                              diver.EquipmentList[i].loanDate.AddDays(diver.EquipmentList[i].maxLoanDays) :
                                              diveDate;
                        // Return equipment to storage
                        diver.EquipmentList[i].ReturnEquipment();

                        // Console log about equipment return info
                        Writer.PrintEquipmentReturn(returnDate, diver, diver.EquipmentList[i]);

                        // Delete equipment from diver
                        diver.EquipmentList.RemoveAt(i);
                    }
                }
            }
        }
Example #6
0
 public void EquipDiver(Diver diver, Dive dive)
 {
     foreach (Equipment equipment in childEquipments)
     {
         equipment.EquipDiver(diver, dive);
     }
 }
Example #7
0
        public static void PrintEquipmentPerDiverInDive(Dive dive)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendFormat("\n\n###### URON ######\n");
            builder.AppendFormat("Datum: \t\t{0}\nTemperatura: \t{1}°C\nBroj ronioca: \t{2}/{3}\n", dive.dateTime, dive.temperature, dive.NumOfDivers, dive.numOfDiversNeeded);
            builder.AppendFormat("Noćni uron: \t{0}\nFotografi: \t{1}\n\n", dive.isNightDive ? "Da" : "Ne", dive.numOfPhotographers);

            // If there is enough divers for dive then print them otherwise print message
            if (dive.NumOfDivers == dive.numOfDiversNeeded)
            {
                foreach (Diver diver in dive.Divers)
                {
                    builder.AppendFormat("\n{0} - {1}\n", diver.name, diver.equipmentStatus);
                    foreach (ConcreteEquipment equipment in diver.EquipmentList)
                    {
                        builder.AppendFormat("{0}\n", equipment.name);
                    }

                    builder.AppendFormat("\n\n");
                }
            }

            else
            {
                builder.Append("Za uron nema dovoljno ronioca! Svi ronioci iz urona vraćaju robu ukoliko ju imaju.");
            }

            Console.WriteLine(builder.ToString());
        }
Example #8
0
        public async Task <IActionResult> JudgeView(int id, [Bind("Id,CompetitionId,CompetitorId,DiveGroup,Judge1,Judge2,Judge3")] Dive dive)
        {
            if (id != dive.Id)
            {
                return(NotFound());
            }

            // Searches through the DB for the match where the divegroups match. The DiveGroup which match are put in a variable
            DiveGroup link = await _context.DiveGroup.Where(cc => cc.Dive == dive.DiveGroup).FirstAsync();

            double?diff = link.Difficulty;  //Gets the difficulty from the variable that matched the dive

            // Checks the median of all dives and takes the difficulty and multiplies it to the median score
            // E.g: If J1 < J2 and J2 < J3 OR J3 < J2  and J2 < J1, then J2 is the median
            if (ModelState.IsValid)
            {
                try
                {
                    if ((dive.Judge1 < dive.Judge2 && dive.Judge2 < dive.Judge3) || (dive.Judge3 < dive.Judge2 && dive.Judge2 < dive.Judge1))
                    {
                        dive.Score = dive.Judge2 * diff * 3;
                    }

                    else if ((dive.Judge2 < dive.Judge1 && dive.Judge1 < dive.Judge3) || (dive.Judge3 < dive.Judge1 && dive.Judge1 < dive.Judge2))
                    {
                        dive.Score = dive.Judge1 * diff * 3;
                    }

                    else
                    {
                        dive.Score = dive.Judge3 * diff * 3;
                    }


                    _context.Update(dive);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DiveExists(dive.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                return(RedirectToAction("JudgeDives", new { dive.CompetitorId, dive.CompetitionId }));
            }
            ViewData["CompetitionId"] = new SelectList(_context.Competition, "Id", "Id", dive.CompetitionId);
            ViewData["CompetitorId"]  = new SelectList(_context.Competitor, "Id", "Id", dive.CompetitorId);

            // Gets all of the divecategories and outs them in a list
            ViewData["divecategories"] = new SelectList(_context.DiveGroup, "Dive", "Dive", dive.DiveGroup);

            return(View(dive));
        }
Example #9
0
        private void SetLoanDate(Dive dive)
        {
            // Set loan date to dive date
            loanDate = dive.dateTime;

            // Set max loan days
            maxLoanDays = Config.Random.Next(1, Config.MaxLoanDays);
        }
Example #10
0
        public ActionResult DeleteConfirmed(int id)
        {
            Dive dive = db.Dives.Find(id);

            db.Dives.Remove(dive);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #11
0
        static void Main(string[] args)
        {
            if (!args.Count().Equals(10))
            {
                Console.WriteLine("Neispravan broj argumenata!");
            }
            else
            {
                // Save arguments to variables
                int    rowNumber         = Int32.Parse(args[0]);
                int    colNumber         = Int32.Parse(args[1]);
                int    cacheCapacity     = Int32.Parse(args[2]);
                string filePathDivers    = args[3];
                string filePathSpecialty = args[4];
                string fileEquipmentPath = args[5];
                int    depth             = Int32.Parse(args[6]);
                int    temperature       = Int32.Parse(args[7]);
                bool   nightDive         = args[8] == "0" ? false : true;
                int    camera            = Int32.Parse(args[9]);

                // Validation
                rowNumber     = (rowNumber >= 24 && rowNumber <= 40) ? rowNumber : 24;
                colNumber     = (colNumber >= 80 && colNumber <= 160) ? colNumber : 80;
                cacheCapacity = (cacheCapacity >= rowNumber && cacheCapacity <= 400) ? cacheCapacity : rowNumber;
                depth         = (depth >= 5 && depth <= 40) ? depth : 40;
                temperature   = (temperature >= 0 && temperature <= 35) ? temperature : 10;
                camera        = (camera >= 0 && camera <= 5) ? camera : 0;

                // Read files
                string[] diversRaw     = Reader.ReadFile(filePathDivers);
                string[] superPowerRaw = Reader.ReadFile(filePathSpecialty);
                string[] equipmentRaw  = Reader.ReadFile(fileEquipmentPath);

                Dive dive = new Dive(depth, temperature, nightDive, camera);

                // Cache init
                Cache cache = Cache.GetInstance();
                cache.InitCache(cacheCapacity * colNumber, rowNumber - 1);

                // Model
                DiversManagement    diversManagement    = new DiversManagement(dive);
                EquipmentManagement equipmentManagement = new EquipmentManagement();
                // View
                DiversView diversView = new DiversView(rowNumber, colNumber);
                // Controller
                DiversController diversController = new DiversController(diversManagement, diversView);

                diversManagement.AddDiversToList(diversRaw, superPowerRaw);
                diversManagement.FilterDivers(depth, temperature, nightDive);

                equipmentManagement.LoadEquipment(equipmentRaw);
                diversManagement.AssignEquipmentToDivers(equipmentManagement.GetAllEquipment(), dive);

                // Add controller to view
                diversView.StateController = diversController;
                diversController.Initialize();
            }
        }
 public ChangeScoreWindow(string name, Dive dive, double[] scores)
 {
     InitializeComponent();
     DiverNameBlock.Text     = name;
     DiveCodeBlock.Text      = "Scores for : " + dive.Code + " - " + dive.Description;
     JudgeOneScoreBox.Text   = "" + scores[0];
     JudgeTwoScoreBox.Text   = "" + scores[1];
     JudgeThreeScoreBox.Text = "" + scores[2];
 }
Example #13
0
 public static void PrintEquipmentReturnHeading(Dive dive)
 {
     Console.WriteLine("---------------------------------------------------------------------------------------------");
     Console.WriteLine("#############################################################################################");
     Console.WriteLine("---------------------------------------------------------------------------------------------");
     Console.WriteLine("\nPOVRAT OPREME NA DATUME PRIJE URONA - {0}\n", dive.dateTime);
     Console.WriteLine("{0,-8}{1,-40}{2,-24}{3,-10}{4}", "IME", "OPREMA", "DATUM POSUDBE", "BR. DANA", "DATUM POVRATA");
     Console.WriteLine("{0,-8}{1,-40}{2,-24}{3,-10}{4}", "---", "------", "--------------", "-------", "-------------");
 }
        public void TestAddAndRemoveNewDive()
        {
            // Tests the adding of a new dive, when it is the first dive of the diver
            Dive dive = new Dive(new DiveCode(3.1));

            branch.AddNewDive(contestantList.ElementAt(0), dive);
            Dive diveToCheck = null;

            diveToCheck = branch.BranchContestants.ElementAt(0).DiveLists.ElementAt(0).ElementAt(0);

            Assert.AreEqual(dive, diveToCheck);

            // Tests the adding of a second jump of a diver on same branch

            Dive dive2 = new Dive(new DiveCode(2));

            branch.AddNewDive(contestantList.ElementAt(0), dive2);

            diveToCheck = branch.BranchContestants.ElementAt(0).DiveLists.ElementAt(0).ElementAt(1);

            Assert.AreEqual(dive2, diveToCheck);


            // Tests adding a new dive on a new branch

            SubContestBranch branch2 = new SubContestBranch("testbranch2", contest, contestantList);

            Dive dive3 = new Dive(new DiveCode(3.0));

            branch2.AddNewDive(contestantList.ElementAt(0), dive3);

            diveToCheck = branch2.BranchContestants.ElementAt(0).DiveLists.ElementAt(1).ElementAt(0);

            Assert.AreEqual(dive3, diveToCheck);


            // Tests removing of a dive that was added by mistake?

            Assert.IsTrue(branch.RemoveExistingDive(contestantList.ElementAt(0), dive2));

            // Checks if the element we removed is still there
            // If ArgumentOutOfRangeException is triggered the test is valid
            try
            {
                contestantList.ElementAt(0).DiveLists.ElementAt(0).ElementAt(1);
                Assert.Fail();
            }
            catch (ArgumentOutOfRangeException)
            {
            }


            // Tests removing of a dive that doesnt exist

            Assert.IsFalse(branch.RemoveExistingDive(contestantList.ElementAt(1), dive2));
        }
Example #15
0
        public void GetById_Should_Return_Correct_Dive()
        {
            // Arrange

            //Act
            Dive testDive = _DiveRepo.GetSingle(1);

            //Assert
            Assert.AreEqual(1, testDive.Id);
        }
Example #16
0
    /// <summary>
    /// Search for the dive that has the given dive code and boardHeight
    /// </summary>
    /// <param name="diveCode">The code of the dive. Capitalization doesn't matter.</param>
    /// <param name="boardHeight">The height of the board in meters. eg: 1m</param>
    /// <returns>A Dive object that corresponds to the query or null if not found.</returns>
    public Dive GetDive(string diveCode, string boardHeight)
    {
        Dive d = dives.FirstOrDefault(x => x.Code == diveCode.ToUpper() && x.Board == boardHeight.ToUpper());

        if (d == null)
        {
            d = new Dive();
        }
        return(d);
    }
Example #17
0
        public void Create__result_contains_samples()
        {
            var dive = new Dive(1, 400, 400, "image");
            var pixel = (new[] { new Pixel(1, 1), new Pixel(2, 3), new Pixel(3, 5), new Pixel(4, 5), new Pixel(5, 1) }).ToList();

            var fac = new SampleFactory();

            var processedDive = fac.Create(pixel, dive);
            processedDive.Samples.Count.Should().Be(pixel.Count);
        }
Example #18
0
        public IActionResult Post([FromBody] Dive dive)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _divingService.AddDive(dive);

            return(CreatedAtAction("/api/getdives", dive));
        }
Example #19
0
        public void Update_Should_ChangeDive()
        {
            // Arrange
            Dive testDive = new Dive(2, "Update", 12, 12);

            //Act
            _DiveRepo.Update(testDive);

            //Assert
            Assert.AreEqual("Update", _MockLstDives[1].Location);
        }
Example #20
0
        public void Delete_Should_Return_Decreased_MockLstDives()
        {
            // Arrange
            Dive testDive = _MockLstDives.First(i => i.Id == 1);

            //Act
            _DiveRepo.Delete(testDive);

            //Assert
            Assert.AreEqual(1, _MockLstDives.Count);
        }
Example #21
0
        private void ChangeDiveButton_Click(object sender, RoutedEventArgs e)
        {
            int      index = DiveListBox.SelectedIndex;
            InputBox ib    = new InputBox("New Dive", "What is the new dive code?", diveList[index].Code);

            ib.ShowDialog();
            string newCode = ib.result;
            Dive   newDive = GetDive(newCode, Board);

            diveList[index]          = newDive;
            DiveListBox.Items[index] = newDive;
        }
Example #22
0
        public void Insert_Should_Return_Increased_MockLstDives()
        {
            // Arrange
            Dive testDive = new Dive(3, "TestDive", 25, 300);

            //Act
            _DiveRepo.Add(testDive);
            var after = (IList <Dive>)_DiveRepo.GetAll();

            //Assert
            Assert.AreEqual(3, after.Count);
        }
Example #23
0
        private void RemoveButton_Click(object sender, RoutedEventArgs e)
        {
            if (DiveListBox.SelectedIndex == -1)
            {
                return;
            }
            Dive toRemove = (Dive)(DiveListBox.SelectedItem);
            int  index    = diveList.FindIndex(x => x.Code == toRemove.Code);

            diveList.RemoveAt(index);
            DiveListBox.Items.RemoveAt(index);
        }
Example #24
0
        public async Task <IActionResult> Create([Bind("Id,CompetitionId,CompetitorId,DiveGroup,Judge1,Judge2,Judge3,FinalScore")] Dive dive)
        {
            if (ModelState.IsValid)
            {
                _context.Add(dive);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CompetitionId"] = new SelectList(_context.Competition, "Id", "Id", dive.CompetitionId);
            ViewData["CompetitorId"]  = new SelectList(_context.Competitor, "Id", "Id", dive.CompetitorId);
            return(View(dive));
        }
Example #25
0
        public IActionResult Delete(int id)
        {
            Dive foundDive = _divingService.GetDive(id);

            if (foundDive == null)
            {
                return(NotFound());
            }
            else
            {
                return(Ok());
            }
        }
Example #26
0
        /// <summary>
        /// Equip diver with adequate equipment for dive
        /// - Hope your eyes won't bleed on this one
        /// </summary>
        /// <param name="diver">Diver that we're equipping</param>
        /// <param name="dive">Dive for which we're equipping diver</param>
        public void EquipDiver(Diver diver, Dive dive)
        {
            // Equip with basic equipment
            if (EquipmentHelper.IsBasicEquipment(this))
            {
                LendEquipment(dive, diver);
            }

            // Equip with dry suit
            else if (dive.temperature < Constants.TEMPERATURE_BOUNDARY && EquipmentHelper.IsDrySuit(this) && !diver.CheckIfDiverNeedUndersuit())
            {
                LendEquipment(dive, diver);
            }

            // Equip with undersuit
            else if (EquipmentHelper.IsUndersuit(this) && diver.CheckIfDiverNeedUndersuit())
            {
                LendEquipment(dive, diver);
            }

            // Equip with wet suit
            else if (dive.temperature >= Constants.TEMPERATURE_BOUNDARY && EquipmentHelper.IsWetSuit(this))
            {
                LendEquipment(dive, diver);
            }

            // Equip with hood if needed
            else if (dive.temperature >= 15 && EquipmentHelper.IsHood(this) && diver.CheckIfDiverNeedHood())
            {
                LendEquipment(dive, diver);
            }

            // Equip with equipment for night dive
            else if (dive.isNightDive && needForNightDive == Constants.EQUIPMENT_NEEDED && diver.CheckIfDiverHasSuperPower(Constants.NIGHT_DIVE))
            {
                LendEquipment(dive, diver);
            }

            // Equip with equipment for photographers
            else if (dive.numOfPhotographers > 0 && diver.CheckIfDiverHasSuperPower(Constants.PHOTOGRAPHER) && needForRecording == Constants.EQUIPMENT_NEEDED)
            {
                LendEquipment(dive, diver);
            }

            // Additional equipment
            else if (EquipmentHelper.IsAdditionalEquipment(this) && temperature != "#" && dive.temperature < 20 ||
                     EquipmentHelper.IsAdditionalEquipment(this) && temperature == "#")
            {
                LendEquipment(dive, diver);
            }
        }
Example #27
0
        // GET: Dive/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Dive dive = db.Dives.Find(id);

            if (dive == null)
            {
                return(HttpNotFound());
            }
            return(View(dive));
        }
        public void Setup()
        {
            _diverepositoryMock = new Mock <IDiveRepository>();
            _divingService      = new DivingService(_diverepositoryMock.Object);

            _MockLstDives = new List <Dive>();
            Dive Diveone = new Dive(1, "Cyprus", 15, 30);
            Dive Divetwo = new Dive(2, "Crete", 17, 100);

            _MockLstDives = new List <Dive>();

            _MockLstDives.Add(Diveone);
            _MockLstDives.Add(Divetwo);
        }
Example #29
0
        public void Setup()
        {
            Dive Diveone = new Dive(1, "Cyprus", 15, 30);
            Dive Divetwo = new Dive(2, "Crete", 17, 100);

            _MockLstDives = new List <Dive>();

            _MockLstDives.Add(Diveone);
            _MockLstDives.Add(Divetwo);

            _DiveMock = new Mock <IDiveRepository>();

            //All Dives
            _DiveMock.Setup(m => m.GetAll()).Returns(_MockLstDives);

            ///GetByID
            _DiveMock.Setup(m =>
                            m.GetSingle(It.Is <int>(i => i == 1 || i == 2 || i == 3 || i == 4))).Returns <int>(r => new Dive
            {
                Id       = r,
                Location = string.Format("Fake Dive {0}", r)
            });

            //Add Dive
            _DiveMock.Setup(m => m.Add(It.IsAny <Dive>())).Callback(new Action <Dive>(
                                                                        x =>
            {
                _MockLstDives.Add(x);
            }
                                                                        ));


            //Delete Dive
            _DiveMock.Setup(x => x.Delete(It.IsAny <Dive>())).Callback(new Action <Dive>(x =>
            {
                _MockLstDives.RemoveAll(d => d.Id == x.Id);
            }
                                                                                         ));


            //Update Dive
            _DiveMock.Setup(x => x.Update(It.IsAny <Dive>())).Callback(new Action <Dive>(x =>
            {
                var found      = _MockLstDives.Find(c => c.Id == x.Id);
                found.Location = x.Location;
            }));

            _DiveRepo = _DiveMock.Object;
        }
Example #30
0
        public void Post_ValidDive_Should_Return_CreatedResponse()
        {
            // Arrange
            Dive             testItem        = new Dive(3, "Karpathos", 25, 200);
            DiversController DivesController = new DiversController(_MockDivingService.Object);

            // Act
            IActionResult createdResponse = DivesController.Post(testItem);
            var           OkCreated       = createdResponse as CreatedAtActionResult;

            // Assert
            Assert.IsNotNull(createdResponse);
            Assert.AreEqual(201, OkCreated.StatusCode);
            Assert.IsInstanceOf <CreatedAtActionResult>(createdResponse);
        }
Example #31
0
 public void EquipDiver(Diver diver, Dive dive)
 {
     // Equip with basic equipment
     if (diver.IsBasicEquipmentAssociation() == true &&
         temperature == "#" &&
         needForRecording == "#" &&
         needForNightDive == "#" &&
         stock > 0 &&
         !diver.CheckExistingEquipmentByCategory(ID))
     {
         diver.AddEquipment(this);
         stock--;
     }
     // Equip with dry suits
     if (dive.GetTemperature() < 15 &&
         (ID.StartsWith("1.1.3.") || ID.StartsWith("1.2.") || ID.StartsWith("1.4.") || (ID.StartsWith("1.3.") && temperature != "#" && Int32.Parse(temperature) < 15)) &&
         stock > 0 &&
         !diver.CheckExistingEquipmentByCategory(ID))
     {
         diver.AddEquipment(this);
         stock--;
     }
     // Equip with wet suits
     else if (dive.GetTemperature() >= 15 &&
              (ID.StartsWith("1.1.1.") || ID.StartsWith("1.1.2.") || (ID.StartsWith("1.3.") && temperature != "#" && Int32.Parse(temperature) >= 15)) &&
              stock > 0 &&
              !diver.CheckExistingEquipmentByCategory(ID))
     {
         diver.AddEquipment(this);
         stock--;
     }
     // Equip with equipment for night dive
     if (dive.IsNightDive() == true &&
         needForNightDive == "*" &&
         !diver.CheckExistingEquipmentByCategory(ID))
     {
         diver.AddEquipment(this);
         stock--;
     }
     // Equip with equipment for fotographers
     if (diver.CheckIfDiverHasSuperPower("Podvodni fotograf") == true &&
         needForRecording == "*" &&
         !diver.CheckExistingEquipmentByCategory(ID))
     {
         diver.AddEquipment(this);
         stock--;
     }
 }
Example #32
0
        public void RunScoreDive()
        {
            Assert.LessOrEqual(_divers[0].Dives[0].Score, 30);

            Diver tDiver = new Diver(-1, "Greger");
            Dive  tDive  = new Dive(-1, tDiver, 1, _contest);

            tDiver.AddDive(tDive);
            tDive.AddScore(new Score(0, tDive, _judges[0], 1));
            tDive.AddScore(new Score(0, tDive, _judges[1], 5));
            tDive.AddScore(new Score(0, tDive, _judges[2], 5));
            tDive.AddScore(new Score(0, tDive, _judges[3], 5));
            tDive.AddScore(new Score(0, tDive, _judges[4], 10));

            Assert.AreEqual(tDive.Score, 15);
        }
Example #33
0
        public void Create__runs_mulitple_post_processing()
        {
            var dive = new Dive(1, 400, 400, "image");
            var pixel = (new[] { new Pixel(0, 0), new SkipPixel(1, 2), new SkipPixel(2, 4), new Pixel(3, 4), new Pixel(4, 0) }).ToList();
            var postProcess1 = new Mock<IPostProcessing>();
            var postProcess2 = new Mock<IPostProcessing>();

            var fac = new SampleFactory();
            fac.AddPostProcessing(postProcess1.Object);
            fac.AddPostProcessing(postProcess2.Object);

            var processedDive = fac.Create(pixel, dive);

            postProcess1.Verify(pp => pp.Process(processedDive), Times.Once());
            postProcess2.Verify(pp => pp.Process(processedDive), Times.Once());
        }
Example #34
0
        public void Create__calculate_average_for_skip_pixels()
        {
            throw new NotImplementedException("implement");
            var dive = new Dive(1, 400, 400, "image");
            var pixel = (new[] { new Pixel(0, 0), new SkipPixel(1, 2), new SkipPixel(2, 4), new Pixel(3, 4), new Pixel(4, 0) }).ToList();

            var fac = new SampleFactory();
            var processedDive = fac.Create(pixel, dive);

            processedDive.Samples.Should().HaveCount(3);

            processedDive.Samples[0].Depth.Should().Be(0);
            processedDive.Samples[0].SecondsSinceStart.Should().Be(0);

            processedDive.Samples[1].Depth.Should().Be(400);
            processedDive.Samples[1].SecondsSinceStart.Should().Be(300);

            processedDive.Samples[2].Depth.Should().Be(0);
            processedDive.Samples[2].SecondsSinceStart.Should().Be(400);
        }
Example #35
0
        public void RemoveLastPlainFromPixelList__removes_the_last_pixels_from_list()
        {
            var dive = new Dive(1, 1, 2, "image");
            var pixel = (new[] { new Pixel(1, 1), new Pixel(2, 3), new Pixel(3, 5), new Pixel(4, 1), new Pixel(5, 1), new Pixel(6, 1), new Pixel(7, 1), new Pixel(8, 1) }).ToList();

            var fac = new SampleFactory();
            fac.RemoveLastPlainFromPixelList(pixel);

            pixel.Count().Should().Be(4);
            pixel[0].X.Should().Be(1);
            pixel[1].X.Should().Be(2);
            pixel[2].X.Should().Be(3);
            pixel[3].X.Should().Be(4);
        }
Example #36
0
        public void Create__samples_have_correct_values()
        {
            var dive = new Dive(1, 400, 400, "image");
            var pixel = (new[] { new Pixel(0, 0), new Pixel(1, 2), new Pixel(2, 4), new Pixel(3, 4), new Pixel(4, 0) }).ToList();

            var fac = new SampleFactory();

            var processedDive = fac.Create(pixel, dive);

            processedDive.Samples[0].Depth.Should().Be(0);
            processedDive.Samples[0].SecondsSinceStart.Should().Be(0);

            processedDive.Samples[1].Depth.Should().Be(200);
            processedDive.Samples[1].SecondsSinceStart.Should().Be(100);

            processedDive.Samples[2].Depth.Should().Be(400);
            processedDive.Samples[2].SecondsSinceStart.Should().Be(200);

            processedDive.Samples[3].Depth.Should().Be(400);
            processedDive.Samples[3].SecondsSinceStart.Should().Be(300);

            processedDive.Samples[4].Depth.Should().Be(0);
            processedDive.Samples[4].SecondsSinceStart.Should().Be(400);
        }
 public IEnumerable<DlImageParsr.Model.Dive> LoadDives()
 {
     var dives = new Dive[] { new Dive(1, 1000, 500, "testimage1.png"), new Dive(2, 500, 500, "testimage1.png") };
     return dives;
 }
Example #38
0
        public void Create__using_first_pixel_as_origin_and_returns_samples_having_correct_values()
        {
            var dive = new Dive(1, 400, 400, "image");
            var pixel = (new[] { new Pixel(70, 50), new Pixel(71, 52), new Pixel(72, 54), new Pixel(73, 54), new Pixel(74, 50) }).ToList();

            var fac = new SampleFactory();

            var processedDive = fac.Create(pixel, dive);

            processedDive.Samples[0].Depth.Should().Be(0);
            processedDive.Samples[0].SecondsSinceStart.Should().Be(0);

            processedDive.Samples[1].Depth.Should().Be(200);
            processedDive.Samples[1].SecondsSinceStart.Should().Be(100);

            processedDive.Samples[2].Depth.Should().Be(400);
            processedDive.Samples[2].SecondsSinceStart.Should().Be(200);

            processedDive.Samples[3].Depth.Should().Be(400);
            processedDive.Samples[3].SecondsSinceStart.Should().Be(300);

            processedDive.Samples[4].Depth.Should().Be(0);
            processedDive.Samples[4].SecondsSinceStart.Should().Be(400);
        }
Example #39
0
        public void GetDepthResolution__returns_correct_value_with_rounding_up()
        {
            var pixel = (new[] { new Pixel(1, 1), new Pixel(2, 16), new Pixel(3, 15), new Pixel(4, 10), new Pixel(5, 1), new Pixel(6, 1), new Pixel(7, 1), new Pixel(8, 1) }).ToList();
            var dive = new Dive(2, 30, 2, "image");
            var fac = new SampleFactory();
            var ret1 = fac.GetDepthResolution(pixel, dive);

            ret1.Should().Be(2);
        }
Example #40
0
        public void GetDepthResolution__uses_origin_and_returns_correct_value()
        {
            var pixel = (new[] { new Pixel(51, 71), new Pixel(52, 73), new Pixel(53, 75), new Pixel(54, 80), new Pixel(55, 71), new Pixel(56, 71), new Pixel(57, 71), new Pixel(58, 71) }).ToList();
            var dive = new Dive(2, 30, 2, "image");
            var fac = new SampleFactory();
            var ret1 = fac.GetDepthResolution(pixel, dive);

            ret1.Should().Be(3);
        }
Example #41
0
        public void GetDepthResolution__wont_fail_on_null_or_empty()
        {
            var dive = new Dive(1, 1, 2, "image");
            var fac = new SampleFactory();
            var ret1 = fac.GetDepthResolution(null, null);

            var ret2 = fac.GetDepthResolution(new List<Pixel> { }, null);

            ret1.Should().Be(-1);
            ret2.Should().Be(-1);
        }
Example #42
0
        public void GetTimeResolution__gets_resolution_round_up()
        {
            var dive = new Dive(1, 1, 68, "image");
            var pixel = (new[] { new Pixel(1, 1), new Pixel(2, 3), new Pixel(3, 5), new Pixel(4, 5), new Pixel(5, 3), new Pixel(6, 1) }).ToList();

            var fac = new SampleFactory();
            var resoluion = fac.GetTimeResolution(pixel, dive);

            resoluion.Should().Be(14);
        }
Example #43
0
        public void GetTimeResolution__removes_the_last_pixels_from_list()
        {
            var dive = new Dive(1, 1, 2, "image");
            var pixel = (new[] { new Pixel(1, 1), new Pixel(2, 3), new Pixel(3, 5), new Pixel(4, 1), new Pixel(5, 1), new Pixel(6, 1), new Pixel(7, 1), new Pixel(8, 1) }).ToList();

            var fac = new SampleFactory();
            fac.GetTimeResolution(pixel, dive);

            pixel.Count().Should().Be(4);
        }
    /// <summary>
    /// Initializes the variables and objects that are needed by this script.
    /// </summary>
    void Start ()
    {
        PlayerMovement = GetComponent<GoalBallPlayerMovementV1>();
        CatchThrow = GetComponent<DEBUGCatchThrowV2>();
        dive = GetComponent<Dive>();
	}
Example #45
0
        public void RemoveLastPlainFromPixelList__wont_fail_on_null_or_empty()
        {
            var dive = new Dive(1, 1, 2, "image");
            var fac = new SampleFactory();
            fac.RemoveLastPlainFromPixelList(null);

            fac.RemoveLastPlainFromPixelList(new List<Pixel> { });

            true.Should().BeTrue();
        }