Exemplo n.º 1
0
    private IEnumerator Step4()
    {
        Pokemon1 p1 = Poke1.GetComponent <Pokemon1>();
        Pokemon2 p2 = Poke2.GetComponent <Pokemon2>();

        Debug.Log("End Player Turn");
        yield return(new WaitForSeconds(readTime));

        healthScroll = false;
        p2.currentHP = tempNum;

        //runs check to see if any poke have < hp, if so it will run the end game code
        //otherwise will check to see what turns have been performed and will end turn...
        //...order if both have gone, or will start next turn
        if (p1.currentHP > 0 && p2.currentHP > 0)
        {
            if (bCon.enemyGone && bCon.playerGone)
            {
                bCon.TurnEnd();
                Debug.Log("End Turn");
            }
            else
            {
                Debug.Log("Enemy Turn Start");
                bCon.EnemyTurn();
            }
        }
        else
        {
            bCon.EndGame();
        }
    }
Exemplo n.º 2
0
    //at start of turn turns off button interaction and compares pokemon's speeds to determine turn order
    public void StartTurn()
    {
        Pokemon1 p1 = Poke1.GetComponent <Pokemon1>();
        Pokemon2 p2 = Poke2.GetComponent <Pokemon2>();

        if (p1.speed > p2.speed)
        {
            playerGone = true;

            PlayerTurn();
        }
        if (p1.speed < p2.speed)
        {
            enemyGone = true;

            EnemyTurn();
        }

        //if speeds are equal randomly determines who goes first
        if (p1.speed == p2.speed)
        {
            float chance = Random.Range(1f, 10f);

            if (chance >= 6)
            {
                PlayerTurn();
            }
            else
            {
                EnemyTurn();
            }
        }
    }
Exemplo n.º 3
0
    public void EnemyTurn()
    {
        Pokemon2  p2    = Poke2.GetComponent <Pokemon2>();
        UIControl UICon = uiCon.GetComponent <UIControl>();

        //uses random chance to choose enemy pokemon move then passes info...
        //where it's needed to go
        float chance = Random.Range(1f, 10f);

        if (chance > 3f)
        {
            UICon.p2Move     = p2.Attack1Name;
            eTurn.pokeMove   = p2.Attack1Name;
            UICon.p1MoveType = p2.Attack1Type;
            eTurn.movePwr    = p2.Atk1Pwr;
        }
        else
        {
            UICon.p2Move     = p2.Attack2Name;
            eTurn.pokeMove   = p2.Attack2Name;
            UICon.p1MoveType = p2.Attack2Type;
            eTurn.movePwr    = p2.Atk2Pwr;
        }

        //starts enemy turn
        enemyGone = true;
        eTurn.StartTurn();
    }
Exemplo n.º 4
0
    //damage formula is simplified pokemon damage formula adjusted for simplified combat
    public void GiveDamage(float mPwr)
    {
        Pokemon1 p1 = Poke1.GetComponent <Pokemon1>();
        Pokemon2 p2 = Poke2.GetComponent <Pokemon2>();

        tempNum      = p2.currentHP;
        tempNum     -= Mathf.Round(((0.2f * (p1.attack / p2.defense)) * mPwr) + 2);
        healthScroll = true;
    }
Exemplo n.º 5
0
    private void Update()
    {
        Pokemon2 p2 = Poke2.GetComponent <Pokemon2>();

        if (healthScroll)
        {
            if (p2.currentHP > tempNum)
            {
                p2.currentHP -= 0.3f;
            }
        }
    }
Exemplo n.º 6
0
    public void EndGame()
    {
        Pokemon1         p1      = Poke1.GetComponent <Pokemon1>();
        Pokemon2         p2      = Poke2.GetComponent <Pokemon2>();
        AnimationControl AnimCon = animCon.GetComponent <AnimationControl>();

        if (p1.currentHP <= 0 && p2.currentHP > 0)
        {
            AnimCon.Faint(1);
            Lose();
        }
        if (p2.currentHP <= 0 && p1.currentHP > 0)
        {
            AnimCon.Faint(2);
            Win();
        }
    }
Exemplo n.º 7
0
    private void Awake()
    {
        Pokemon1 p1 = Poke1.GetComponent <Pokemon1>();
        Pokemon2 p2 = Poke2.GetComponent <Pokemon2>();

        //setup min/max values for HP sliders and labels
        p1Slider.maxValue = p1.maxHP;
        p1Slider.value    = p1.maxHP;
        p1Slider.minValue = 0;

        p2Slider.maxValue = p2.maxHP;
        p2Slider.value    = p1.maxHP;
        p2Slider.minValue = 0;

        p1HPmaxtxt.text = " /" + p1.maxHP;

        //changes pokemon Name on status bar to pokemon's name;

        p1Nametxt.text = p1.Pokemon1Name;
        p2Nametxt.text = p2.Pokemon2Name;

        //setting name values

        p1Name = p1.Pokemon1Name;
        p2Name = p2.Pokemon2Name;

        Attack1.text = p1.Attack1Name;
        Attack2.text = p1.Attack2Name;

        //text setup

        BattletxtManager(8);

        selectArrow.transform.position = T1.position;
        MenufirstEntry = true;
        MovefirstEntry = true;
    }
