コード例 #1
0
    public void SwordFight()
    {
        Random.InitState(System.DateTime.Now.Millisecond);
        int myroll = Random.Range(pfp - 5, pfp + 6) + add;

        Debug.Log(myroll);
        int enemyroll = Random.Range(efp - 5, efp + 6);

        Debug.Log(enemyroll);

        int result = myroll - enemyroll;

        Debug.Log(result);

        bool win;

        if (result >= 0)
        {
            win = true;
        }
        else
        {
            win     = false;
            result *= -1;
        }

        int damage = result * 10;

        switch (win)
        {
        case true:

            elp     -= damage * mult;
            log.text = "With Fire and Steel your crew wins the fight and does " + damage * mult + "  damage to the enemy ship.\n That'll teach those rats who's the real king of the seas!";

            foreach (pirate p in manager.pirates)
            {
                if (p.prof == Class.Sailor && manager.sailorsfight == true)
                {
                    p.php -= 0.5f;
                    p.mhp -= 0.5f;
                }
                else if (p.prof == Class.Fighter)
                {
                    p.php -= 0.5f;
                }
                manager.checkdead();
            }


            break;

        case false:
            manager.HullPoint -= damage;
            log.text           = "Your crew fought bravely but it wasn't able to hold back the enemy assault, your ship takes " + damage + "  damage.\n We'll get those pox-ridden maggots next time!";

            foreach (pirate p in manager.pirates)
            {
                if (p.prof == Class.Sailor && manager.sailorsfight == true)
                {
                    p.php -= 1f;
                    p.mhp -= 1f;
                }
                else if (p.prof == Class.Fighter)
                {
                    p.php -= 1f;
                }
            }


            manager.checkdead();
            break;
        }

        NextStage();
    }