158 lines
3.6 KiB
C#
158 lines
3.6 KiB
C#
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 "Plane":
|
|
return generateTileContent();
|
|
case "Mountain":
|
|
return generateStoneTileContent();
|
|
case "Forest":
|
|
return generateTreeTileContent();
|
|
case "River":
|
|
return generateRiverTileContent();
|
|
case "Lake":
|
|
return generateLakeTileContent();
|
|
}
|
|
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,2) == 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;
|
|
}
|
|
}
|
|
|
|
public GameObject generateRiverTileContent()
|
|
{
|
|
int chance = rand.Next(1, 101);
|
|
if (chance < 50)
|
|
{
|
|
return null;
|
|
}
|
|
else if (chance >= 50 && chance < 90)
|
|
{
|
|
if (rand.Next(0, 2) == 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 generateLakeTileContent()
|
|
{
|
|
int chance = rand.Next(1, 101);
|
|
if (chance < 75)
|
|
{
|
|
return null;
|
|
}
|
|
else if (chance >= 75 && chance < 90)
|
|
{
|
|
return stones[rand.Next(0, stones.Length)];
|
|
}
|
|
else if (chance >= 90 && chance < 99)
|
|
{
|
|
return generateEnemy();
|
|
}
|
|
else
|
|
{
|
|
return boss;
|
|
}
|
|
}
|
|
}
|