Esempio n. 1
0
    public void DoDamage()
    {
        PLayerBattle pbattle = (PLayerBattle)player.GetComponent("PLayerBattle");
        Attacks      att     = (Attacks)activeattack.GetComponent("Attacks");

        pbattle.TakeDamage(att.enemydamage);
    }
Esempio n. 2
0
 public void FourthPerson()
 {
     commentarygui.SetActive(true);
     choicesgui.SetActive(true);
     option1gui.SetActive(false);
     optionattackgui.SetActive(false);
     optionmagicgui.SetActive(false);
     selectbutton1.SetActive(false);
     selectbutton2.SetActive(false);
     selectbutton3.SetActive(false);
     selectbutton4.SetActive(false);
     selectbutton5.SetActive(false);
     selectbutton22.SetActive(false);
     backbutton.SetActive(false);
     if (fourthperson == player)
     {
         PLayerBattle pbattle = (PLayerBattle)player.GetComponent("PLayerBattle");
         Attacks      att     = (Attacks)thisturnattack.GetComponent("Attacks");
         commentarytext.text = "Player used " + att.attackname;
         pbattle.DoDamage(targetenemy, thisturnattack);
     }
     if (fourthperson == enemy1)
     {
         EnemyAI enem1 = (EnemyAI)enemy1.GetComponent("EnemyAI");
         Attacks att   = (Attacks)enem1.activeattack.GetComponent("Attacks");
         commentarytext.text = enem1.enemyname + " used " + att.attackname;
         enem1.DoDamage();
     }
     if (fourthperson == enemy2)
     {
         EnemyAI enem2 = (EnemyAI)enemy2.GetComponent("EnemyAI");
         Attacks att   = (Attacks)enem2.activeattack.GetComponent("Attacks");
         commentarytext.text = enem2.enemyname + " used " + att.attackname;
         enem2.DoDamage();
     }
     if (fourthperson == enemy3)
     {
         EnemyAI enem3 = (EnemyAI)enemy3.GetComponent("EnemyAI");
         Attacks att   = (Attacks)enem3.activeattack.GetComponent("Attacks");
         commentarytext.text = enem3.enemyname + " used " + att.attackname;
         enem3.DoDamage();
     }
 }
