Esempio n. 1
0
        void ucb_AttackClicked(object sender, EventArgs e)
        {
            Function.SoundManager.PlayButtonSound();
            ucCharacterBattle control = sender as ucCharacterBattle;

            Core.Abilities.ActiveAbility ab = control.ChoosenAbility();

            if (ab.DamageOrHealing == EnumActiveAbilityType.Damage)
            {
                AttackButtonDamage(control, ab);
            }
            else
            {
                AttackButtonHealing(control, ab);
            }

            foreach (var item in flpCharacters.Controls)
            {
                (item as ucCharacterBattle).Update();
            }

            (flpNPCs.Controls[0] as ucNPC).Update();

            CheckNPCHealth();
        }
Esempio n. 2
0
        /// <summary>
        /// Constructor for the Battle Form. Only supports Singleplayer combat atm
        /// </summary>
        /// <param name="_listOfChars"></param>
        /// <param name="_difficulty"></param>
        public BattleForm(List <Core.Units.Character> _listOfChars, int _difficulty, RPG.Core.PlayerSettings settings)
        {
            InitializeComponent();
            this.StartPosition   = FormStartPosition.CenterParent;
            this.BackgroundImage = GeneralFunctions.ResizeImage(Properties.Resources.background, labelBackgroundIGNORE.Size);
            Function.SoundManager.PlayMain(settings.SoundOn, this, settings.SoundVolume);

            numberOfPlayers = _listOfChars.Count;

            battleChars = _listOfChars;

            int sum = 0;

            foreach (var item in battleChars)
            {
                sum += item.UnitLevel;
                liveChars.Add(item.UnitName);
            }

            int average = (int)(sum / battleChars.Count);

            enemy = WorldGeneration.GenerateNPC(null, average, _difficulty, EnumMonsterType.Null, battleChars.Count);
            ai    = WorldGeneration.GenerateNPCAI(enemy, battleChars);
            enemy = ai.ModifiedNPC;

            foreach (var item in battleChars)
            {
                ucCharacterBattle ucb = new ucCharacterBattle(item, battleChars.Count);
                ucb.AttackClicked += ucb_AttackClicked;
                flpCharacters.Controls.Add(ucb);
            }

            flpNPCs.Controls.Add(new ucNPC(enemy));
        }
Esempio n. 3
0
        private void AttackButtonHealing(ucCharacterBattle control, Core.Abilities.ActiveAbility ab)
        {
            if (control.CheckBoxP1Status || control.CheckBoxP2Status || control.CheckBoxP3Status || control.CheckBoxP4Status || Function.CombatHandler.RequiresNoTarget(ab))
            {
                List <int> indexes = new List <int>();

                if (control.CheckBoxP1Status)
                {
                    indexes.Add(0);
                }
                if (control.CheckBoxP2Status)
                {
                    indexes.Add(1);
                }
                if (control.CheckBoxP3Status)
                {
                    indexes.Add(2);
                }
                if (control.CheckBoxP4Status)
                {
                    indexes.Add(3);
                }

                int previousHP = 0;
                int postHP     = 0;

                foreach (var item in battleChars)
                {
                    previousHP += item.CurrentHP.IntValue;
                }

                ab.UseAbility(control.Character(), battleChars, indexes, enemy);

                foreach (var item in battleChars)
                {
                    postHP += item.CurrentHP.IntValue;
                }

                if (postHP > previousHP)
                {
                    healingDone += Math.Abs(postHP - previousHP);
                }

                UpdateIndexedControls(indexes);

                Function.RichTextBoxExtensions.AppendText(richTextBoxActionbox, "[" + DateTime.Now.ToShortTimeString() + "] ", Color.DarkSeaGreen);
                Function.RichTextBoxExtensions.AppendText(richTextBoxActionbox, ab.ChatString + Environment.NewLine, Color.DarkOrange);
            }
            else
            {
                RPG.UI.MessageForm mes = new MessageForm("You have no target!");
                mes.ShowDialog();
            }
        }
Esempio n. 4
0
        private void AttackButtonDamage(ucCharacterBattle control, Core.Abilities.ActiveAbility ab)
        {
            if (control.CheckBoxEnemyStatus)
            {
                int previousHP        = 0;
                int postHP            = 0;
                int previousMonsterHP = 0;
                int postMonsterHP     = 0;

                foreach (var item in battleChars)
                {
                    previousHP += item.CurrentHP.IntValue;
                }

                previousMonsterHP = enemy.CurrentHP.IntValue;

                ab.UseAbility(control.Character(), battleChars, null, enemy);

                foreach (var item in battleChars)
                {
                    postHP += item.CurrentHP.IntValue;
                }

                postMonsterHP = enemy.CurrentHP.IntValue;

                if (postHP > previousHP)
                {
                    healingDone += Math.Abs(postHP - previousHP);
                }

                if (postMonsterHP > previousMonsterHP)
                {
                    damageDone += Math.Abs(postMonsterHP - previousMonsterHP);
                }

                Function.RichTextBoxExtensions.AppendText(richTextBoxActionbox, "[" + DateTime.Now.ToShortTimeString() + "] ", Color.DarkSeaGreen);
                Function.RichTextBoxExtensions.AppendText(richTextBoxActionbox, ab.ChatString + Environment.NewLine, Color.DarkOrange);

                CheckPlayersHealth();
            }
            else
            {
                RPG.UI.MessageForm mes = new MessageForm("You have no target!");
                mes.ShowDialog();
            }
        }