fixed options, fixed save, new Screenshots, v.140
This commit is contained in:
@@ -7,11 +7,11 @@ namespace Assets.Scripts
|
||||
{
|
||||
public class Chest : MonoBehaviour
|
||||
{
|
||||
bool gotItem;
|
||||
bool gotItem = false;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
gotItem = false;
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@@ -37,16 +37,27 @@ namespace Assets.Scripts
|
||||
// Maybe add luck to increase chance for equipment
|
||||
item = new Equipment(luck);
|
||||
break;
|
||||
case 1:
|
||||
item = new Book(luck);
|
||||
break;
|
||||
/*case 1:
|
||||
//Removed lore for now... no idea for lore
|
||||
break;*/
|
||||
default:
|
||||
item = new Item(luck);
|
||||
item = new Item(luck, false);
|
||||
break;
|
||||
}
|
||||
GameObject.Find("Inventory").GetComponent<Inventory>().addItem(item);
|
||||
}
|
||||
gotItem = true;
|
||||
}
|
||||
|
||||
public bool saveChest(){
|
||||
return gotItem;
|
||||
}
|
||||
|
||||
public void loadChest(bool gotItem){
|
||||
this.gotItem = gotItem;
|
||||
if(gotItem){
|
||||
gameObject.transform.parent.Find("Lid").GetComponent<Animator>().Play("ChestOpen");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ public class ContentGenerator : MonoBehaviour
|
||||
public GameObject grass;
|
||||
public GameObject boss;
|
||||
public GameObject npc;
|
||||
public GameObject house;
|
||||
static System.Random rand = new System.Random();
|
||||
|
||||
public GameObject generateEnemy()
|
||||
@@ -33,6 +34,8 @@ public class ContentGenerator : MonoBehaviour
|
||||
return generateRiverTileContent();
|
||||
case "Lake":
|
||||
return generateLakeTileContent();
|
||||
case "City":
|
||||
return generateCityTileContent();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -180,7 +183,7 @@ public class ContentGenerator : MonoBehaviour
|
||||
{
|
||||
GameObject result = gameObject;
|
||||
string name = json["objectname"].ToString().Replace("(Clone)", "");
|
||||
if (name.ToLower().Contains("stone"))
|
||||
if (name.ToLower().Contains("rock") || name.ToLower().Contains("ore"))
|
||||
{
|
||||
foreach (GameObject stone in stones)
|
||||
{
|
||||
@@ -191,7 +194,7 @@ public class ContentGenerator : MonoBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
else if(name.ToLower().Contains("tree"))
|
||||
{
|
||||
foreach (GameObject tree in trees)
|
||||
{
|
||||
@@ -202,6 +205,12 @@ public class ContentGenerator : MonoBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(name.ToLower().Contains("npc")){
|
||||
result = npc;
|
||||
}
|
||||
else if(name.ToLower().Contains("house")){
|
||||
result = house;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -251,4 +260,28 @@ public class ContentGenerator : MonoBehaviour
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public GameObject generateCityTileContent(){
|
||||
int chance = rand.Next(1, 101);
|
||||
if (chance < 10)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else if (chance >= 10 && chance < 40)
|
||||
{
|
||||
return house;
|
||||
}
|
||||
else if (chance >= 40 && chance < 65)
|
||||
{
|
||||
return trees[rand.Next(0, trees.Length)];
|
||||
}
|
||||
else if (chance >= 65 && chance < 90)
|
||||
{
|
||||
return stones[rand.Next(0, stones.Length)];
|
||||
}
|
||||
else
|
||||
{
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public class Controls : MonoBehaviour
|
||||
player = GameObject.Find("Player");
|
||||
fight = GameObject.Find("Fight");
|
||||
worldGen = GameObject.Find("WorldGenerator");
|
||||
playerCam = GameObject.Find("InformationCamera");
|
||||
playerCam = GameObject.Find("Main Camera");
|
||||
uihandler = GameObject.Find("UIHandler").GetComponent<UIHandler>();
|
||||
}
|
||||
|
||||
@@ -71,6 +71,21 @@ public class Controls : MonoBehaviour
|
||||
case "Chest":
|
||||
target.GetComponent<Chest>().interact();
|
||||
break;
|
||||
case "Ore":
|
||||
if(target.name.ToLower().Contains("iron")){
|
||||
GameObject.Find("Inventory").GetComponent<Inventory>().addItem(new Item("Iron ore"));
|
||||
}
|
||||
else if(target.name.ToLower().Contains("gold")){
|
||||
GameObject.Find("Inventory").GetComponent<Inventory>().addItem(new Item("Gold ore"));
|
||||
}
|
||||
else if(target.name.ToLower().Contains("copper")){
|
||||
GameObject.Find("Inventory").GetComponent<Inventory>().addItem(new Item("Copper ore"));
|
||||
}
|
||||
else if(target.name.ToLower().Contains("tin")){
|
||||
GameObject.Find("Inventory").GetComponent<Inventory>().addItem(new Item("Tin ore"));
|
||||
}
|
||||
Destroy(target);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,19 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Assets.Scripts
|
||||
{
|
||||
public class Door : MonoBehaviour
|
||||
{
|
||||
bool hasInteracted;
|
||||
public bool hasInteracted = false;
|
||||
bool isOpen = false;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
hasInteracted = false;
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@@ -32,6 +34,7 @@ namespace Assets.Scripts
|
||||
int openChance = new System.Random().Next(4);
|
||||
if(openChance == 0){
|
||||
gameObject.GetComponent<Animator>().Play("DoorOpen");
|
||||
isOpen = true;
|
||||
}
|
||||
else{
|
||||
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("ERROR;This house is locked.");
|
||||
@@ -39,5 +42,23 @@ namespace Assets.Scripts
|
||||
}
|
||||
hasInteracted = true;
|
||||
}
|
||||
|
||||
public string saveHouse(){
|
||||
string result = "";
|
||||
result = result + FileHandler.generateJSON("objectname", "\"" + transform.parent.name + "\",\r\n");
|
||||
result = result + FileHandler.generateJSON("hasInteracted", "\"" + hasInteracted + "\",\r\n");
|
||||
result = result + FileHandler.generateJSON("isOpen", "\"" + isOpen + "\",\r\n");
|
||||
result = result + FileHandler.generateJSON("gotItem", "\"" + transform.parent.Find("chest").Find("Body").GetComponent<Chest>().saveChest() + "\"");
|
||||
return result;
|
||||
}
|
||||
|
||||
public void loadHouse(JToken json){
|
||||
hasInteracted = bool.Parse(json["hasInteracted"].ToString());
|
||||
isOpen = bool.Parse(json["isOpen"].ToString());
|
||||
transform.parent.Find("chest").Find("Body").GetComponent<Chest>().loadChest(bool.Parse(json["gotItem"].ToString()));
|
||||
if(isOpen){
|
||||
gameObject.GetComponent<Animator>().Play("DoorOpen");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,7 @@ public class Fight : MonoBehaviour
|
||||
this.enemy = enemy;
|
||||
this.player = player;
|
||||
enemy.GetComponent<Enemy>().scaleEnemy(player.GetComponent<Player>());
|
||||
enemy.transform.rotation = player.transform.rotation;
|
||||
enemy.transform.RotateAround (enemy.transform.position, enemy.transform.up, 180f);
|
||||
enemy.transform.rotation = Quaternion.Euler(0,GameObject.Find("Main Camera").transform.rotation.y + 180f,0);
|
||||
|
||||
uihandler = GameObject.Find("UIHandler").GetComponent<UIHandler>();
|
||||
uihandler.openFight();
|
||||
|
||||
@@ -27,7 +27,6 @@ public class AudioHandler : MonoBehaviour
|
||||
{
|
||||
cameraAudio = GameObject.Find("Main Camera").GetComponent<AudioSource>();
|
||||
playerAudio = GameObject.Find("Player").GetComponent<AudioSource>();
|
||||
loadAudioSettings();
|
||||
}
|
||||
|
||||
public void playButtonClick()
|
||||
@@ -114,15 +113,13 @@ public class AudioHandler : MonoBehaviour
|
||||
GameObject.Find("slideMusic").GetComponent<Slider>().value = cameraAudio.volume;
|
||||
}
|
||||
|
||||
public void loadAudioSettings()
|
||||
{
|
||||
FileHandler.loadAudio(filepath, cameraAudio, playerAudio);
|
||||
}
|
||||
|
||||
public void saveAudioSettings()
|
||||
public string saveAudioSettings()
|
||||
{
|
||||
string result = "";
|
||||
float music = GameObject.Find("slideMusic").GetComponent<Slider>().value;
|
||||
float effects = GameObject.Find("slideEffects").GetComponent<Slider>().value;
|
||||
FileHandler.saveAudio(filepath, music, effects);
|
||||
result = result + "Music:" + music + "\r\n";
|
||||
result = result + "Effects:" + effects;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ namespace Assets.Scripts
|
||||
|
||||
public void closeOptions()
|
||||
{
|
||||
audioHandler.loadAudioSettings();
|
||||
audioHandler.playButtonClick();
|
||||
uihandler.closeOptions();
|
||||
}
|
||||
@@ -83,9 +82,13 @@ namespace Assets.Scripts
|
||||
|
||||
public void saveOptions()
|
||||
{
|
||||
string saveText = "";
|
||||
audioHandler.playButtonClick();
|
||||
uihandler.adaptScreen();
|
||||
audioHandler.saveAudioSettings();
|
||||
saveText = saveText + uihandler.saveVideoSettings() + "\r\n";
|
||||
saveText = saveText + audioHandler.saveAudioSettings() + "\r\n";
|
||||
GameObject.Find("Main Camera").GetComponent<PlayerCamera>().speed = GameObject.Find("slideSensitivity").GetComponent<Slider>().value;
|
||||
saveText = saveText + "Sensitivity:"+GameObject.Find("slideSensitivity").GetComponent<Slider>().value;
|
||||
FileHandler.saveOptions(saveText);
|
||||
uihandler.closeOptions();
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace Assets.Scripts
|
||||
public class FileHandler
|
||||
{
|
||||
static StreamWriter sw;
|
||||
static string settingsPath = "./settings.txt";
|
||||
public static void saveGame(string data, string path)
|
||||
{
|
||||
sw = new StreamWriter(path);
|
||||
@@ -40,31 +41,90 @@ namespace Assets.Scripts
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveAudio(string path, float music, float effects)
|
||||
{
|
||||
sw = new StreamWriter(path);
|
||||
sw.WriteLine("Music:" + music);
|
||||
sw.WriteLine("Effects:" + effects);
|
||||
public static void saveOptions(string saveText){
|
||||
sw = new StreamWriter(settingsPath);
|
||||
sw.Write(saveText);
|
||||
sw.Flush();
|
||||
sw.Close();
|
||||
}
|
||||
|
||||
public static void loadAudio(string path, AudioSource cameraAudio, AudioSource playerAudio)
|
||||
{
|
||||
if (File.Exists(path))
|
||||
public static void loadOptions(bool isIngame){
|
||||
if (!File.Exists(settingsPath))
|
||||
{
|
||||
string[] lines = File.ReadAllLines(path);
|
||||
cameraAudio.volume = float.Parse(lines[0].Split(':')[1]);
|
||||
playerAudio.volume = float.Parse(lines[1].Split(':')[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
sw = File.CreateText(path);
|
||||
sw = File.CreateText(settingsPath);
|
||||
sw.WriteLine("Music:0.5");
|
||||
sw.WriteLine("Effects:0.5");
|
||||
sw.WriteLine("Resolution:0");
|
||||
sw.WriteLine("Mode:0");
|
||||
sw.WriteLine("Sensitivity:1");
|
||||
sw.Flush();
|
||||
sw.Close();
|
||||
}
|
||||
string[] lines = File.ReadAllLines(settingsPath);
|
||||
foreach(string line in lines){
|
||||
switch(line.Split(":")[0]){
|
||||
case "Music":
|
||||
GameObject.Find("Main Camera").GetComponent<AudioSource>().volume = float.Parse(line.Split(':')[1]);
|
||||
break;
|
||||
case "Effects":
|
||||
GameObject.Find("Player").GetComponent<AudioSource>().volume = float.Parse(line.Split(':')[1]);
|
||||
break;
|
||||
case "Resolution":
|
||||
switch(line.Split(":")[1].ToLower()){
|
||||
case "0":
|
||||
Screen.SetResolution(800, 600, Screen.fullScreenMode);
|
||||
break;
|
||||
case "1":
|
||||
Screen.SetResolution(1280, 800, Screen.fullScreenMode);
|
||||
break;
|
||||
case "2":
|
||||
Screen.SetResolution(1920, 1080, Screen.fullScreenMode);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "Mode":
|
||||
switch(line.Split(":")[1].ToLower()){
|
||||
case "0":
|
||||
Screen.fullScreenMode = FullScreenMode.Windowed;
|
||||
break;
|
||||
case "1":
|
||||
Screen.fullScreenMode = FullScreenMode.ExclusiveFullScreen;
|
||||
break;
|
||||
case "2":
|
||||
Screen.fullScreenMode = FullScreenMode.FullScreenWindow;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "Sensitivity":
|
||||
if(isIngame){
|
||||
GameObject.Find("Main Camera").GetComponent<PlayerCamera>().speed = float.Parse(line.Split(':')[1]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadOptionDisplay(){
|
||||
string[] lines = File.ReadAllLines(settingsPath);
|
||||
foreach(string line in lines){
|
||||
switch(line.Split(":")[0]){
|
||||
case "Music":
|
||||
GameObject.Find("slideMusic").GetComponent<Slider>().value = float.Parse(line.Split(':')[1]);
|
||||
break;
|
||||
case "Effects":
|
||||
GameObject.Find("slideEffects").GetComponent<Slider>().value = float.Parse(line.Split(':')[1]);
|
||||
break;
|
||||
case "Resolution":
|
||||
GameObject.Find("dropResolution").GetComponent<Dropdown>().value = int.Parse(line.Split(':')[1]);
|
||||
break;
|
||||
case "Mode":
|
||||
GameObject.Find("dropMode").GetComponent<Dropdown>().value = int.Parse(line.Split(':')[1]);
|
||||
break;
|
||||
case "Sensitivity":
|
||||
GameObject.Find("slideSensitivity").GetComponent<Slider>().value = float.Parse(line.Split(':')[1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string generateJSON(string key, object value)
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Assets.Scripts
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
FileHandler.loadOptions(true);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@@ -88,6 +88,15 @@ namespace Assets.Scripts
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool canPlayerRotate()
|
||||
{
|
||||
if (state == UIState.GAME)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool isPlayerInFight()
|
||||
{
|
||||
return state == UIState.FIGHT;
|
||||
@@ -116,7 +125,7 @@ namespace Assets.Scripts
|
||||
public void openOptions()
|
||||
{
|
||||
options.SetActive(true);
|
||||
GameObject.Find("AudioHandler").GetComponent<AudioHandler>().setSlider();
|
||||
FileHandler.loadOptionDisplay();
|
||||
hideOtherElements(options);
|
||||
state = UIState.PAUSEOPTIONS;
|
||||
GameObject.Find("ScrollbarOptions").GetComponent<Scrollbar>().value = 1f;
|
||||
@@ -243,21 +252,20 @@ namespace Assets.Scripts
|
||||
showHUD();
|
||||
}
|
||||
|
||||
public void adaptScreen()
|
||||
{
|
||||
public string saveVideoSettings(){
|
||||
GameObject resolution = GameObject.Find("dropResolution");
|
||||
GameObject mode = GameObject.Find("dropMode");
|
||||
|
||||
string result = "";
|
||||
switch (resolution.GetComponent<Dropdown>().value)
|
||||
{
|
||||
case 0:
|
||||
Screen.SetResolution(800,600, Screen.fullScreenMode);
|
||||
Screen.SetResolution(800, 600, Screen.fullScreenMode);
|
||||
break;
|
||||
case 1:
|
||||
Screen.SetResolution(1280, 800, Screen.fullScreenMode);
|
||||
break;
|
||||
case 2:
|
||||
Screen.SetResolution(1920,1080, Screen.fullScreenMode);
|
||||
Screen.SetResolution(1920, 1080, Screen.fullScreenMode);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -282,6 +290,9 @@ namespace Assets.Scripts
|
||||
}
|
||||
break;
|
||||
}
|
||||
result = result + "Resolution:"+resolution.GetComponent<Dropdown>().value+"\r\n";
|
||||
result = result + "Mode:"+mode.GetComponent<Dropdown>().value;
|
||||
return result;
|
||||
}
|
||||
|
||||
public void openPauseMenu()
|
||||
@@ -442,29 +453,25 @@ namespace Assets.Scripts
|
||||
|
||||
private void updateHealthUI(int health, int maxHealth)
|
||||
{
|
||||
GameObject foreground = GameObject.Find("healthForegroundInformation");
|
||||
GameObject background = GameObject.Find("healthBackgroundInformation");
|
||||
GameObject fill = GameObject.Find("pnlHealthBar");
|
||||
GameObject text = GameObject.Find("healthTextInformation");
|
||||
|
||||
updateBar(foreground, background, text, maxHealth, health);
|
||||
updateFill(fill, text, maxHealth, health);
|
||||
}
|
||||
|
||||
private void updateSecondaryUI(int secondary, int maxSecondary)
|
||||
{
|
||||
GameObject foreground = GameObject.Find("secondaryForegroundInformation");
|
||||
GameObject background = GameObject.Find("secondaryBackgroundInformation");
|
||||
GameObject fill = GameObject.Find("pnlSecondaryBar");
|
||||
GameObject text = GameObject.Find("secondaryTextInformation");
|
||||
|
||||
updateBar(foreground, background, text, maxSecondary, secondary);
|
||||
updateFill(fill, text, maxSecondary, secondary);
|
||||
}
|
||||
|
||||
private void updateExperienceUI(int experience, int maxExperience)
|
||||
{
|
||||
GameObject foreground = GameObject.Find("experienceForeground");
|
||||
GameObject background = GameObject.Find("experienceBackground");
|
||||
GameObject text = GameObject.Find("experienceText");
|
||||
GameObject fill = GameObject.Find("pnlExperience");
|
||||
|
||||
updateBar(foreground, background, text, maxExperience, experience);
|
||||
updateFill(fill, null, maxExperience, experience);
|
||||
}
|
||||
|
||||
public void updateHUD(Player player)
|
||||
@@ -476,13 +483,11 @@ namespace Assets.Scripts
|
||||
GameObject information = GameObject.Find("txtInformationHUD");
|
||||
player.updateNameHUD(information.GetComponent<Text>());
|
||||
|
||||
GameObject foreground = GameObject.Find("healthForegroundHUD");
|
||||
GameObject background = GameObject.Find("healthBackgroundHUD");
|
||||
updateBar(foreground, background, null, playerStats[1] + equipment["HP"], playerStats[0]);
|
||||
GameObject fill = GameObject.Find("HUD_healthFill");
|
||||
updateFill(fill, null, playerStats[1] + equipment["HP"], playerStats[0]);
|
||||
|
||||
foreground = GameObject.Find("secondaryForegroundHUD");
|
||||
background = GameObject.Find("secondaryBackgroundHUD");
|
||||
updateBar(foreground, background, null, playerStats[3] + equipment["MP"], playerStats[2]);
|
||||
fill = GameObject.Find("HUD_secondaryFill");
|
||||
updateFill(fill, null, playerStats[3] + equipment["MP"], playerStats[2]);
|
||||
}
|
||||
|
||||
public void updateBar(GameObject bar, GameObject barBackground, GameObject textField, int maxValue, int minValue)
|
||||
@@ -503,6 +508,22 @@ namespace Assets.Scripts
|
||||
bar.GetComponent<RectTransform>().offsetMax = new Vector2(-change, bar.GetComponent<RectTransform>().offsetMax.y);
|
||||
}
|
||||
|
||||
public void updateFill(GameObject fill, GameObject textField, int maxValue, int minValue)
|
||||
{
|
||||
string text = minValue + "/" + maxValue;
|
||||
float percentage = 0;
|
||||
if (maxValue > 0)
|
||||
{
|
||||
percentage = (1 / (float)maxValue) * minValue;
|
||||
}
|
||||
|
||||
if (textField != null)
|
||||
{
|
||||
textField.GetComponent<Text>().text = text;
|
||||
}
|
||||
fill.GetComponent<Image>().fillAmount = percentage;
|
||||
}
|
||||
|
||||
public void openIntroduction()
|
||||
{
|
||||
GameObject.Find("AudioHandler").GetComponent<AudioHandler>().Start();
|
||||
|
||||
@@ -225,7 +225,13 @@ namespace Assets.Scripts
|
||||
}
|
||||
else
|
||||
{
|
||||
items[bag] = new Item(json);
|
||||
if(json["place"] != null){
|
||||
items[bag] = new Equipment(json);
|
||||
}
|
||||
else{
|
||||
items[bag] = new Item(json);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Assets.Scripts
|
||||
ItemPlace place;
|
||||
Dictionary<string, int> attributes;
|
||||
|
||||
public Equipment(int luck) : base(luck)
|
||||
public Equipment(int luck) : base(luck, true)
|
||||
{
|
||||
attributes = new Dictionary<string, int>();
|
||||
int numberOfAttributes = 1;
|
||||
|
||||
@@ -14,13 +14,20 @@ namespace Assets.Scripts
|
||||
public Texture image;
|
||||
public Color32 rarityColor;
|
||||
|
||||
public Item(int luck)
|
||||
public Item(int luck, bool isEquipment)
|
||||
{
|
||||
luck = luck + GameObject.Find("Inventory").GetComponent<Inventory>().getEquipmentBonus()["LCK"];
|
||||
calculateRarity(luck);
|
||||
chooseItem();
|
||||
setColor();
|
||||
loadImage();
|
||||
if(isEquipment){
|
||||
luck = luck + GameObject.Find("Inventory").GetComponent<Inventory>().getEquipmentBonus()["LCK"];
|
||||
calculateRarity(luck);
|
||||
setColor();
|
||||
}
|
||||
else{
|
||||
chooseItem();
|
||||
rarity = ItemRarity.COMMON;
|
||||
rarityColor = Color.white;
|
||||
loadImage();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Item(string name)
|
||||
@@ -35,7 +42,12 @@ namespace Assets.Scripts
|
||||
{
|
||||
rarity = (ItemRarity)Enum.Parse(typeof(ItemRarity), json["rarity"].ToString());
|
||||
itemName = json["itemName"].ToString();
|
||||
setColor();
|
||||
if(json["place"] != null){
|
||||
setColor();
|
||||
}
|
||||
else{
|
||||
rarityColor = Color.white;
|
||||
}
|
||||
loadImage();
|
||||
}
|
||||
|
||||
@@ -92,6 +104,18 @@ namespace Assets.Scripts
|
||||
case "Rock":
|
||||
image = Resources.Load<Texture>("Items/Inv_Stone");
|
||||
break;
|
||||
case "Iron ore":
|
||||
image = Resources.Load<Texture>("Items/Inv_Iron");
|
||||
break;
|
||||
case "Gold ore":
|
||||
image = Resources.Load<Texture>("Items/Inv_Gold");
|
||||
break;
|
||||
case "Copper ore":
|
||||
image = Resources.Load<Texture>("Items/Inv_Copper");
|
||||
break;
|
||||
case "Tin ore":
|
||||
image = Resources.Load<Texture>("Items/Inv_Tin");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,6 +156,18 @@ namespace Assets.Scripts
|
||||
case "Rock":
|
||||
result = "Is it... Dwayne?";
|
||||
break;
|
||||
case "Iron ore":
|
||||
result = "The most basic ore";
|
||||
break;
|
||||
case "Gold ore":
|
||||
result = "Wooooow... Shiny.";
|
||||
break;
|
||||
case "Copper ore":
|
||||
result = "Cool";
|
||||
break;
|
||||
case "Tin ore":
|
||||
result = "Got inspired by Minecraft, huh?";
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -159,25 +195,20 @@ namespace Assets.Scripts
|
||||
|
||||
private void chooseItem()
|
||||
{
|
||||
/* Common: Slimeball
|
||||
* Rare:
|
||||
* Epic:
|
||||
* Legendary:
|
||||
*/
|
||||
int index = rand.Next(10);
|
||||
switch (rarity)
|
||||
int index = rand.Next(4);
|
||||
switch (index)
|
||||
{
|
||||
case ItemRarity.COMMON:
|
||||
case 0:
|
||||
itemName = "Slimeball";
|
||||
break;
|
||||
case ItemRarity.RARE:
|
||||
itemName = "Slimeball";
|
||||
case 1:
|
||||
itemName = "Rock";
|
||||
break;
|
||||
case ItemRarity.EPIC:
|
||||
itemName = "Slimeball";
|
||||
case 2:
|
||||
itemName = "Iron ore";
|
||||
break;
|
||||
case ItemRarity.LEGENDARY:
|
||||
itemName = "Slimeball";
|
||||
case 3:
|
||||
itemName = "Gold ore";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@ namespace Assets.Scripts.Menu
|
||||
|
||||
public void closeOptions()
|
||||
{
|
||||
audioHandler.loadAudioSettings();
|
||||
audioHandler.playButtonClick();
|
||||
uihandler.closeOptions();
|
||||
}
|
||||
@@ -62,9 +61,13 @@ namespace Assets.Scripts.Menu
|
||||
|
||||
public void saveOptions()
|
||||
{
|
||||
string saveText = "";
|
||||
audioHandler.playButtonClick();
|
||||
uihandler.adaptScreen();
|
||||
audioHandler.saveAudioSettings();
|
||||
saveText = saveText + uihandler.saveVideoSettings() + "\r\n";
|
||||
saveText = saveText + audioHandler.saveAudioSettings() + "\r\n";
|
||||
//GameObject.Find("Main Camera").GetComponent<PlayerCamera>().speed = GameObject.Find("slideSensitivity").GetComponent<Slider>().value;
|
||||
saveText = saveText + "Sensitivity:"+GameObject.Find("slideSensitivity").GetComponent<Slider>().value;
|
||||
FileHandler.saveOptions(saveText);
|
||||
uihandler.closeOptions();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace Assets.Scripts.Menu
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
FileHandler.loadOptions(false);
|
||||
options.SetActive(false);
|
||||
characterCreation.SetActive(false);
|
||||
mainMenu.SetActive(true);
|
||||
@@ -107,7 +108,7 @@ namespace Assets.Scripts.Menu
|
||||
{
|
||||
options.SetActive(true);
|
||||
mainMenu.SetActive(false);
|
||||
GameObject.Find("AudioHandler").GetComponent<AudioHandler>().setSlider();
|
||||
FileHandler.loadOptionDisplay();
|
||||
GameObject.Find("ScrollbarOptions").GetComponent<Scrollbar>().value = 1f;
|
||||
}
|
||||
|
||||
@@ -117,11 +118,10 @@ namespace Assets.Scripts.Menu
|
||||
mainMenu.SetActive(true);
|
||||
}
|
||||
|
||||
public void adaptScreen()
|
||||
{
|
||||
public string saveVideoSettings(){
|
||||
GameObject resolution = GameObject.Find("dropResolution");
|
||||
GameObject mode = GameObject.Find("dropMode");
|
||||
|
||||
string result = "";
|
||||
switch (resolution.GetComponent<Dropdown>().value)
|
||||
{
|
||||
case 0:
|
||||
@@ -156,6 +156,9 @@ namespace Assets.Scripts.Menu
|
||||
}
|
||||
break;
|
||||
}
|
||||
result = result + "Resolution:"+resolution.GetComponent<Dropdown>().value+"\r\n";
|
||||
result = result + "Mode:"+mode.GetComponent<Dropdown>().value;
|
||||
return result;
|
||||
}
|
||||
|
||||
public void updateCreationInformation()
|
||||
|
||||
@@ -33,5 +33,21 @@ namespace Assets.Scripts
|
||||
}
|
||||
GameObject.Find("QuestLog").GetComponent<QuestLog>().removeQuests();
|
||||
}
|
||||
|
||||
public bool receivedQuest(){
|
||||
return !hasQuest;
|
||||
}
|
||||
|
||||
public void loadQuest(string receivedQuest){
|
||||
|
||||
this.hasQuest = !bool.Parse(receivedQuest);
|
||||
}
|
||||
|
||||
public string saveNPC(){
|
||||
string result = "";
|
||||
result = result + FileHandler.generateJSON("objectname", "\"" + name + "\",");
|
||||
result = result + FileHandler.generateJSON("receivedQuest", "\"" + !hasQuest + "\"");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,43 @@ using System.Linq;
|
||||
public class NoiseGenerator
|
||||
{
|
||||
System.Random rand = new System.Random();
|
||||
public void applyNoise(GameObject tile)
|
||||
public void applyNoise(GameObject tile, string name)
|
||||
{
|
||||
if(name.Length > 0){
|
||||
applyCityNoise(tile);
|
||||
}
|
||||
else{
|
||||
applyNormalNoise(tile);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void applyCityNoise(GameObject tile)
|
||||
{
|
||||
//resetMesh(tile);
|
||||
Mesh mesh = tile.GetComponent<MeshFilter>().mesh;
|
||||
Vector3[] vertices = mesh.vertices;
|
||||
float[] samples;
|
||||
Color32[] colors;
|
||||
int chance = rand.Next(1, 101);
|
||||
samples = calculateSamplesCity(tile);
|
||||
string tiletype = "City";
|
||||
|
||||
colors = new Color32[samples.Length];
|
||||
for (int i = 0; i < samples.Length; i++)
|
||||
{
|
||||
colors[i] = new Color32(0, 185, 0, 255);
|
||||
}
|
||||
|
||||
for (int i = 0; i < samples.Length; i++)
|
||||
{
|
||||
vertices[i].y = samples[i] * 3;
|
||||
}
|
||||
applyMesh(tile, vertices, mesh, colors);
|
||||
tile.GetComponent<Tile>().setType(tiletype);
|
||||
}
|
||||
|
||||
private void applyNormalNoise(GameObject tile)
|
||||
{
|
||||
//resetMesh(tile);
|
||||
Mesh mesh = tile.GetComponent<MeshFilter>().mesh;
|
||||
@@ -55,6 +91,7 @@ public class NoiseGenerator
|
||||
high = new Color32(0, 185, 0, 255);
|
||||
tiletype = "Plane";
|
||||
}
|
||||
|
||||
|
||||
float lowestValue = 10;
|
||||
float highestValue = 0;
|
||||
@@ -119,6 +156,17 @@ public class NoiseGenerator
|
||||
return samples;
|
||||
}
|
||||
|
||||
private float[] calculateSamplesCity(GameObject tile){
|
||||
Mesh mesh = tile.GetComponent<MeshFilter>().mesh;
|
||||
Vector3[] vertices = mesh.vertices;
|
||||
float[] samples = new float[vertices.Length];
|
||||
for (int i = 0; i < vertices.Length; i++)
|
||||
{
|
||||
samples[i] = 0;
|
||||
}
|
||||
return samples;
|
||||
}
|
||||
|
||||
private float[] calculateSamplesPlane(GameObject tile)
|
||||
{
|
||||
float[] samples = calculateBasicSamples(tile);
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace Assets.Scripts
|
||||
int killcount = -1;
|
||||
int difficulty = 0;
|
||||
Dictionary<string, int> equipment;
|
||||
bool finishedGame = false;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
@@ -194,7 +195,9 @@ namespace Assets.Scripts
|
||||
getRotation();
|
||||
regeneratePlayer();
|
||||
uihandler.adjustInformation(this);
|
||||
gameFinished();
|
||||
if(!finishedGame){
|
||||
gameFinished();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,6 +249,7 @@ namespace Assets.Scripts
|
||||
|
||||
public void move()
|
||||
{
|
||||
GameObject camera = GameObject.Find("Main Camera");
|
||||
float x = Input.GetAxis("Horizontal");
|
||||
float z = Input.GetAxis("Vertical");
|
||||
|
||||
@@ -268,16 +272,13 @@ namespace Assets.Scripts
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 movement = new Vector3(0, 0, z);
|
||||
Vector3 rotation = new Vector3(0, x * 20, 0);
|
||||
|
||||
gameObject.transform.Rotate(rotation * speed * Time.deltaTime);
|
||||
Vector3 movement = new Vector3(x, 0, z);
|
||||
movement = camera.transform.TransformDirection(movement);
|
||||
movement.y = 0;
|
||||
gameObject.transform.Translate(movement * speed * Time.deltaTime);
|
||||
|
||||
if (z != 0)
|
||||
{
|
||||
GameObject camera = GameObject.Find("Main Camera");
|
||||
|
||||
if (camera.transform.localPosition.y >= 0.5)
|
||||
{
|
||||
bobbingDirection = -1;
|
||||
@@ -294,31 +295,16 @@ namespace Assets.Scripts
|
||||
|
||||
public void getRotation()
|
||||
{
|
||||
GameObject.Find("North").GetComponent<Text>().color = Color.white;
|
||||
GameObject.Find("East").GetComponent<Text>().color = Color.white;
|
||||
GameObject.Find("South").GetComponent<Text>().color = Color.white;
|
||||
GameObject.Find("West").GetComponent<Text>().color = Color.white;
|
||||
float rotation = gameObject.transform.rotation.eulerAngles.y;
|
||||
GameObject needle = GameObject.Find("imgNeedle");
|
||||
float rotation = GameObject.Find("Main Camera").transform.rotation.eulerAngles.y;
|
||||
if (rotation < 0)
|
||||
{
|
||||
rotation += 360;
|
||||
}
|
||||
if (rotation <= 44 || rotation >= 315)
|
||||
{
|
||||
GameObject.Find("North").GetComponent<Text>().color = Color.red;
|
||||
}
|
||||
else if (rotation >= 45 && rotation <= 134)
|
||||
{
|
||||
GameObject.Find("East").GetComponent<Text>().color = Color.red;
|
||||
}
|
||||
else if (rotation >= 135 && rotation <= 224)
|
||||
{
|
||||
GameObject.Find("South").GetComponent<Text>().color = Color.red;
|
||||
}
|
||||
else if (rotation >= 225 && rotation <= 314)
|
||||
{
|
||||
GameObject.Find("West").GetComponent<Text>().color = Color.red;
|
||||
if(rotation >= 360){
|
||||
rotation -= 360;
|
||||
}
|
||||
needle.transform.eulerAngles = new Vector3(0,0,rotation);
|
||||
}
|
||||
|
||||
public int[] getStats()
|
||||
@@ -468,6 +454,7 @@ namespace Assets.Scripts
|
||||
{
|
||||
if (GameObject.Find("WorldGenerator").GetComponent<WorldGenerator>().gameWon())
|
||||
{
|
||||
finishedGame = true;
|
||||
uihandler.showMessage("SUCCESS;You won the game!");
|
||||
switch (difficulty)
|
||||
{
|
||||
|
||||
@@ -8,17 +8,32 @@ namespace Assets.Scripts
|
||||
public class PlayerCamera : MonoBehaviour
|
||||
{
|
||||
UIHandler uihandler;
|
||||
GameObject player;
|
||||
Vector2 rotation = Vector2.zero;
|
||||
public float speed = 1; //the sensibility
|
||||
public float xMaxLimit = 25.0f;
|
||||
public float xMinLimit = -25.0f;
|
||||
GameObject interact;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
uihandler = GameObject.Find("UIHandler").GetComponent<UIHandler>();
|
||||
player = gameObject.transform.parent.gameObject;
|
||||
interact = GameObject.Find("pnlInteract");
|
||||
interact.transform.localScale = new Vector3(0,0,0);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
{
|
||||
if(uihandler.canPlayerRotate()){
|
||||
rotation.y += Input.GetAxis("Mouse X");
|
||||
rotation.x += -Input.GetAxis("Mouse Y");
|
||||
rotation.x = Mathf.Clamp(rotation.x, xMinLimit, xMaxLimit);
|
||||
transform.eulerAngles = (Vector2)rotation * speed;
|
||||
}
|
||||
transform.position = new Vector3(transform.parent.transform.position.x, transform.position.y, transform.parent.transform.position.z);
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
@@ -42,11 +57,15 @@ namespace Assets.Scripts
|
||||
void showInformation()
|
||||
{
|
||||
RaycastHit hit;
|
||||
interact.transform.localScale = new Vector3(0,0,0);
|
||||
if (Physics.Raycast(transform.position, transform.forward, out hit, Mathf.Infinity))
|
||||
{
|
||||
if (hit.collider.gameObject.tag.ToLower().Contains("object"))
|
||||
{
|
||||
string obj = hit.collider.gameObject.tag.Split(':')[1];
|
||||
if(hit.distance <= 3 && !obj.ToLower().Equals("house")){
|
||||
interact.transform.localScale = new Vector3(1,1,1);
|
||||
}
|
||||
switch (obj.ToLower())
|
||||
{
|
||||
case "tree":
|
||||
@@ -61,18 +80,29 @@ namespace Assets.Scripts
|
||||
case "enemy":
|
||||
displayInformation(hit.collider.gameObject.GetComponent<Enemy>().getEnemyName());
|
||||
break;
|
||||
case "city":
|
||||
displayInformation("City");
|
||||
break;
|
||||
case "house":
|
||||
displayInformation("House");
|
||||
break;
|
||||
case "door":
|
||||
displayInformation("Exit");
|
||||
displayInformation("Door");
|
||||
break;
|
||||
case "chest":
|
||||
displayInformation("Chest");
|
||||
break;
|
||||
case "ore":
|
||||
if(hit.collider.gameObject.name.ToLower().Contains("iron")){
|
||||
displayInformation("Iron ore");
|
||||
}
|
||||
else if(hit.collider.gameObject.name.ToLower().Contains("gold")){
|
||||
displayInformation("Gold ore");
|
||||
}
|
||||
else if(hit.collider.gameObject.name.ToLower().Contains("copper")){
|
||||
displayInformation("Copper ore");
|
||||
}
|
||||
else if(hit.collider.gameObject.name.ToLower().Contains("tin")){
|
||||
displayInformation("Tin ore");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
uihandler.hideInformation();
|
||||
break;
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Assets.Scripts
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
if (quests == null)
|
||||
if (quests == null && PlayerPrefs.GetInt("isLoad") != 1)
|
||||
{
|
||||
quests = new Dictionary<string, List<Quest>>();
|
||||
quests.Add("find", new List<Quest>());
|
||||
@@ -129,18 +129,24 @@ namespace Assets.Scripts
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int rand = new System.Random().Next(100) + 1;
|
||||
foreach (string key in toDelete.Keys)
|
||||
{
|
||||
foreach (Quest quest in toDelete[key])
|
||||
{
|
||||
rand = new System.Random().Next(4);
|
||||
if (quest is CollectQuest)
|
||||
{
|
||||
((CollectQuest)quest).removeItems(inventory);
|
||||
}
|
||||
quest.delete();
|
||||
quests[key].Remove(quest);
|
||||
inventory.addItem(new Item(luck));
|
||||
if(rand == 1){
|
||||
inventory.addItem(new Equipment(luck));
|
||||
}
|
||||
else{
|
||||
inventory.addItem(new Item(luck, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,6 +181,13 @@ namespace Assets.Scripts
|
||||
return result;
|
||||
}
|
||||
|
||||
private void clearQuestlog(){
|
||||
int children = content.transform.childCount;
|
||||
for(int i = 0; i < children; i++){
|
||||
Destroy(content.transform.GetChild(i).gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void loadQuests(JToken json)
|
||||
{
|
||||
var jsonData = JObject.Parse(json.ToString()).Children();
|
||||
@@ -182,10 +195,9 @@ namespace Assets.Scripts
|
||||
List<JToken> quests;
|
||||
string key = "";
|
||||
Quest questItem;
|
||||
if (this.quests == null)
|
||||
{
|
||||
this.quests = new Dictionary<string, List<Quest>>();
|
||||
}
|
||||
this.quests = new Dictionary<string, List<Quest>>();
|
||||
this.quests.Clear();
|
||||
clearQuestlog();
|
||||
foreach (JToken keyword in keywords)
|
||||
{
|
||||
jsonData = JObject.Parse(keyword.ToString()).Children();
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Assets.Scripts
|
||||
current = 0;
|
||||
goal = getRandomNumber(10) + 1;
|
||||
questname = "Collect " + goal + " ";
|
||||
int index = getRandomNumber(7);
|
||||
int index = getRandomNumber(11);
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
@@ -43,6 +43,22 @@ namespace Assets.Scripts
|
||||
questname = questname + "legendary items";
|
||||
keyword = "Legendary";
|
||||
break;
|
||||
case 7:
|
||||
questname = questname + "iron ore";
|
||||
keyword = "Iron";
|
||||
break;
|
||||
case 8:
|
||||
questname = questname + "gold ore";
|
||||
keyword = "Gold";
|
||||
break;
|
||||
case 9:
|
||||
questname = questname + "copper ore";
|
||||
keyword = "Copper";
|
||||
break;
|
||||
case 10:
|
||||
questname = questname + "tin ore";
|
||||
keyword = "Tin";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,6 +122,22 @@ namespace Assets.Scripts
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (keyword == "Iron" && item.getName().ToLower().Contains("iron"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (keyword == "Gold" && item.getName().ToLower().Contains("gold"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (keyword == "Copper" && item.getName().ToLower().Contains("copper"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (keyword == "Tin" && item.getName().ToLower().Contains("tin"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (keyword == "Wood" && item.getName().ToLower().Contains("wood"))
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -103,17 +103,17 @@ namespace Assets.Scripts.Slimes
|
||||
int rand = new System.Random().Next(100) + 1;
|
||||
if (rand < 10 + luck)
|
||||
{
|
||||
int type = new System.Random().Next(3);
|
||||
int type = new System.Random().Next(2);
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
item = new Equipment(luck);
|
||||
break;
|
||||
case 1:
|
||||
/*case 1:
|
||||
item = new Book(luck);
|
||||
break;
|
||||
case 2:
|
||||
item = new Item(luck);
|
||||
break;*/
|
||||
case 1:
|
||||
item = new Item(luck,false);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ public class Tile : MonoBehaviour
|
||||
GameObject contentGenerator;
|
||||
|
||||
List<GameObject> aliveEnemies = new List<GameObject>();
|
||||
List<GameObject> deadEnemies = new List<GameObject>();
|
||||
|
||||
public void generateTile(Vector3 pos, string type)
|
||||
{
|
||||
@@ -47,12 +46,9 @@ public class Tile : MonoBehaviour
|
||||
|
||||
public void generateContent()
|
||||
{
|
||||
if (!tiletype.ToLower().Equals("City"))
|
||||
foreach (Vector3 position in getSpawnLocations())
|
||||
{
|
||||
foreach (Vector3 position in getSpawnLocations())
|
||||
{
|
||||
spawnObject(position);
|
||||
}
|
||||
spawnObject(position);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,13 +57,26 @@ public class Tile : MonoBehaviour
|
||||
List<Vector3> list = new List<Vector3>();
|
||||
int xChange = 0;
|
||||
int zChange = 0;
|
||||
for (float i = borderNorth - 10; i >= borderSouth + 10; i = i - 10)
|
||||
int sideLimiter = 0;
|
||||
if(tiletype == "City"){
|
||||
sideLimiter = 20;
|
||||
}
|
||||
else{
|
||||
sideLimiter = 10;
|
||||
}
|
||||
for (float i = borderNorth - sideLimiter; i >= borderSouth + sideLimiter; i = i - sideLimiter)
|
||||
{
|
||||
for (float j = borderWest + 10; j <= borderEast - 10; j = j + 10)
|
||||
for (float j = borderWest + sideLimiter; j <= borderEast - sideLimiter; j = j + sideLimiter)
|
||||
{
|
||||
xChange = rand.Next(-4, +4);
|
||||
zChange = rand.Next(-4, +4);
|
||||
list.Add(new Vector3(j + xChange, 5, i + zChange));
|
||||
xChange = rand.Next(-2, +2);
|
||||
zChange = rand.Next(-2, +2);
|
||||
if(tiletype == "City"){
|
||||
list.Add(new Vector3(j + xChange, 0, i + zChange));
|
||||
}
|
||||
else{
|
||||
list.Add(new Vector3(j + xChange, 5, i + zChange));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return list;
|
||||
@@ -76,11 +85,14 @@ public class Tile : MonoBehaviour
|
||||
public void spawnObject(Vector3 position)
|
||||
{
|
||||
int chance = rand.Next(1, 101);
|
||||
if (chance >= 50)
|
||||
if (chance >= 25)
|
||||
{
|
||||
GameObject content = contentGenerator.GetComponent<ContentGenerator>().generateContent(tiletype);
|
||||
if (content != null)
|
||||
{
|
||||
if(tiletype == "City" && (content.tag.ToLower().Contains("npc") || content.tag.ToLower().Contains("tree") || content.tag.ToLower().Contains("stone") || content.tag.ToLower().Contains("ore"))){
|
||||
position.y = 5;
|
||||
}
|
||||
GameObject obj = Instantiate(content, position, Quaternion.identity);
|
||||
obj.transform.parent = gameObject.transform;
|
||||
if (obj.tag.Contains("Enemy"))
|
||||
@@ -121,26 +133,17 @@ public class Tile : MonoBehaviour
|
||||
{
|
||||
foreach (Rigidbody rigid in gameObject.GetComponentsInChildren<Rigidbody>())
|
||||
{
|
||||
if (!deadEnemies.Contains(rigid.gameObject))
|
||||
{
|
||||
rigid.useGravity = !rigid.useGravity;
|
||||
}
|
||||
rigid.useGravity = !rigid.useGravity;
|
||||
}
|
||||
|
||||
foreach (Renderer rend in gameObject.GetComponentsInChildren<Renderer>())
|
||||
{
|
||||
if (!deadEnemies.Contains(rend.gameObject))
|
||||
{
|
||||
rend.enabled = !rend.enabled;
|
||||
}
|
||||
rend.enabled = !rend.enabled;
|
||||
}
|
||||
|
||||
foreach (Collider col in gameObject.GetComponentsInChildren<Collider>())
|
||||
{
|
||||
if (!deadEnemies.Contains(col.gameObject))
|
||||
{
|
||||
col.enabled = !col.enabled;
|
||||
}
|
||||
col.enabled = !col.enabled;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,11 +214,8 @@ public class Tile : MonoBehaviour
|
||||
|
||||
public void enemyKilled(GameObject enemy)
|
||||
{
|
||||
deadEnemies.Add(enemy);
|
||||
enemy.GetComponent<Rigidbody>().useGravity = false;
|
||||
enemy.GetComponent<Renderer>().enabled = false;
|
||||
enemy.GetComponent<Collider>().enabled = false;
|
||||
aliveEnemies.Remove(enemy);
|
||||
Destroy(enemy);
|
||||
}
|
||||
|
||||
public string getTileType()
|
||||
@@ -239,6 +239,12 @@ public class Tile : MonoBehaviour
|
||||
{
|
||||
result = result + obj.GetComponent<Enemy>().saveEnemy() + "\r\n}";
|
||||
}
|
||||
else if(obj.name.ToLower().Contains("house")){
|
||||
result = result + obj.transform.Find("Door").GetComponent<Door>().saveHouse() + "\r\n}";
|
||||
}
|
||||
else if(obj.name.ToLower().Contains("npc")){
|
||||
result = result + obj.GetComponent<NPC>().saveNPC() + "\r\n}";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = result + FileHandler.generateJSON("objectname", "\"" + obj.name + "\"") + "\r\n}";
|
||||
@@ -296,6 +302,12 @@ public class Tile : MonoBehaviour
|
||||
spawnedObject.GetComponent<Enemy>().loadEnemy(obj);
|
||||
}
|
||||
}
|
||||
else if(spawnedObject.name.ToLower().Contains("house")){
|
||||
spawnedObject.transform.Find("Door").GetComponent<Door>().loadHouse(obj);
|
||||
}
|
||||
else if(spawnedObject.tag.ToLower().Contains("npc")){
|
||||
spawnedObject.GetComponent<NPC>().loadQuest(obj["receivedQuest"].ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
tiletype = json["tiletype"].ToString();
|
||||
|
||||
@@ -11,7 +11,6 @@ using UnityEngine.UI;
|
||||
public class WorldGenerator : MonoBehaviour
|
||||
{
|
||||
public GameObject player;
|
||||
public GameObject city;
|
||||
public GameObject tile;
|
||||
Dictionary<Vector3, GameObject> tiles;
|
||||
GameObject currentTile;
|
||||
@@ -90,31 +89,22 @@ public class WorldGenerator : MonoBehaviour
|
||||
if (!tiles.ContainsKey(pos) && pos.y == 0)
|
||||
{
|
||||
GameObject newTile;
|
||||
string name;
|
||||
string name = "";
|
||||
int chance = rand.Next(1,11);
|
||||
Vector3 mapPos = new Vector3(pos.x * 100, 0, pos.z * 100);
|
||||
newTile = Instantiate(tile, mapPos, Quaternion.identity);
|
||||
if (chance == 1)
|
||||
{
|
||||
if (cityAmount > 0)
|
||||
{
|
||||
newTile = Instantiate(city, mapPos, Quaternion.identity);
|
||||
name = city.name;
|
||||
name = "City";
|
||||
cityAmount--;
|
||||
SteamWorksHandler.getStandardAchievement("CityAchievement");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
newTile = Instantiate(tile, mapPos, Quaternion.identity);
|
||||
name = tile.name;
|
||||
noise.applyNoise(newTile);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newTile = Instantiate(tile, mapPos, Quaternion.identity);
|
||||
noise.applyNoise(newTile, name);
|
||||
if(name.Length <= 0){
|
||||
name = tile.name;
|
||||
noise.applyNoise(newTile);
|
||||
}
|
||||
if (name.Contains("_"))
|
||||
{
|
||||
@@ -237,7 +227,7 @@ public class WorldGenerator : MonoBehaviour
|
||||
mapPos = new Vector3(pos.x * 100, 0, pos.z * 100);
|
||||
if (jsonData["tiletype"].ToString() == "CityTile")
|
||||
{
|
||||
loadedTile = Instantiate(city, mapPos, Quaternion.identity);
|
||||
loadedTile = Instantiate(tile, mapPos, Quaternion.identity);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -249,9 +239,9 @@ public class WorldGenerator : MonoBehaviour
|
||||
renderedTiles.Add(loadedTile);
|
||||
}
|
||||
currentTile = tiles[current];
|
||||
updateRenderedTiles();
|
||||
Vector3 position = new Vector3(currentTile.transform.position.x, 5, currentTile.transform.position.z);
|
||||
player.transform.SetPositionAndRotation(position, player.transform.rotation);
|
||||
updateRenderedTiles();
|
||||
}
|
||||
|
||||
public int getCityAmount()
|
||||
|
||||
Reference in New Issue
Block a user