public void Generate(string direction)
    {
        if (this._biomSize == 0)
        {
            this._biomSize    = Random.Range(90, 250);
            this._currentBiom = (Bioms)Random.Range(0, 2);

            switch (this._currentBiom)
            {
            case Bioms.Sand:
                this._currentPlatforms = this.SandBiom;
                break;

            case Bioms.Vulkan:
                this._currentPlatforms = this.LavaBiom;
                break;

            case Bioms.Forest:
                this._currentPlatforms = this.ForestBiom;
                break;

            default:
                break;
            }
        }

        if (direction == "left")
        {
            this._currentOffset   = this.directionLeft;
            this._currentPosition = this.PositionLeft;
        }
        else
        {
            this._currentOffset   = this.directionRight;
            this._currentPosition = this.PositionRight;
        }

        int        temp = this._biomSize;
        GameObject platform;

        for (int i = 0; i < temp; i++)
        {
            platform = Instantiate(this._currentPlatforms[Random.Range(0, this._currentPlatforms.Length - 1)], this._currentPosition, new Quaternion(0, 0, 0, 0));
            this._currentPosition.x += this._currentOffset;
            this._biomSize--;

            if (direction == "left")
            {
                this.PositionLeft = this._currentPosition;
            }
            else
            {
                this.PositionRight = this._currentPosition;
            }
        }
    }
Exemple #2
0
    void OnDrawGizmosSelected()
    {
        Gizmos.color = Color.yellow;
        float pillarsRingStep = Bioms.GetInstance().GetCurrentBiomData().RingStep;

        for (int i = 1; i <= ring; i++)
        {
            UnityEditor.Handles.DrawWireDisc(center.position, center.up, pillarsRingStep * i);
        }
    }
Exemple #3
0
    private void Start()
    {
        // Singletone pattern
        if (instance == null)
        {
            instance = this;

            instance.diamondsProbabilities.Add(Diamond.DiamondTypes.COMMON, 0.744);
            instance.diamondsProbabilities.Add(Diamond.DiamondTypes.RARE, 0.2);
            instance.diamondsProbabilities.Add(Diamond.DiamondTypes.MYTHICAL, 0.05);
            instance.diamondsProbabilities.Add(Diamond.DiamondTypes.DRAGON, 0.005);
            instance.diamondsProbabilities.Add(Diamond.DiamondTypes.ONYKS, 0.001);
        }
        else if (instance == this)
        {
            Destroy(gameObject);
        }
    }
Exemple #4
0
    public static Bioms GetInstance()
    {
        if (instance == null)
        {
            instance = new Bioms();

            // Init probabilities dictionary
            Debug.Log("Added");
            instance.diamondsProbabilities.Add(Diamond.DiamondTypes.COMMON, 0.744);
            instance.diamondsProbabilities.Add(Diamond.DiamondTypes.RARE, 0.2);
            instance.diamondsProbabilities.Add(Diamond.DiamondTypes.MYTHICAL, 0.05);
            instance.diamondsProbabilities.Add(Diamond.DiamondTypes.DRAGON, 0.05);
            instance.diamondsProbabilities.Add(Diamond.DiamondTypes.ONYKS, 0.001);

            return(instance);
        }
        else
        {
            return(instance);
        }
    }
Exemple #5
0
    private IEnumerator DelayedPrerender()
    {
        yield return(null);

        float pillarsRingStep = Bioms.GetInstance().GetCurrentBiomData().RingStep;

        oldPillarsRingStep  = pillarsRingStep;
        prerenderRings      = Mathf.RoundToInt(renderRadius / pillarsRingStep);
        defaultRenderRadius = renderRadius;

        if (prerenderRings == 0)
        {
            prerenderRings = 1;
        }
        for (int i = 1; i <= prerenderRings; i++)
        {
            GenerateRing(ring);
            ring++;
        }
        prerendering = false;
    }
Exemple #6
0
    public void changeBiomGlobalCoords(int x, int z, Bioms newBiom)
    {
        Vector2Int pos = getPositionInChunk(x, z);

        changeBiomChunkCoords(pos.x, pos.z, newBiom);
    }
Exemple #7
0
 public void changeBiomChunkCoords(int x, int z, Bioms newBiom)
 {
     chunkBiomes[x, z] = (int)newBiom;
     //generateModel();
 }
Exemple #8
0
    //changes the biom of a hexagon
    public void changeBiom(int x, int z, Bioms newBiom)
    {
        Chunk c = getChunkAt(x, z);

        c.changeBiomGlobalCoords(x, z, newBiom);
    }