Esempio n. 3
0
    // Use this for initialization
    void Start()
    {
        commentarygui.SetActive(false);
        choicesgui.SetActive(true);
        option1gui.SetActive(true);
        optionattackgui.SetActive(false);
        optionmagicgui.SetActive(false);
        selectbutton1.SetActive(false);
        selectbutton2.SetActive(false);
        selectbutton3.SetActive(false);
        selectbutton4.SetActive(false);
        selectbutton5.SetActive(false);
        selectbutton22.SetActive(false);
        backbutton.SetActive(false);
        enemyhealthbar1.SetActive(false);
        enemyhealthbar2.SetActive(false);
        enemyhealthbar3.SetActive(false);
        enemyhealthbar4.SetActive(false);
        enemyhealthbar5.SetActive(false);
        playervars = GameObject.FindGameObjectWithTag("Walk To Battle");
        player     = GameObject.FindGameObjectWithTag("Player");
        SetupBattle setup = (SetupBattle)setupbattle.GetComponent("SetupBattle");

        enemy1 = setup.enemy1;
        enemy2 = setup.enemy2;
        enemy3 = setup.enemy3;
        setup.attack1button.GetComponent <Button> ().onClick.AddListener(() => Optionattack(setup.attack1));
        setup.attack2button.GetComponent <Button> ().onClick.AddListener(() => Optionattack(setup.attack2));
        setup.attack3button.GetComponent <Button> ().onClick.AddListener(() => Optionattack(setup.attack3));
        setup.attack4button.GetComponent <Button> ().onClick.AddListener(() => Optionattack(setup.attack4));
        setup.magic1button.GetComponent <Button> ().onClick.AddListener(() => Optionmagic(setup.magic1));
        setup.magic2button.GetComponent <Button> ().onClick.AddListener(() => Optionmagic(setup.magic2));
        setup.magic3button.GetComponent <Button> ().onClick.AddListener(() => Optionmagic(setup.magic3));
        setup.magic4button.GetComponent <Button> ().onClick.AddListener(() => Optionmagic(setup.magic4));
        PLayerBattle pbattle = (PLayerBattle)player.GetComponent("PLayerBattle");

        if (setup.numenemies == 1)
        {
            EnemyAI enem1stats = (EnemyAI)enemy1.GetComponent("EnemyAI");
            if (enem1stats.speed >= pbattle.speed)
            {
                firstperson  = enemy1;
                secondperson = player;
            }
            else
            {
                firstperson  = player;
                secondperson = enemy1;
            }
        }
        if (setup.numenemies == 2)
        {
            EnemyAI enem1stats = (EnemyAI)enemy1.GetComponent("EnemyAI");
            EnemyAI enem2stats = (EnemyAI)enemy2.GetComponent("EnemyAI");
            if (pbattle.speed >= enem1stats.speed && pbattle.speed >= enem2stats.speed)
            {
                firstperson = player;
                if (enem1stats.speed >= enem2stats.speed)
                {
                    secondperson = enemy1;
                    thirdperson  = enemy2;
                }
                else
                {
                    secondperson = enemy2;
                    thirdperson  = enemy1;
                }
            }
            if (enem1stats.speed >= pbattle.speed && enem1stats.speed >= enem2stats.speed)
            {
                firstperson = enemy1;
                if (pbattle.speed >= enem2stats.speed)
                {
                    secondperson = player;
                    thirdperson  = enemy2;
                }
                else
                {
                    secondperson = enemy2;
                    thirdperson  = player;
                }
            }
            if (enem2stats.speed >= pbattle.speed && enem2stats.speed >= enem1stats.speed)
            {
                firstperson = enemy2;
                if (pbattle.speed >= enem1stats.speed)
                {
                    secondperson = player;
                    thirdperson  = enemy1;
                }
                else
                {
                    secondperson = enemy1;
                    thirdperson  = player;
                }
            }
        }
        if (setup.numenemies == 3)
        {
            EnemyAI enem1stats = (EnemyAI)enemy1.GetComponent("EnemyAI");
            EnemyAI enem2stats = (EnemyAI)enemy2.GetComponent("EnemyAI");
            EnemyAI enem3stats = (EnemyAI)enemy3.GetComponent("EnemyAI");
            if (pbattle.speed >= enem1stats.speed && pbattle.speed >= enem2stats.speed && pbattle.speed >= enem3stats.speed)
            {
                firstperson = player;
                if (enem1stats.speed >= enem2stats.speed && enem1stats.speed >= enem3stats.speed)
                {
                    secondperson = enemy1;
                    if (enem2stats.speed >= enem3stats.speed)
                    {
                        thirdperson  = enemy2;
                        fourthperson = enemy3;
                    }
                    else
                    {
                        thirdperson  = enemy3;
                        fourthperson = enemy2;
                    }
                }
                if (enem2stats.speed >= enem1stats.speed && enem2stats.speed >= enem3stats.speed)
                {
                    secondperson = enemy2;
                    if (enem1stats.speed >= enem3stats.speed)
                    {
                        thirdperson  = enemy1;
                        fourthperson = enemy3;
                    }
                    else
                    {
                        thirdperson  = enemy3;
                        fourthperson = enemy1;
                    }
                }
                if (enem3stats.speed >= enem1stats.speed && enem3stats.speed >= enem2stats.speed)
                {
                    secondperson = enemy3;
                    if (enem1stats.speed >= enem2stats.speed)
                    {
                        thirdperson  = enemy1;
                        fourthperson = enemy2;
                    }
                    else
                    {
                        thirdperson  = enemy2;
                        fourthperson = enemy1;
                    }
                }
            }
            if (enem1stats.speed >= pbattle.speed && enem1stats.speed >= enem2stats.speed && enem1stats.speed >= enem3stats.speed)
            {
                firstperson = enemy1;
                if (pbattle.speed >= enem2stats.speed && pbattle.speed >= enem3stats.speed)
                {
                    secondperson = player;
                    if (enem2stats.speed >= enem3stats.speed)
                    {
                        thirdperson  = enemy2;
                        fourthperson = enemy3;
                    }
                    else
                    {
                        thirdperson  = enemy3;
                        fourthperson = enemy2;
                    }
                }
                if (enem2stats.speed >= pbattle.speed && enem2stats.speed >= enem3stats.speed)
                {
                    secondperson = enemy2;
                    if (pbattle.speed >= enem3stats.speed)
                    {
                        thirdperson  = player;
                        fourthperson = enemy3;
                    }
                    else
                    {
                        thirdperson  = enemy3;
                        fourthperson = player;
                    }
                }
                if (enem3stats.speed >= pbattle.speed && enem3stats.speed >= enem2stats.speed)
                {
                    secondperson = enemy3;
                    if (pbattle.speed >= enem2stats.speed)
                    {
                        thirdperson  = player;
                        fourthperson = enemy2;
                    }
                    else
                    {
                        thirdperson  = enemy2;
                        fourthperson = player;
                    }
                }
            }
            if (enem2stats.speed >= enem1stats.speed && enem2stats.speed >= pbattle.speed && enem2stats.speed >= enem3stats.speed)
            {
                firstperson = enemy2;
                if (enem1stats.speed >= enem2stats.speed && enem1stats.speed >= enem3stats.speed)
                {
                    secondperson = enemy1;
                    if (pbattle.speed >= enem3stats.speed)
                    {
                        thirdperson  = player;
                        fourthperson = enemy3;
                    }
                    else
                    {
                        thirdperson  = enemy3;
                        fourthperson = player;
                    }
                }
                if (pbattle.speed >= enem1stats.speed && pbattle.speed >= enem3stats.speed)
                {
                    secondperson = player;
                    if (enem1stats.speed >= enem3stats.speed)
                    {
                        thirdperson  = enemy1;
                        fourthperson = enemy3;
                    }
                    else
                    {
                        thirdperson  = enemy3;
                        fourthperson = enemy1;
                    }
                }
                if (enem3stats.speed >= enem1stats.speed && enem3stats.speed >= pbattle.speed)
                {
                    secondperson = enemy3;
                    if (enem1stats.speed >= pbattle.speed)
                    {
                        thirdperson  = enemy1;
                        fourthperson = player;
                    }
                    else
                    {
                        thirdperson  = player;
                        fourthperson = enemy1;
                    }
                }
            }
            if (enem3stats.speed >= enem1stats.speed && enem3stats.speed >= enem2stats.speed && enem3stats.speed >= pbattle.speed)
            {
                firstperson = enemy3;
                if (enem1stats.speed >= enem2stats.speed && enem1stats.speed >= pbattle.speed)
                {
                    secondperson = enemy1;
                    if (enem2stats.speed >= pbattle.speed)
                    {
                        thirdperson  = enemy2;
                        fourthperson = player;
                    }
                    else
                    {
                        thirdperson  = player;
                        fourthperson = enemy2;
                    }
                }
                if (enem2stats.speed >= enem1stats.speed && enem2stats.speed >= pbattle.speed)
                {
                    secondperson = enemy2;
                    if (enem1stats.speed >= pbattle.speed)
                    {
                        thirdperson  = enemy1;
                        fourthperson = player;
                    }
                    else
                    {
                        thirdperson  = player;
                        fourthperson = enemy1;
                    }
                }
                if (pbattle.speed >= enem1stats.speed && pbattle.speed >= enem2stats.speed)
                {
                    secondperson = player;
                    if (enem1stats.speed >= enem2stats.speed)
                    {
                        thirdperson  = enemy1;
                        fourthperson = enemy2;
                    }
                    else
                    {
                        thirdperson  = enemy2;
                        fourthperson = enemy1;
                    }
                }
            }
        }
        commentarygui.SetActive(false);
    }
