示例#1
0
        private void SlowlorisItem_Click(object sender, RoutedEventArgs e)
        {
            _attackWindow       = new AttackWindow(Connections, 2, "Broadcast Slowloris Attack");
            _attackWindow.Owner = this;

            if (_attackWindow.ShowDialog() == true)
            {
                // Broadcast Attack Window closed
            }
        }
示例#2
0
        private void SynFloodItem_Click(object sender, RoutedEventArgs e)
        {
            _attackWindow       = new AttackWindow(Connections, 1, "Broadcast SYN Flood Attack");
            _attackWindow.Owner = this;

            if (_attackWindow.ShowDialog() == true)
            {
                // Broadcast Window closed
            }
        }
示例#3
0
 public BattleLogic(Base ownBase, Base enemyBase, Army army, List <Base> enemies, TimeSpan gameStepDuration, bool isUserPlaying, MainWindow window, AttackWindow attackWindow)
 {
     OwnBase          = ownBase;
     Enemy            = enemyBase;
     Army             = army;
     Enemies          = enemies;
     GameStepDuration = gameStepDuration;
     Window           = window;
     IsUserPlaying    = isUserPlaying;
     AttackWindow     = attackWindow;
 }
示例#4
0
    private void OnGUI()
    {
        minSize        = new Vector2(350, 350);
        scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true, GUIStyle.none, GUI.skin.verticalScrollbar);
        EditorGUILayout.LabelField("Edit Melee Attack", CustomStyles.titles);
        EditorGUILayout.Space();
        if (baseAttack != null)
        {
            EditorGUILayout.LabelField(baseAttack.attackName, CustomStyles.subtitles);
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            baseAttack.attackDescription = EditorGUILayout.TextField("Attack Description", baseAttack.attackDescription);
            EditorGUILayout.Space();
            baseAttack.baseDamage = EditorGUILayout.FloatField("Base Damage", baseAttack.baseDamage);
            if (baseAttack.baseDamage < 0)
            {
                baseAttack.baseDamage = 0;
            }
            EditorGUILayout.Space();
            baseAttack.isAreaAttack = EditorGUILayout.Toggle("Is Area Attack?", baseAttack.isAreaAttack);
            EditorGUILayout.Space();

            isMultiple = EditorGUILayout.Toggle("Is Multiple Attack?", isMultiple);
            if (isMultiple)
            {
                EditorGUILayout.Space();
                baseAttack.attackQty = EditorGUILayout.IntField("Attacks Quantity", baseAttack.attackQty);
                if (baseAttack.attackQty < 2)
                {
                    baseAttack.attackQty = 2;
                }
            }
            else
            {
                baseAttack.attackQty = 1;
            }
            EditorGUILayout.Space();

            baseAttack.levelRequirement = EditorGUILayout.IntField("Level Requirement", baseAttack.levelRequirement);
            if (baseAttack.levelRequirement < 0)
            {
                baseAttack.levelRequirement = 0;
            }
            EditorGUILayout.Space();
            baseAttack.jobsRequirement = (JobsEnum.Jobs)EditorGUILayout.EnumPopup("Job Requirement", baseAttack.jobsRequirement);
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Add Color"))
            {
                baseAttack.listOfColors.Add(ColorsEnum.Colors.BLUE);
                colorIndex.Add(baseAttack.listOfColors.Count);
            }
            if (colorIndex.Count > 0)
            {
                if (GUILayout.Button("Remove Color"))
                {
                    baseAttack.listOfColors.RemoveAt(colorIndex.Count - 1);
                    colorIndex.RemoveAt(colorIndex.Count - 1);
                }
            }
            EditorGUILayout.EndHorizontal();

            foreach (int actualColor in colorIndex)
            {
                int index = colorIndex.IndexOf(actualColor);
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("color" + actualColor + ":");
                baseAttack.listOfColors[index] = (ColorsEnum.Colors)EditorGUILayout.EnumPopup(baseAttack.listOfColors[index]);
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Add Tag"))
            {
                baseAttack.listOfTags.Add(AttackTagsEnum.Tags.SLASH);
                tagIndex.Add(baseAttack.listOfTags.Count);
            }
            if (colorIndex.Count > 0)
            {
                if (GUILayout.Button("Remove Tag"))
                {
                    baseAttack.listOfTags.RemoveAt(tagIndex.Count - 1);
                    tagIndex.RemoveAt(tagIndex.Count - 1);
                }
            }
            EditorGUILayout.EndHorizontal();

            foreach (int actualTag in tagIndex)
            {
                int index = tagIndex.IndexOf(actualTag);
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Tag " + actualTag + ":");
                baseAttack.listOfTags[index] = (AttackTagsEnum.Tags)EditorGUILayout.EnumPopup(baseAttack.listOfTags[index]);
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Save Changes"))
            {
                Save();
            }
            if (GUILayout.Button("Cancel"))
            {
                AttackWindow.OpenWindow();
                Close();
            }
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(15);
        }
        EditorGUILayout.EndScrollView();
    }
示例#5
0
    private void OnGUI()
    {
        minSize        = new Vector2(350, 350);
        scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true, GUIStyle.none, GUI.skin.verticalScrollbar);
        EditorGUILayout.LabelField("New Melee Attack", CustomStyles.titles);
        EditorGUILayout.Space();
        attackName = EditorGUILayout.TextField("Attack Name", attackName);
        EditorGUILayout.Space();
        attackDescription = EditorGUILayout.TextField("Attack Description", attackDescription);
        EditorGUILayout.Space();
        baseDamage = EditorGUILayout.FloatField("Base Damage", baseDamage);
        if (baseDamage < 0)
        {
            baseDamage = 0;
        }
        EditorGUILayout.Space();
        isAreaAttack = EditorGUILayout.Toggle("Is Area Attack?", isAreaAttack);
        EditorGUILayout.Space();

        isMultipleAttack = EditorGUILayout.Toggle("Is Multiple Attack?", isMultipleAttack);
        if (isMultipleAttack)
        {
            EditorGUILayout.Space();
            attackQty = EditorGUILayout.IntField("Attacks Quantity", attackQty);
            if (attackQty < 2)
            {
                attackQty = 2;
            }
        }
        else
        {
            attackQty = 1;
        }
        EditorGUILayout.Space();

        levelRequirement = EditorGUILayout.IntField("Level Requirement", levelRequirement);
        if (levelRequirement < 0)
        {
            levelRequirement = 0;
        }
        EditorGUILayout.Space();
        jobRequirement = (JobsEnum.Jobs)EditorGUILayout.EnumPopup("Job Requirement", jobRequirement);
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Add Color"))
        {
            colorList.Add(ColorsEnum.Colors.BLUE);
            colorIndex.Add(colorList.Count);
        }
        if (colorIndex.Count > 0)
        {
            if (GUILayout.Button("Remove Color"))
            {
                colorList.RemoveAt(colorIndex.Count - 1);
                colorIndex.RemoveAt(colorIndex.Count - 1);
            }
        }
        EditorGUILayout.EndHorizontal();
        foreach (int actualColor in colorIndex)
        {
            int index = colorIndex.IndexOf(actualColor);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("color " + actualColor + ":");
            colorList[index] = (ColorsEnum.Colors)EditorGUILayout.EnumPopup(colorList[index]);
            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Add Tag"))
        {
            tagList.Add(AttackTagsEnum.Tags.SLASH);
            tagIndex.Add(tagList.Count);
        }
        if (colorIndex.Count > 0)
        {
            if (GUILayout.Button("Remove Tag"))
            {
                tagList.RemoveAt(tagIndex.Count - 1);
                tagIndex.RemoveAt(tagIndex.Count - 1);
            }
        }
        EditorGUILayout.EndHorizontal();
        foreach (int actualTag in tagIndex)
        {
            int index = tagIndex.IndexOf(actualTag);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Tag " + actualTag + ":");
            tagList[index] = (AttackTagsEnum.Tags)EditorGUILayout.EnumPopup(tagList[index]);
            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Create"))
        {
            if (attackName == null)
            {
                ShowError("Attack must have a name");
            }
            else
            {
                CreateAttack();
            }
        }
        if (GUILayout.Button("Return"))
        {
            AttackWindow.OpenWindow();
            Close();
        }
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(15);
        EditorGUILayout.EndScrollView();
    }
    private void OnGUI()
    {
        minSize        = new Vector2(350, 350);
        scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true, GUIStyle.none, GUI.skin.verticalScrollbar);
        EditorGUILayout.LabelField("Edit Combination Attack", CustomStyles.titles);
        EditorGUILayout.Space();
        baseAttack.attackName = EditorGUILayout.TextField("Attack Name", baseAttack.attackName);
        EditorGUILayout.Space();
        baseAttack.attackDescription = EditorGUILayout.TextField("Attack Description", baseAttack.attackDescription);
        EditorGUILayout.Space();

        baseAttack.isBuff = EditorGUILayout.Toggle("Is Buff?", baseAttack.isBuff);
        EditorGUILayout.Space();
        if (!baseAttack.isBuff)
        {
            baseAttack.baseDamage = EditorGUILayout.FloatField("Base Damage", baseAttack.baseDamage);
            if (baseAttack.baseDamage < 0)
            {
                baseAttack.baseDamage = 0;
            }
            EditorGUILayout.Space();
        }

        isMultipleAttack = EditorGUILayout.Toggle("Is Multiple Attack?", isMultipleAttack);
        if (isMultipleAttack)
        {
            EditorGUILayout.Space();
            baseAttack.attackQty = EditorGUILayout.IntField("Attacks Quantity", baseAttack.attackQty);
            if (baseAttack.attackQty < 2)
            {
                baseAttack.attackQty = 2;
            }
        }
        else
        {
            baseAttack.attackQty = 1;
        }
        EditorGUILayout.Space();

        baseAttack.isAreaAttack = EditorGUILayout.Toggle("Is Area Attack?", baseAttack.isAreaAttack);
        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Add Color"))
        {
            baseAttack.listOfColors.Add(ColorsEnum.Colors.BLUE);
            colorIndex.Add(baseAttack.listOfColors.Count);
        }
        if (colorIndex.Count > 0)
        {
            if (GUILayout.Button("Remove Color"))
            {
                baseAttack.listOfColors.RemoveAt(colorIndex.Count - 1);
                colorIndex.RemoveAt(colorIndex.Count - 1);
            }
        }
        EditorGUILayout.EndHorizontal();

        foreach (int actualColor in colorIndex)
        {
            int index = colorIndex.IndexOf(actualColor);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("color" + actualColor + ":");
            baseAttack.listOfColors[index] = (ColorsEnum.Colors)EditorGUILayout.EnumPopup(baseAttack.listOfColors[index]);
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.Space();

        if (baseAttack.combinationOfAttacks.Count == 2)
        {
            if (GUILayout.Button("Add Attack"))
            {
                attacksIndex.Add(2);
                baseAttack.combinationOfAttacks.Add(null);
            }
        }
        else
        {
            if (baseAttack.combinationOfAttacks.Count == 3)
            {
                if (GUILayout.Button("Remove Attack"))
                {
                    attacksIndex.Remove(2);
                    baseAttack.combinationOfAttacks.RemoveAt(2);
                }
            }
        }

        foreach (int actualAttack in attacksIndex)
        {
            int index = attacksIndex.IndexOf(actualAttack);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Attack" + actualAttack + ":");
            baseAttack.combinationOfAttacks[index] = (BaseAttack)EditorGUILayout.ObjectField(baseAttack.combinationOfAttacks[index], typeof(BaseAttack), true);;
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Save Changes"))
        {
            foreach (BaseAttack actualAttack in baseAttack.combinationOfAttacks)
            {
                if (actualAttack == null)
                {
                    ShowError("There´s a null attack");
                    OnGUI();
                }
            }
            Save();
        }
        if (GUILayout.Button("Return"))
        {
            AttackWindow.OpenWindow();
            Close();
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndScrollView();
    }
示例#7
0
        public async void WarProcess()
        {
            if (OwnBase.Active == true)
            {
                int attackUnits  = Army.AttackUnits;
                int defenceUnits = Army.DefenceUnits;
                int speedUnits   = Army.SpeedUnits;

                if (attackUnits > 0 || defenceUnits > 0 || speedUnits > 0)
                {
                    if (OwnBase.Equals(Window.Base))
                    {
                        AttackWindow.Hide();
                    }

                    OwnBase.Army.AttackUnits  -= attackUnits;
                    OwnBase.Army.SpeedUnits   -= speedUnits;
                    OwnBase.Army.DefenceUnits -= defenceUnits;

                    CalculateDistance(OwnBase.Position, Enemy.Position);
                    GetSpeed(Army);

                    numberOfSteps = (int)Math.Ceiling(Distance / SpeedOfMovement);

                    TimeSpan stepDuration = GameStepDuration;
                    stepDuration = TimeSpan.FromTicks(stepDuration.Ticks * numberOfSteps);

                    ArmyMovement(OwnBase.Position, Enemy.Position, false, Army, GameStepDuration, Window);
                    await Task.Delay(stepDuration);

                    double attack = GetArmyPower(Army);
                    Enemy.DefencePower();
                    double defence = Enemy.Defence;

                    if (attack > defence)
                    {
                        if (OwnBase.Equals(Window.Base))
                        {
                            AttackWindow.Hide();
                        }
                        double survived = GetSurvived(Army, Enemy);

                        if (Enemy.Equals(Window.Base))
                        {
                            Window.destroyed = true;
                            SetImage(Enemy.Position[0], Enemy.Position[1], "Image/grass.png", Window);
                        }
                        else
                        {
                            SetImage(Enemy.Position[0], Enemy.Position[1], "Image/grass.png", Window);
                            Window.enemies[Enemy.Id - 1].Active = false;
                        }

                        if (OwnBase.Equals(Window.Base))
                        {
                            MessageBoxResult result = MessageBox.Show("Вы победили! \nВам будет начислено 1000 кредитов и 1000 товаров. ",
                                                                      "Confirmation",
                                                                      MessageBoxButton.OK,
                                                                      MessageBoxImage.Exclamation);
                        }

                        ArmyMovement(Enemy.Position, OwnBase.Position, true, Army, GameStepDuration, Window);
                        await Task.Delay(stepDuration);

                        SetImage(Enemy.Position[0], Enemy.Position[1], "Image/grass.png", Window);

                        OwnBase.Credits += 1000;
                        OwnBase.Goods   += 1000;

                        OwnBase.Army.DefenceUnits += (int)Math.Round(defenceUnits * survived, 0);
                        OwnBase.Army.AttackUnits  += (int)Math.Round(attackUnits * survived, 0);
                        OwnBase.Army.SpeedUnits   += (int)Math.Round(speedUnits * survived, 0);

                        if (OwnBase.Equals(Window.Base))
                        {
                            SetImage(OwnBase.Position[0], OwnBase.Position[1], "Image/ownCastle.png", Window);
                            SetImage(Enemy.Position[0], Enemy.Position[1], "Image/grass.png", Window);
                            AttackWindow.Close();
                        }
                        else
                        {
                            Window.SetEnemyImage(OwnBase.Position[0], OwnBase.Position[1], "Image/enemiesCastle.png", OwnBase.Id);
                            SetImage(Enemy.Position[0], Enemy.Position[1], "Image/grass.png", Window);
                        }
                    }
                    else
                    {
                        if (OwnBase.Equals(Window.Base))
                        {
                            AttackWindow.Hide();
                        }

                        if (defence - attack > 100)
                        {
                            double defenceLeftPercent = GetDefenceLeft(Army, Enemy);
                            Enemy.Army.AttackUnits  = (int)Math.Floor(Enemy.Army.AttackUnits * defenceLeftPercent);
                            Enemy.Army.DefenceUnits = (int)Math.Floor(Enemy.Army.DefenceUnits * defenceLeftPercent);
                            Enemy.Army.SpeedUnits   = (int)Math.Floor(Enemy.Army.SpeedUnits * defenceLeftPercent);
                        }
                        else
                        {
                            Enemy.Army.AttackUnits  = 0;
                            Enemy.Army.DefenceUnits = 0;
                            Enemy.Army.SpeedUnits   = 0;
                        }

                        if (Enemy.Equals(Window.Base))
                        {
                            Window.Base.Army = Enemy.Army;
                            SetImage(Enemy.Position[0], Enemy.Position[1], "Image/ownCastle.png", Window);
                            if (OwnBase.Active == true)
                            {
                                Window.SetEnemyImage(OwnBase.Position[0], OwnBase.Position[1], "Image/enemiesCastle.png", OwnBase.Id);
                            }
                            else
                            {
                                SetImage(OwnBase.Position[0], OwnBase.Position[1], "Image/grass.png", Window);
                            }
                        }
                        else
                        {
                            if (Enemy.Active == true)
                            {
                                double defenceLeftPercent = GetDefenceLeft(Army, Enemy);
                                Window.enemies[Enemy.Id - 1].Army = Enemy.Army;
                                Window.SetEnemyImage(Enemy.Position[0], Enemy.Position[1], "Image/enemiesCastle.png", Enemy.Id);
                            }
                            else
                            {
                                SetImage(Enemy.Position[0], Enemy.Position[1], "Image/grass.png", Window);
                            }

                            if (OwnBase.Equals(Window.Base))
                            {
                                SetImage(OwnBase.Position[0], OwnBase.Position[1], "Image/ownCastle.png", Window);
                            }
                            else if (OwnBase.Active == true)
                            {
                                Window.SetEnemyImage(OwnBase.Position[0], OwnBase.Position[1], "Image/enemiesCastle.png", OwnBase.Id);
                            }
                            else
                            {
                                SetImage(OwnBase.Position[0], OwnBase.Position[1], "Image/grass.png", Window);
                            }
                        }

                        if (OwnBase.Equals(Window.Base))
                        {
                            MessageBoxResult result = MessageBox.Show("Увы, победа за противником! \nНаберите более сильную армию и попробуйте снова... ",
                                                                      "Confirmation",
                                                                      MessageBoxButton.OK,
                                                                      MessageBoxImage.Exclamation);

                            AttackWindow.Close();
                        }
                    }
                }
            }
        }