예제 #1
0
    private string randomReward(out int val)
    {
        // Roll chance for type of reward first
        float[] reward_type   = { coin_chance, ball_skin_chance, ball_trail_chance };
        int     reward_output = chanceRoll(reward_type);

        if (reward_output == 0)
        {
            // Coin Reward
            int coin_reward = chanceRoll(coin_reward_chance);
            val = coin_reward_values[coin_reward];
            return("coin");
        }
        else
        {
            BackgroundData bg_data = GameObject.Find("BackgroundDataCenter").GetComponent <BackgroundData>();

            if (reward_output == 1)
            {
                // Ball Skin Reward

                float[]  skin_chance = { common_chance, rare_chance, epic_chance, legendary_chance };
                int      skin_reward = chanceRoll(skin_chance);
                string[] skin_type   = { "common", "rare", "epic", "legendary" };

                Dictionary <string, ArrayList> ball_categories = bg_data.getCollectables()["ball_skins"];
                val = (int)Random.Range(0, (ball_categories[skin_type[skin_reward]].Count - 0.01f));
                return("ball_skin");
            }

            /*
             * else if (reward_output == 2)
             * {
             *  // Ball Trail Reward
             *  Debug.Log("TODO: Ball Trail");
             * }
             */
            else
            {
                Debug.Log("Reward Output out of range of index");
            }
        }



        // TODO - remove
        val = -1;
        return("null");
    }