コード例 #1
0
ファイル: BattleSystem.cs プロジェクト: jlindy12/WEST
    int TryToCatchAnimal(Animal animal)
    {
        float a = (3 * animal.MaxHP - 2 * animal.HP) * animal.Base.CatchRate * ConditionsDB.GetStatusBonus(animal.Status) / (3 * animal.MaxHP);

        if (a >= 255)
        {
            return(4);
        }

        float b = 1048560 / Mathf.Sqrt(Mathf.Sqrt(16711680 / a));

        int shakeCount = 0;

        while (shakeCount < 4)
        {
            if (UnityEngine.Random.Range(0, 65535) >= b)
            {
                break;
            }

            ++shakeCount;
        }

        return(shakeCount);
    }
コード例 #2
0
    //used in the age old method of enslaving creatures
    int TryToCatchCreature(Creature creature)
    {
        //the formula used in pokemon to capture using health, status and luck to try catch it
        float a = (3 * creature.MaxHp - 2 * creature.HP) * creature.Base.CatchRate * ConditionsDB.GetStatusBonus(creature.Status) / (3 * creature.MaxHp);

        if (a >= 255)
        {
            //on return 4 the creature is captured
            return(4);
        }

        //if the value is not equal to 255 a new value is required and its below....
        float b = 1048560 / Mathf.Sqrt(Mathf.Sqrt(16711680 / a));

        int shakeCount = 0;

        //run loop 4 times
        while (shakeCount < 4)
        {
            if (UnityEngine.Random.Range(0, 65535) >= b)
            {
                break;
            }
            ++shakeCount;
        }
        return(shakeCount);
    }
コード例 #3
0
ファイル: BattleSystem.cs プロジェクト: Naplyrroth/LabDay
    int TryToCatchPokemon(Pokemon pokemon)  //Number of shake the ball will do, and know if the pokemon is captured or not
    {
        //a is a value we'll use in the calculation of the number of shake the ball have to do
        float a = (3 * pokemon.MaxHp - 2 * pokemon.HP) * pokemon.Base.CatchRate * ConditionsDB.GetStatusBonus(pokemon.Status) / (3 * pokemon.MaxHp);

        if (a >= 255) //If a is enough (the pokemon already has 255, or by the calculus it's up to this value
        {
            return(4);
        }

        float b = 1048560 / Mathf.Sqrt(Mathf.Sqrt(16711680 / a)); //We'll use be to determine how many counts we have to do

        int shakeCount = 0;

        while (shakeCount < 4)
        {
            if (UnityEngine.Random.Range(0, 65535) >= b)
            {
                break;
            }

            ++shakeCount;
        }

        return(shakeCount);
    }
コード例 #4
0
ファイル: GameManager.cs プロジェクト: PJaButter/Pegasus
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(this.gameObject);
        }

        ConditionsDB.Init();
    }
コード例 #5
0
 private void Awake()
 {
     ConditionsDB.Init();
 }
コード例 #6
0
 private void Awake()
 {
     Instance = this;
     ConditionsDB.Init();
     BattleMusic = GetComponent <AudioSource>();
 }
コード例 #7
0
 private void Awake()
 {
     Instance = this;
     ConditionsDB.Initilize();
 }