Early Access, v1.0.1
This commit is contained in:
104
Assets/Scripts/ContentGenerator.cs
Normal file
104
Assets/Scripts/ContentGenerator.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ContentGenerator : MonoBehaviour
|
||||
{
|
||||
public GameObject[] enemies;
|
||||
public GameObject[] trees;
|
||||
public GameObject[] stones;
|
||||
public GameObject grass;
|
||||
public GameObject boss;
|
||||
//public GameObject npc;
|
||||
static System.Random rand = new System.Random();
|
||||
|
||||
public GameObject generateEnemy()
|
||||
{
|
||||
int index = rand.Next(0, enemies.Length);
|
||||
return enemies[index];
|
||||
}
|
||||
|
||||
public GameObject generateContent(string tiletype)
|
||||
{
|
||||
switch (tiletype)
|
||||
{
|
||||
case "Tile":
|
||||
return generateTileContent();
|
||||
case "StoneTile":
|
||||
return generateStoneTileContent();
|
||||
case "TreeTile":
|
||||
return generateTreeTileContent();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public GameObject generateTileContent()
|
||||
{
|
||||
int chance = rand.Next(1, 101);
|
||||
if (chance < 50)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else if (chance >= 50 && chance < 90)
|
||||
{
|
||||
if (rand.Next(0,trees.Length) == 0)
|
||||
{
|
||||
return trees[rand.Next(0, trees.Length)];
|
||||
}
|
||||
else
|
||||
{
|
||||
return stones[rand.Next(0, stones.Length)];
|
||||
}
|
||||
}
|
||||
else if (chance >= 90 && chance < 99)
|
||||
{
|
||||
return generateEnemy();
|
||||
}
|
||||
else
|
||||
{
|
||||
return boss;
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject generateStoneTileContent()
|
||||
{
|
||||
int chance = rand.Next(1, 101);
|
||||
if (chance < 60)
|
||||
{
|
||||
return stones[rand.Next(0, stones.Length)];
|
||||
}
|
||||
else if (chance >= 60 && chance < 90)
|
||||
{
|
||||
return trees[rand.Next(0, trees.Length)];
|
||||
}
|
||||
else if (chance >= 90 && chance < 99)
|
||||
{
|
||||
return generateEnemy();
|
||||
}
|
||||
else
|
||||
{
|
||||
return boss;
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject generateTreeTileContent()
|
||||
{
|
||||
int chance = rand.Next(1, 101);
|
||||
if (chance < 60)
|
||||
{
|
||||
return trees[rand.Next(0, trees.Length)];
|
||||
}
|
||||
else if (chance >= 60 && chance < 90)
|
||||
{
|
||||
return stones[rand.Next(0, stones.Length)];
|
||||
}
|
||||
else if (chance >= 90 && chance < 99)
|
||||
{
|
||||
return generateEnemy();
|
||||
}
|
||||
else
|
||||
{
|
||||
return boss;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user