Esempio n. 1
0
        public int Attack(AttackBase attack, CharacterBase target, out string message)
        {
            int damage = attack.Action(this, target, out message);

            return(damage);
        }
Esempio n. 2
0
        partial void TouchEvent_AttackEnemy(UIButton sender)
        {
            int attackIndex  = -1;
            int tableSection = -1;

            try
            {
                attackIndex  = Tbl_AttackList.IndexPathForSelectedRow.Row;
                tableSection = Tbl_AttackList.IndexPathForSelectedRow.Section;
            }catch (System.NullReferenceException) {
                attackIndex  = -1;
                tableSection = -1;
            }

            if (attackIndex >= 0 && tableSection >= 0)
            {
                if (tableSection == 0 && playerCharacter.Stamina >= playerCharacter.attacks[attackIndex].GetManaCost())
                {
                    AttackBase playerAttack = playerCharacter.attacks[attackIndex];
                    AttackBase enemyAttack  = enemyCharacter.GetRandomAttack();

                    string msg1;
                    string msg2;

                    //perform battle
                    int damage2 = playerCharacter.Attack(playerAttack, enemyCharacter, out msg1);
                    int damage1 = enemyCharacter.Attack(enemyAttack, playerCharacter, out msg2);

                    UpdateStats();
                    UpdateHPBars();

                    Txt_BattleSummary.Text  = "";
                    Txt_BattleSummary.Text += msg1 + '\n';
                    Txt_BattleSummary.Text += msg2 + '\n';
                }
                else if (tableSection == 0 && playerCharacter.Stamina < playerCharacter.attacks[attackIndex].GetManaCost())
                {
                    Txt_BattleSummary.Text = "Not Enough Mana!";
                }
                else
                {
                    ItemBase playerItem = playerCharacter.bag[attackIndex];
                    Console.WriteLine(attackIndex);
                    string str = playerCharacter.UseItem(attackIndex, playerCharacter);
                    Tbl_AttackList.ReloadData();
                    Txt_BattleSummary.Text  = "";
                    Txt_BattleSummary.Text += str + '\n';
                }
            }
            else
            {
                Txt_BattleSummary.Text = "Select an attack or item!";
            }

            Tbl_AttackList.ReloadData();

            if (enemyCharacter.Health <= 0 && enemyCharacter.IsFinalBoss())
            {
                VC_DeathScreen deathScreen = new VC_DeathScreen(true);
                PresentViewController(deathScreen, true, null);
            }

            else if (enemyCharacter.Health <= 0)
            {
                playerCharacter.Experience += enemyCharacter.GetExpValue();
                this.DismissViewController(true, null);
            }

            if (playerCharacter.Health <= 0)
            {
                VC_DeathScreen deathScreen = new VC_DeathScreen(false);
                PresentViewController(deathScreen, true, null);
            }
        }