Exemplo n.º 8
0
    //setup UI elements
    void Update()
    {
        BattleController bCon  = BCon.GetComponent <BattleController>();
        AudioManager     audio = Audio.GetComponent <AudioManager>();

        #region Arrow Nav MenuSelect
        if (MenuSelect.activeInHierarchy)
        {
            inputPause = true;
            if (MenufirstEntry)
            {
                selectArrow.transform.position = T1.position;
                MenufirstEntry = false;
            }

            if (selectArrow.transform.position == T1.position)
            {
                if (Input.GetKeyDown(KeyCode.E))
                {
                    audio.PlayAudio(7);
                    StartCoroutine(InputPause());
                    MoveSelect.SetActive(true);
                    MenuSelect.SetActive(false);
                }
            }
        }
        #endregion

        #region Arrow Nav MoveSelect
        if (MoveSelect.activeInHierarchy)
        {
            if (MoveChoice == 1)
            {
                selectArrow.transform.position = T6.position;
                MoveChoice = 0;
            }

            if (MoveChoice == 2)
            {
                selectArrow.transform.position = T5.position;
                MoveChoice = 0;
            }

            if (MovefirstEntry)
            {
                selectArrow.transform.position = T6.position;
                MovefirstEntry = false;
            }

            if (inputPause == false)
            {
                if (Input.GetKeyDown(KeyCode.Q))
                {
                    MenufirstEntry = true;
                    MenuSelect.SetActive(true);
                    MoveSelect.SetActive(false);
                }
                if (selectArrow.transform.position == T6.position)
                {
                    if (Input.GetKeyDown(KeyCode.D))
                    {
                        audio.PlayAudio(7);
                        selectArrow.transform.position = T5.position;
                    }
                    if (Input.GetKeyDown(KeyCode.E))
                    {
                        MoveChoice = 1;
                        audio.PlayAudio(7);
                        SelectArrowGroup.SetActive(false);
                        BattleUI.SetActive(true);
                        MoveSelect.SetActive(false);
                        bCon.Button1Hit();
                        bCon.StartTurn();
                    }
                }
                if (selectArrow.transform.position == T5.position)
                {
                    if (Input.GetKeyDown(KeyCode.A))
                    {
                        audio.PlayAudio(7);
                        selectArrow.transform.position = T6.position;
                    }
                    if (Input.GetKeyDown(KeyCode.E))
                    {
                        MoveChoice = 2;
                        audio.PlayAudio(7);
                        SelectArrowGroup.SetActive(false);
                        BattleUI.SetActive(true);
                        MoveSelect.SetActive(false);
                        bCon.Button2Hit();
                        bCon.StartTurn();
                    }
                }
            }
        }
        #endregion

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
        }
        if (Input.GetKeyDown(KeyCode.Backspace))
        {
            SceneManager.LoadScene("Battle Scene");
        }

        //updates player health counter to match slider values
        Pokemon1 p1 = Poke1.GetComponent <Pokemon1>();
        Pokemon2 p2 = Poke2.GetComponent <Pokemon2>();

        float tempNum = Mathf.Round(p1.currentHP);

        if (tempNum >= 0)
        {
            p1HPcountertxt.text = tempNum.ToString();
        }
        else
        {
            p1HPcountertxt.text = "0";
        }

        p1Slider.value = p1.currentHP;
        p2Slider.value = p2.currentHP;

        #region HpSlider Color Change

        Image f1 = fill1.GetComponent <Image>();
        Image f2 = fill2.GetComponent <Image>();

        if (p1.currentHP <= p1.maxHP / 2)
        {
            f1.color = Color.yellow;
        }

        if (p1.currentHP <= p1.maxHP / 5)
        {
            f1.color = Color.red;
        }

        if (p1.currentHP <= 0)
        {
            f1.color = Color.gray;
        }

        if (p2.currentHP <= p2.maxHP / 2)
        {
            f2.color = Color.yellow;
        }

        if (p2.currentHP <= p2.maxHP / 5)
        {
            f2.color = Color.red;
        }

        if (p2.currentHP <= 0)
        {
            f2.color = Color.gray;
        }

        #endregion
    }