Example #1
0
    void Update()
    {
        if (pokemonObj.enemy == null)
        {
            if (Random.value < 0.01f)
            {
                target = transform.position + Quaternion.Euler(0, Random.value * 360, 0) * Vector3.right * 10;
            }
            Vector3 direct = target - transform.position;
            direct.y = 0;
            if (direct.sqrMagnitude > 1)
            {
                transform.rotation = Quaternion.LookRotation(direct);
                pokemonObj.SetVelocity(direct.normalized * pokemonObj.speed / 3);
            }
        }
        else
        {
            if (pokemonObj.pokemon.hp > 0)
            {
                Vector3 direct = pokemonObj.enemy.transform.position - transform.position;
                if (direct.sqrMagnitude > 25 * 25)
                {
                    pokemonObj.enemy = null;
                    return;
                }

                direct.y           = 0;
                transform.rotation = Quaternion.LookRotation(direct);

                if (Random.value < 0.1f)                //use random moves whenever
                {
                    pokemonObj.UseMove(direct.normalized, pokemonObj.pokemon.moves[Random.Range(0, pokemonObj.pokemon.moves.Count)]);
                }

                if (direct.sqrMagnitude > 1)
                {
                    pokemonObj.SetVelocity(direct.normalized * pokemonObj.speed);
                }
            }
        }
    }
Example #2
0
    public void BattleGUI()
    {
        GUI.DrawTexture(new Rect(0, Screen.height - 90, 200, 100), GUImgr.gradRight);
        float ypos = Screen.height - 85;

        GUI.Label(new Rect(10, ypos, 200, 20), name + " lvl" + pokemonObj.pokemon.level.ToString());

        //stats
        ypos += 20;
        GUI.Label(new Rect(10, ypos, 200, 20), "HP");
        GUImgr.DrawBar(new Rect(35, ypos + 5, 200, 10), pokemonObj.pokemon.hp, GUImgr.hp);

        ypos += 20;
        GUI.Label(new Rect(10, ypos, 200, 20), "PP");
        GUImgr.DrawBar(new Rect(35, ypos + 5, 200, 10), pokemonObj.pokemon.pp, GUImgr.pp);

        ypos += 20;
        GUI.Label(new Rect(10, ypos, 200, 20), "XP");
        GUImgr.DrawBar(new Rect(35, ypos + 5, 200, 10), pokemonObj.pokemon.xp, GUImgr.xp);

        //current target
        if (pokemonObj.enemy != null)
        {
            if (pokemonObj.enemy.pokemon != null)
            {
                GUI.DrawTexture(new Rect(0, 0, 200, 60), GUImgr.gradRight);
                ypos = 5;
                GUI.Label(new Rect(10, ypos, 200, 20), pokemonObj.enemy.name + " lvl" + pokemonObj.enemy.pokemon.level.ToString());
                ypos += 20;
                GUI.Label(new Rect(10, ypos, 200, 20), "HP");
                GUImgr.DrawBar(new Rect(35, ypos + 5, 200, 10), pokemonObj.enemy.pokemon.hp, GUImgr.hp);;
            }
        }

        //moves
        float height = pokemonObj.pokemon.moves.Count * 40 + 10;

        GUI.DrawTexture(new Rect(Screen.width - 200, Screen.height - height, 200, height), GUImgr.gradLeft);
        ypos = Screen.height - 40;
        float xpos  = Screen.width - 150;
        int   moveN = pokemonObj.pokemon.moves.Count;

        foreach (Move move in pokemonObj.pokemon.moves)
        {
            GUI.Label(new Rect(xpos, ypos, 200, 20), moveN.ToString() + " - " + move.moveType.ToString());
            GUImgr.DrawBar(new Rect(xpos, ypos + 20, 100, 5), move.cooldown, GUImgr.pp);
            ypos -= 40;
            bool useMove = false;
            if (!Player.click)
            {
                switch (moveN)
                {
                case 1: if (Input.GetKey(KeyCode.Alpha1) || Input.GetKey(KeyCode.Keypad1))
                    {
                        useMove = true;
                    }
                    break;

                case 2: if (Input.GetKey(KeyCode.Alpha2) || Input.GetKey(KeyCode.Keypad2))
                    {
                        useMove = true;
                    }
                    break;

                case 3: if (Input.GetKey(KeyCode.Alpha3) || Input.GetKey(KeyCode.Keypad3))
                    {
                        useMove = true;
                    }
                    break;

                case 4: if (Input.GetKey(KeyCode.Alpha4) || Input.GetKey(KeyCode.Keypad4))
                    {
                        useMove = true;
                    }
                    break;

                case 5: if (Input.GetKey(KeyCode.Alpha5) || Input.GetKey(KeyCode.Keypad5))
                    {
                        useMove = true;
                    }
                    break;

                case 6: if (Input.GetKey(KeyCode.Alpha6) || Input.GetKey(KeyCode.Keypad6))
                    {
                        useMove = true;
                    }
                    break;

                case 7: if (Input.GetKey(KeyCode.Alpha7) || Input.GetKey(KeyCode.Keypad7))
                    {
                        useMove = true;
                    }
                    break;

                case 8: if (Input.GetKey(KeyCode.Alpha8) || Input.GetKey(KeyCode.Keypad8))
                    {
                        useMove = true;
                    }
                    break;

                case 9: if (Input.GetKey(KeyCode.Alpha9) || Input.GetKey(KeyCode.Keypad9))
                    {
                        useMove = true;
                    }
                    break;
                }
            }
            if (useMove)
            {
                pokemonObj.UseMove(transform.forward, move);
            }
            moveN--;
        }
    }