Exemplo n.º 1
0
        public clsBattle(clsEdjimon player, clsEdjimon enemy)
        {
            B_player = player;
            B_enemy = enemy;

            BattleForm = new frmBattle(player, enemy);
            BattleForm.Show();
            BattleForm.Cycle(player, enemy, 0);
        }
Exemplo n.º 2
0
        public static bool DoDamage(int hp_loss, ref clsEdjimon receiver)
        {
            receiver.currentHP -= hp_loss;

            //This tells the player if there was any damage. The form has the difference
            //of whether you did damage or he did.
            //HACK: This won't work for Sleep, Paralyze, etc when no damage is done.
                //possibly use another function for non-HP damage?
            if (hp_loss == 0)
                return false;
            else return true;

            //TODO: hp_loss < 0, subtract damage from active edjimon
        }
Exemplo n.º 3
0
        public frmBattle(clsEdjimon edPlayer, clsEdjimon edEnemy)
        {
            InitializeComponent();
            this.pictureboxEnemy.Image = System.Drawing.Image.FromFile("img_edjimon\\" + edEnemy.name + ".bmp");
            this.pictureboxPlayer.Image = System.Drawing.Image.FromFile("img_edjimon\\" + edPlayer.name + ".bmp");
            this.lblEnemyName.Text = edEnemy.name;
            this.lblPlayerName.Text = edPlayer.name;
            this.lblEnemyType.Text = edEnemy.type.ToString();
            this.lblPlayerType.Text = edPlayer.type.ToString();
            this.pbEnemyHP.Maximum = edEnemy.maxHP;
            this.pbEnemyHP.Value = edEnemy.currentHP;
            this.pbPlayerHP.Maximum = edPlayer.maxHP;
            this.pbPlayerHP.Value = edPlayer.currentHP;

            this.edEnemy = edEnemy;
            this.edPlayer = edPlayer;
            clsGame.inbattle = true;

            if (edEnemy.speed < edPlayer.speed)
                player_turn = true;

            #region Write Button Text
            if (edPlayer.attacks[0] != "null")
            {
                btnAttack1.Enabled = true;
                btnAttack1.Visible = true;
                btnAttack1.Text = edPlayer.attacks[0];
            }
            if (edPlayer.attacks[1] != "null")
            {
                btnAttack2.Enabled = true;
                btnAttack2.Visible = true;
                btnAttack2.Text = edPlayer.attacks[1];
            }
            if (edPlayer.attacks[2] != "null")
            {
                btnAttack3.Enabled = true;
                btnAttack3.Visible = true;
                btnAttack3.Text = edPlayer.attacks[2];
            }
            if (edPlayer.attacks[3] != "null")
            {
                btnAttack4.Enabled = true;
                btnAttack4.Visible = true;
                btnAttack4.Text = edPlayer.attacks[3];
            }
            #endregion
        }
Exemplo n.º 4
0
        public clsTrainer(string nameofsprite, PointF startpos)
            : base(nameofsprite, startpos)
        {
            for (int x = 0; x < 6; x++)
            {
                edjimon[x] = new clsEdjimon();
            }

            //HACK: Load this data from save_game file
            edjimon[0].number = "001";
            edjimon[0].name = "Treep";
            edjimon[0].type = clsBattle.type.grass;
            edjimon[0].currentHP = 17;
            edjimon[0].currentlevel = 1;
            edjimon[0].attacks[0] = "Punch";
            edjimon[0].maxHP = 17;
            edjimon[0].currentHP = 17;
            edjimon[0].attack = 6;
            edjimon[0].defense = 10;
            edjimon[0].accuracy = 50;
            edjimon[0].cel = 10;

            //TODO: clsTrainer - need to add ability to swap edjimon out of order
        }
Exemplo n.º 5
0
        /// <summary>
        /// Represents a turn in battle.
        /// </summary>
        /// <param name="edPlayer">The player's Edjimon.</param>
        /// <param name="edEnemy">The enemy's Edjimon.</param>
        /// <param name="playermove">What number move the player is using. ?CHECK THIS?</param>
        public void Cycle(clsEdjimon edPlayer, clsEdjimon edEnemy, int playermove)
        {
            if (edEnemy.currentHP > 0 && edPlayer.currentHP > 0)
            {
                //if enemy gets first hit
                //HACK: Fix this. Why check speed AND player_turn? Speed should set player_turn.
                if (edEnemy.speed > edPlayer.speed && player_turn == false)
                {
                    //HACK: Random selection of enemy attack is inadequate. FIX ME
                    Random pickattack = new Random(System.DateTime.Today.Millisecond);
                    int attacktodo = 0;

                    for (int x = 0; x < 4; x++)
                    {
                        //The 99 is preceded with "null:" in the Edjimon's data.
                        //It means the Edjimon does not have a move for that slot.
                        if ((int)edEnemy.attack_types[x] != 99)
                        {
                            attacktodo = pickattack.Next(0, x);
                        }
                        else
                            break;
                    }

                    if (clsBattle.DoDamage(clsAttack.Attack(edEnemy.attack_types[attacktodo], edPlayer.type, edPlayer.accuracy, edEnemy.cel/*, true*/), ref clsBattle.B_player))
                        MessageBox.Show("He hit you!");
                    else
                        MessageBox.Show("He missed!");

                    pbPlayerHP.Value = edPlayer.currentHP;
                    pbEnemyHP.Value = edEnemy.currentHP;
                    Refresh();

                    //HACK: Speed + 100? May work permanently
                    /* After each attack, the opponent's speed increases by 100
                     * This is linear, and it makes sure the opponent has the next turn
                     */
                    clsBattle.B_player.speed += 100;
                    player_turn = true;

                    while (clsGame.inbattle == true && player_turn == false)
                    {
                        //it doesn't matter what you send to Cycle(x,x,HERE) for the enemy's attack
                        Cycle(edPlayer, edEnemy, 0);
                        //Set the HP bars on the window.
                        pbPlayerHP.Value = edPlayer.currentHP;
                        pbEnemyHP.Value = edEnemy.currentHP;
                        Refresh();
                    }
                }
            }
            else
            {
                clsGame.inbattle = false;

                //TODO: Save edjimon data back to player and opponent(if trainer)
                MessageBox.Show("Battle Done!");
                this.Close();
            }
        }