Ejemplo n.º 1
0
    // 攻撃時の判定にしか使ってません
    void OnCollisionStay2D(Collision2D collision)
    {
        // 敵の攻撃なら処理しない
        if (collision.gameObject.tag == "EnemyAttack")
        {
            return;
        }
        // アイテムなら処理しない
        if (collision.gameObject.tag == "Items")
        {
            return;
        }

        BoatDamage boatDamage = collision.gameObject.GetComponent <BoatDamage> ();

        // ダメージ処理でfalseが帰ってきたらまだダメージ時間中
        if (!boatDamage.DamageBoat(AttackPower))
        {
            return;
        }
        // ヒットSE再生
        hitSE.Play();

        // 船を沈める処理
        if (boatDamage.IsDead())
        {
            gameCtrl.DownBoat();
            Destroy(collision.gameObject);
        }
    }
Ejemplo n.º 2
0
    bool isStartAct = false;            // 行動開始するか

    // Use this for initialization
    void Start()
    {
        // 他のクラスでも使う関数を切り出した
        //generalFunc = new GeneralFunc ();

        // 左右の向きを親クラスから取得
        moveX  = this.GetComponentInParent <MoveX>();
        isLeft = moveX.GetIsLeft();

        // コピー用銛をDeactiveに
        boatSpear.SetActive(false);

        // 一斉攻撃のタイミング取得用
        // BoatManagerはGameController経由で取得
        gameControllerObj = GameObject.FindWithTag("GameController");
        gameCtrl          = gameControllerObj.GetComponent <GameController>();
        boatManager       = gameCtrl.GetBoatManager();


        // 設定値取得等の初期設定
        InitSetting();

        // ダメージの確認用
        boatDamage = this.GetComponent <BoatDamage> ();

        // 銛関係のマネージャ
        GameObject   obj           = new GameObject("SpearManger");
        SpearManager smAddComponet = obj.AddComponent <SpearManager> ();

        spearManager = smAddComponet;
    }
Ejemplo n.º 3
0
        public void AddreportToDB_AddDamageReportToDataBase_ResultIsTrue()
        {
            //Arrange
            var report = new BoatDamage
            {
                boatId             = 1,
                memberId           = 1,
                boatDamageLevel    = 2,
                boatDamageLocation = "Voor",
                boatDamageReason   = "Sawwy",
                reportDate         = DateTime.Now,
                boatImageBlob      = ""
            };
            var result = false;

            //Act
            //Method is placed inside a try block, so if it cant connect the result is set to false
            try
            {
                BoatDamage.AddReportToDb(report);

                //Check if the member is actually in the database
                using (var context = new BootDB())
                {
                    var Damages = from d in context.BoatDamages
                                  where d.boatId == report.boatId && d.memberId == report.memberId && d.boatDamageLevel == report.boatDamageLevel && d.boatDamageLocation == report.boatDamageLocation && d.boatDamageReason == report.boatDamageReason
                                  select d;

                    if (Damages.ToList().Count > 0)
                    {
                        result = true;
                    }
                }

                //Remove test member form database
                using (var context = new BootDB())
                {
                    context.BoatDamages.Attach(report);
                    context.BoatDamages.Remove(report);
                    context.SaveChanges();
                }
            }
            catch (Exception)
            {
                result = false;
            }

            //Assert
            Assert.True(result);
        }