Esempio n. 4
0
    public void Optionmagic(GameObject attack)
    {
        Attacks      att     = (Attacks)attack.GetComponent("Attacks");
        PLayerBattle pbattle = (PLayerBattle)player.GetComponent("PLayerBattle");

        if (pbattle.curmana >= att.manacost)
        {
            SetupBattle setup = (SetupBattle)setupbattle.GetComponent("SetupBattle");
            thisturnattack = attack;
            if (setup.numenemies == 1)
            {
                selectbutton1.SetActive(false);
                selectbutton2.SetActive(false);
                selectbutton3.SetActive(false);
                selectbutton4.SetActive(false);
                selectbutton5.SetActive(false);
                enemyhealthbar1.SetActive(false);
                enemyhealthbar2.SetActive(false);
                enemyhealthbar3.SetActive(false);
                enemyhealthbar4.SetActive(false);
                enemyhealthbar5.SetActive(false);
                if (enemy1 != null)
                {
                    selectbutton3.SetActive(true);
                    EnemyAI enem1 = (EnemyAI)enemy1.GetComponent("EnemyAI");
                    enem1.ChooseAttack();
                    enemyhealthbar3.SetActive(true);
                }
            }
            if (setup.numenemies == 2)
            {
                selectbutton1.SetActive(false);
                selectbutton2.SetActive(false);
                selectbutton3.SetActive(false);
                selectbutton4.SetActive(false);
                selectbutton5.SetActive(false);
                enemyhealthbar1.SetActive(false);
                enemyhealthbar2.SetActive(false);
                enemyhealthbar3.SetActive(false);
                enemyhealthbar4.SetActive(false);
                enemyhealthbar5.SetActive(false);
                if (enemy1 != null)
                {
                    selectbutton2.SetActive(true);
                    EnemyAI enem1 = (EnemyAI)enemy1.GetComponent("EnemyAI");
                    enem1.ChooseAttack();
                    enemyhealthbar2.SetActive(true);
                }
                if (enemy2 != null)
                {
                    selectbutton4.SetActive(true);
                    EnemyAI enem2 = (EnemyAI)enemy2.GetComponent("EnemyAI");
                    enem2.ChooseAttack();
                    enemyhealthbar4.SetActive(true);
                }
            }
            if (setup.numenemies == 3)
            {
                selectbutton1.SetActive(false);
                selectbutton2.SetActive(false);
                selectbutton3.SetActive(false);
                selectbutton4.SetActive(false);
                selectbutton5.SetActive(false);
                enemyhealthbar1.SetActive(false);
                enemyhealthbar2.SetActive(false);
                enemyhealthbar3.SetActive(false);
                enemyhealthbar4.SetActive(false);
                enemyhealthbar5.SetActive(false);
                if (enemy1 != null)
                {
                    selectbutton1.SetActive(true);
                    EnemyAI enem1 = (EnemyAI)enemy1.GetComponent("EnemyAI");
                    enem1.ChooseAttack();
                    enemyhealthbar1.SetActive(true);
                }
                if (enemy2 != null)
                {
                    selectbutton3.SetActive(true);
                    EnemyAI enem2 = (EnemyAI)enemy2.GetComponent("EnemyAI");
                    enem2.ChooseAttack();
                    enemyhealthbar3.SetActive(true);
                }
                if (enemy3 != null)
                {
                    selectbutton5.SetActive(true);
                    EnemyAI enem3 = (EnemyAI)enemy3.GetComponent("EnemyAI");
                    enem3.ChooseAttack();
                    enemyhealthbar5.SetActive(true);
                }
            }
        }
    }