Beispiel #1
0
    public GameObject getRandomItemInstance(Transform parent)
    {
        int        rand          = RandFuncs.Sample(distribution, (float)(normalItemProbability + itemOptions.Length - 1));
        Vector3    position      = new Vector3(parent.position.x, parent.position.y + 1, parent.position.z);
        GameObject resultingItem = (GameObject)Instantiate(itemOptions[rand], position, Quaternion.identity);

        resultingItem.transform.parent = parent;

        return(resultingItem);
    }
    private int getWeight()
    {
        int weight;

        if (diversity == 0)
        {
            weight = 0;
        }
        else if (diversity < 0.1)
        {
            weight = RandFuncs.Sample(new float[] { 0.9f, 0.05f, 0.05f });
        }
        else if (diversity < 0.2)
        {
            weight = RandFuncs.Sample(new float[] { 0.8f, 0.1f, 0.1f });
        }
        else if (diversity < 0.3)
        {
            weight = RandFuncs.Sample(new float[] { 0.7f, 0.2f, 0.1f });
        }
        else if (diversity < 0.4)
        {
            weight = RandFuncs.Sample(new float[] { 0.6f, 0.3f, 0.1f });
        }
        else if (diversity < 0.5)
        {
            weight = RandFuncs.Sample(new float[] { 0.5f, 0.35f, 0.15f });
        }
        else if (diversity < 0.6)
        {
            weight = RandFuncs.Sample(new float[] { 0.5f, 0.3f, 0.2f });
        }
        else if (diversity < 0.7)
        {
            weight = RandFuncs.Sample(new float[] { 0.45f, 0.35f, 0.20f });
        }
        else if (diversity < 0.8)
        {
            weight = RandFuncs.Sample(new float[] { 0.4f, 0.35f, 0.25f });
        }
        else if (diversity < 0.9)
        {
            weight = RandFuncs.Sample(new float[] { 0.35f, 0.35f, 0.3f });
        }
        else
        {
            weight = RandFuncs.Sample(new float[] { 0.33333f, 0.3333f, 0.3333f });
        }
        return(weight);
    }