Ejemplo n.º 4
0
        //Method to load a list of damage reports
        private void LoadDamageReports()
        {
            var reports = new List <BoatDamage>();

            using (var context = new BootDB())
            {
                //tables used: Boats - BoatsTypes - BoatDamages - Reservations- Members
                //selected boat name, boat type description, damage level, damage location, reason the boat is damaged, date teh report was made, who reported the damage
                var data = from m in context.Members
                           join bd in context.BoatDamages
                           on m.memberId equals bd.memberId
                           join b in context.Boats
                           on bd.boatId equals b.boatId
                           join bt in context.BoatTypes
                           on b.boatTypeId equals bt.boatTypeId
                           where bd.boatId == BoatId
                           select new
                {
                    boatImageBlob        = bd.boatImageBlob,
                    boatName             = b.boatName,
                    boatDesc             = bt.boatTypeDescription,
                    boatDamageLevel      = bd.boatDamageLevel,
                    boatDamageLocation   = bd.boatDamageLocation,
                    boatDamageReason     = bd.boatDamageReason,
                    boatDamageReportDate = bd.reportDate,
                    boatDamageReporter   = m.memberName
                };

                //add all reports to list
                foreach (var d in data)
                {
                    reports.Add(new BoatDamage
                    {
                        boatImageBlob        = d.boatImageBlob,
                        boatDamageLevelText  = BoatDamage.DamageLevelToString(d.boatDamageLevel),
                        boatDamageLocation   = d.boatDamageLocation,
                        boatDamageReason     = d.boatDamageReason,
                        boatDamageReportDate = d.boatDamageReportDate.ToString("dd-MM-yyyy"),
                        boatDamageReporter   = d.boatDamageReporter
                    });

                    nameLabel.Content        = d.boatName;
                    descriptionLabel.Content = d.boatDesc;
                }
            }
            //add list with reports to the grid
            ReportList.ItemsSource = reports;
        }
Ejemplo n.º 5
0
        public void DamageLevelToString_Input2MethodOutputIsSchade_ResultIsTrue()
        {
            //Arragne
            var returnValue = "";
            var input       = 2;
            var result      = false;

            //Act
            returnValue = BoatDamage.DamageLevelToString(input);
            if (returnValue == "Schade")
            {
                result = true;
            }
            //Assert
            Assert.IsTrue(result);
        }
Ejemplo n.º 6
0
        //Method to execute when AddUser button is clicked
        private void ReportDamageButton_Click(object sender, RoutedEventArgs e)
        {
            //Save textBox content to variables for easy access
            var damageLevel = DamageLevel.SelectedIndex + 1; //Add 1 because combobox index start at 0 and values in database vary from 1 to 3
            var location    = LocationBox.Text;
            var reason      = ReasonBox.Text;

            //Check for empty fields, if a field is left empty show an error dialog
            if (!string.IsNullOrWhiteSpace(location) && !string.IsNullOrWhiteSpace(reason))
            {
                try
                {
                    //Convert image to blob
                    var selectedImageString = BoatImages.ImageToBase64(SelectedImageForConversion, System.Drawing.Imaging.ImageFormat.Png);
                    var selectedImageInput  = selectedImageString;

                    //Create new report to add to the DB
                    var boatDamage = new BoatDamage
                    {
                        boatId             = BoatId,
                        memberId           = MemberId,
                        boatDamageLevel    = damageLevel,
                        boatDamageLocation = location,
                        boatDamageReason   = reason,
                        reportDate         = DateTime.Now,
                        boatImageBlob      = selectedImageInput
                    };

                    //Add report to database
                    BoatDamage.AddReportToDb(boatDamage);

                    MessageBox.Show("Schade melding is succesvol toegevoegd.", "Melding toegevoegd", MessageBoxButton.OK, MessageBoxImage.Information);
                    switch (AccessLevel)
                    {
                    case 1:
                        Switcher.Switch(new HomePageMember(FullName, AccessLevel, MemberId));
                        break;

                    case 2:
                        Switcher.Switch(new HomePageMatchCommissioner(FullName, AccessLevel, MemberId));
                        break;

                    case 3:
                        Switcher.Switch(new HomePageMaterialCommissioner(FullName, AccessLevel, MemberId));
                        break;
                    }
                }
                catch (FileTooLargeException)
                {
                    MessageBox.Show("De geselecteerde afbeelding is te groot. (Max. 256kb)", "Bestand te groot", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                catch (Exception exception)
                {
                    //Error message for any other exception that could occur
                    MessageBox.Show(exception.Message, "Een fout is opgetreden", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                MessageBox.Show("Vul alle velden in.", "Niet alle velden zijn ingevuld", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }