Added NPCs to game, fixed explore and collect quest, added quest remove, fixed quest update, v1.4.0
This commit is contained in:
parent
3f8d9c0551
commit
59e34ef728
@ -9778,6 +9778,7 @@ MonoBehaviour:
|
|||||||
- {fileID: 4813231546532491625, guid: ee075607d6b41e94d959a6a91288e2d3, type: 3}
|
- {fileID: 4813231546532491625, guid: ee075607d6b41e94d959a6a91288e2d3, type: 3}
|
||||||
grass: {fileID: 5970796181653315724, guid: 6622329b9828ab547b3ba34a33107c2d, type: 3}
|
grass: {fileID: 5970796181653315724, guid: 6622329b9828ab547b3ba34a33107c2d, type: 3}
|
||||||
boss: {fileID: 5250108364493051291, guid: a9001384d18dd1c4f94df7c4711588e4, type: 3}
|
boss: {fileID: 5250108364493051291, guid: a9001384d18dd1c4f94df7c4711588e4, type: 3}
|
||||||
|
npc: {fileID: 6513753043401943383, guid: fba991e0db8729b4c934e5c9620457f7, type: 3}
|
||||||
--- !u!4 &667353831
|
--- !u!4 &667353831
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -10,7 +10,7 @@ public class ContentGenerator : MonoBehaviour
|
|||||||
public GameObject[] stones;
|
public GameObject[] stones;
|
||||||
public GameObject grass;
|
public GameObject grass;
|
||||||
public GameObject boss;
|
public GameObject boss;
|
||||||
//public GameObject npc;
|
public GameObject npc;
|
||||||
static System.Random rand = new System.Random();
|
static System.Random rand = new System.Random();
|
||||||
|
|
||||||
public GameObject generateEnemy()
|
public GameObject generateEnemy()
|
||||||
@ -55,14 +55,18 @@ public class ContentGenerator : MonoBehaviour
|
|||||||
return stones[rand.Next(0, stones.Length)];
|
return stones[rand.Next(0, stones.Length)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (chance >= 90 && chance < 99)
|
else if (chance >= 90 && chance < 95)
|
||||||
{
|
{
|
||||||
return generateEnemy();
|
return generateEnemy();
|
||||||
}
|
}
|
||||||
else
|
else if(chance >= 95 && chance < 99)
|
||||||
{
|
{
|
||||||
return boss;
|
return boss;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return npc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameObject generateStoneTileContent()
|
public GameObject generateStoneTileContent()
|
||||||
@ -76,14 +80,18 @@ public class ContentGenerator : MonoBehaviour
|
|||||||
{
|
{
|
||||||
return trees[rand.Next(0, trees.Length)];
|
return trees[rand.Next(0, trees.Length)];
|
||||||
}
|
}
|
||||||
else if (chance >= 90 && chance < 99)
|
else if (chance >= 90 && chance < 95)
|
||||||
{
|
{
|
||||||
return generateEnemy();
|
return generateEnemy();
|
||||||
}
|
}
|
||||||
else
|
else if (chance >= 95 && chance < 99)
|
||||||
{
|
{
|
||||||
return boss;
|
return boss;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return npc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameObject generateTreeTileContent()
|
public GameObject generateTreeTileContent()
|
||||||
@ -97,14 +105,18 @@ public class ContentGenerator : MonoBehaviour
|
|||||||
{
|
{
|
||||||
return stones[rand.Next(0, stones.Length)];
|
return stones[rand.Next(0, stones.Length)];
|
||||||
}
|
}
|
||||||
else if (chance >= 90 && chance < 99)
|
else if (chance >= 90 && chance < 95)
|
||||||
{
|
{
|
||||||
return generateEnemy();
|
return generateEnemy();
|
||||||
}
|
}
|
||||||
else
|
else if (chance >= 95 && chance < 99)
|
||||||
{
|
{
|
||||||
return boss;
|
return boss;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return npc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameObject generateRiverTileContent()
|
public GameObject generateRiverTileContent()
|
||||||
@ -125,14 +137,18 @@ public class ContentGenerator : MonoBehaviour
|
|||||||
return stones[rand.Next(0, stones.Length)];
|
return stones[rand.Next(0, stones.Length)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (chance >= 90 && chance < 99)
|
else if (chance >= 90 && chance < 95)
|
||||||
{
|
{
|
||||||
return generateEnemy();
|
return generateEnemy();
|
||||||
}
|
}
|
||||||
else
|
else if (chance >= 95 && chance < 99)
|
||||||
{
|
{
|
||||||
return boss;
|
return boss;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return npc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameObject generateLakeTileContent()
|
public GameObject generateLakeTileContent()
|
||||||
@ -146,14 +162,18 @@ public class ContentGenerator : MonoBehaviour
|
|||||||
{
|
{
|
||||||
return stones[rand.Next(0, stones.Length)];
|
return stones[rand.Next(0, stones.Length)];
|
||||||
}
|
}
|
||||||
else if (chance >= 90 && chance < 99)
|
else if (chance >= 90 && chance < 95)
|
||||||
{
|
{
|
||||||
return generateEnemy();
|
return generateEnemy();
|
||||||
}
|
}
|
||||||
else
|
else if (chance >= 95 && chance < 99)
|
||||||
{
|
{
|
||||||
return boss;
|
return boss;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return npc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameObject loadObject(JToken json)
|
public GameObject loadObject(JToken json)
|
||||||
|
|||||||
@ -62,6 +62,7 @@ public class Controls : MonoBehaviour
|
|||||||
Destroy(target);
|
Destroy(target);
|
||||||
break;
|
break;
|
||||||
case "NPC":
|
case "NPC":
|
||||||
|
target.GetComponent<NPC>().interact();
|
||||||
break;
|
break;
|
||||||
case "House":
|
case "House":
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -48,6 +48,11 @@ namespace Assets.Scripts
|
|||||||
items[currentBag] = null;
|
items[currentBag] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeItem(int bag)
|
||||||
|
{
|
||||||
|
items[bag] = null;
|
||||||
|
}
|
||||||
|
|
||||||
public void showTooltip()
|
public void showTooltip()
|
||||||
{
|
{
|
||||||
Item item = getItemForTooltip();
|
Item item = getItemForTooltip();
|
||||||
|
|||||||
@ -2,8 +2,11 @@ using System.Collections;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class NPC : MonoBehaviour
|
namespace Assets.Scripts
|
||||||
{
|
{
|
||||||
|
public class NPC : MonoBehaviour
|
||||||
|
{
|
||||||
|
bool hasQuest = true;
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
@ -18,6 +21,17 @@ public class NPC : MonoBehaviour
|
|||||||
|
|
||||||
public void interact()
|
public void interact()
|
||||||
{
|
{
|
||||||
|
if (hasQuest)
|
||||||
|
{
|
||||||
|
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("SUCCESS;You got a quest from this NPC!");
|
||||||
|
GameObject.Find("QuestLog").GetComponent<QuestLog>().addQuest();
|
||||||
|
hasQuest = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("ERROR;You already got the quest from this NPC!");
|
||||||
|
}
|
||||||
|
GameObject.Find("QuestLog").GetComponent<QuestLog>().removeQuests();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -693,5 +693,10 @@ namespace Assets.Scripts
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getLuck()
|
||||||
|
{
|
||||||
|
return luck;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,16 +19,12 @@ namespace Assets.Scripts
|
|||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
quests = new Dictionary<string, List<Quest>>();
|
quests = new Dictionary<string, List<Quest>>();
|
||||||
quests.Add("main", new List<Quest>());
|
quests.Add("find", new List<Quest>());
|
||||||
GameObject newQuest = Instantiate(quest);
|
GameObject newQuest = Instantiate(quest);
|
||||||
newQuest.transform.SetParent(content.transform, false);
|
newQuest.transform.SetParent(content.transform, false);
|
||||||
FindQuest main = new FindQuest(newQuest);
|
FindQuest main = new FindQuest(newQuest);
|
||||||
main.generateCityQuest();
|
main.generateCityQuest();
|
||||||
quests["main"].Add(main);
|
quests["find"].Add(main);
|
||||||
for (int i = 0; i < 20; i++)
|
|
||||||
{
|
|
||||||
addQuest();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
@ -38,12 +34,15 @@ namespace Assets.Scripts
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateQuests(string key, object obj, int amount)
|
public void updateQuests(string key, object obj, int amount)
|
||||||
|
{
|
||||||
|
if (quests.ContainsKey(key))
|
||||||
{
|
{
|
||||||
foreach (Quest quest in quests[key])
|
foreach (Quest quest in quests[key])
|
||||||
{
|
{
|
||||||
quest.update(obj, amount);
|
quest.update(obj, amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void addQuest()
|
public void addQuest()
|
||||||
{
|
{
|
||||||
@ -100,6 +99,42 @@ namespace Assets.Scripts
|
|||||||
scrollBar.value = 0;
|
scrollBar.value = 0;
|
||||||
content.transform.localPosition = new Vector3(0,0,0);
|
content.transform.localPosition = new Vector3(0,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeQuests()
|
||||||
|
{
|
||||||
|
Inventory inventory = GameObject.Find("Inventory").GetComponent<Inventory>();
|
||||||
|
int luck = GameObject.Find("Player").GetComponent<Player>().getLuck();
|
||||||
|
luck = luck + inventory.getEquipmentBonus()["LCK"];
|
||||||
|
Dictionary<string, List<Quest>> toDelete = new Dictionary<string, List<Quest>>();
|
||||||
|
foreach (string key in quests.Keys)
|
||||||
|
{
|
||||||
|
foreach (Quest quest in quests[key])
|
||||||
|
{
|
||||||
|
if (quest.isFinishedQuest())
|
||||||
|
{
|
||||||
|
if (!toDelete.ContainsKey(key))
|
||||||
|
{
|
||||||
|
toDelete.Add(key, new List<Quest>());
|
||||||
|
}
|
||||||
|
toDelete[key].Add(quest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (string key in toDelete.Keys)
|
||||||
|
{
|
||||||
|
foreach (Quest quest in toDelete[key])
|
||||||
|
{
|
||||||
|
if (quest is CollectQuest)
|
||||||
|
{
|
||||||
|
((CollectQuest)quest).removeItems(inventory);
|
||||||
|
}
|
||||||
|
quest.delete();
|
||||||
|
quests[key].Remove(quest);
|
||||||
|
inventory.addItem(new Item(luck));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,31 +49,7 @@ namespace Assets.Scripts
|
|||||||
public void update(object obj, int amount)
|
public void update(object obj, int amount)
|
||||||
{
|
{
|
||||||
Item item = (Item)obj;
|
Item item = (Item)obj;
|
||||||
if (keyword == "Slimeball" && item.getName().ToLower().Contains("slimeball"))
|
if (checkItem(item))
|
||||||
{
|
|
||||||
current = current + amount;
|
|
||||||
}
|
|
||||||
if (keyword == "Stone" && item.getName().ToLower().Contains("stone"))
|
|
||||||
{
|
|
||||||
current = current + amount;
|
|
||||||
}
|
|
||||||
if (keyword == "Wood" && item.getName().ToLower().Contains("wood"))
|
|
||||||
{
|
|
||||||
current = current + amount;
|
|
||||||
}
|
|
||||||
if (keyword == "Common" && item.getName().ToLower().Contains("common"))
|
|
||||||
{
|
|
||||||
current = current + amount;
|
|
||||||
}
|
|
||||||
if (keyword == "Rare" && item.getName().ToLower().Contains("rare"))
|
|
||||||
{
|
|
||||||
current = current + amount;
|
|
||||||
}
|
|
||||||
if (keyword == "Epic" && item.getName().ToLower().Contains("epic"))
|
|
||||||
{
|
|
||||||
current = current + amount;
|
|
||||||
}
|
|
||||||
if (keyword == "Legendary" && item.getName().ToLower().Contains("legendary"))
|
|
||||||
{
|
{
|
||||||
current = current + amount;
|
current = current + amount;
|
||||||
}
|
}
|
||||||
@ -81,7 +57,73 @@ namespace Assets.Scripts
|
|||||||
{
|
{
|
||||||
isFinished = true;
|
isFinished = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isFinished = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeItems(Inventory inventory)
|
||||||
|
{
|
||||||
|
Item item;
|
||||||
|
int counter = 0;
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
foreach (GameObject slot in inventory.slots)
|
||||||
|
{
|
||||||
|
item = slot.GetComponent<InventorySlot>().getItem(i);
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
if (checkItem(item))
|
||||||
|
{
|
||||||
|
slot.GetComponent<InventorySlot>().removeItem(i);
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (counter == goal)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (counter == goal)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool checkItem(Item item)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
if (keyword == "Slimeball" && item.getName().ToLower().Contains("slimeball"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (keyword == "Stone" && item.getName().ToLower().Contains("stone"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (keyword == "Wood" && item.getName().ToLower().Contains("wood"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (keyword == "Common" && item.getName().ToLower().Contains("common"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (keyword == "Rare" && item.getName().ToLower().Contains("rare"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (keyword == "Epic" && item.getName().ToLower().Contains("epic"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (keyword == "Legendary" && item.getName().ToLower().Contains("legendary"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,17 +9,17 @@ namespace Assets.Scripts
|
|||||||
public ExploreQuest(GameObject display) : base(display)
|
public ExploreQuest(GameObject display) : base(display)
|
||||||
{
|
{
|
||||||
Vector3 playerPos = GameObject.Find("Player").GetComponent<Player>().transform.position;
|
Vector3 playerPos = GameObject.Find("Player").GetComponent<Player>().transform.position;
|
||||||
float coordX = getRandomNumber(20) - 10;
|
float coordX = getRandomNumber(1000) - 500;
|
||||||
float coordZ = getRandomNumber(20) - 10;
|
float coordZ = getRandomNumber(1000) - 500;
|
||||||
coordinates = new Vector3(playerPos.x + coordX, 0, playerPos.z + coordZ);
|
coordinates = new Vector3(playerPos.x + coordX, 0, playerPos.z + coordZ);
|
||||||
questname = "Travel to " + coordinates.x + "/" + coordinates.z + "(X/Z)";
|
questname = "Travel to " + Mathf.Floor(coordinates.x) + "/" + Mathf.Floor(coordinates.z) + "(X/Z)";
|
||||||
}
|
}
|
||||||
|
|
||||||
override
|
override
|
||||||
public void update(object obj, int amount)
|
public void update(object obj, int amount)
|
||||||
{
|
{
|
||||||
Vector3 player = ((GameObject)obj).transform.position;
|
Vector3 player = ((GameObject)obj).transform.position;
|
||||||
if (player.x - 5 >= coordinates.x && player.x + 5 <= coordinates.x && player.z - 5 >= coordinates.z && player.z + 5 <= coordinates.z)
|
if (player.x >= coordinates.x - 1 && player.x <= coordinates.x + 1 && player.z >= coordinates.z - 1 && player.z <= coordinates.z + 1)
|
||||||
{
|
{
|
||||||
isFinished = true;
|
isFinished = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,6 +33,10 @@ namespace Assets.Scripts
|
|||||||
{
|
{
|
||||||
display.transform.Find("imgDone").GetComponent<RawImage>().color = new Color(255,255,255,255);
|
display.transform.Find("imgDone").GetComponent<RawImage>().color = new Color(255,255,255,255);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
display.transform.Find("imgDone").GetComponent<RawImage>().color = new Color(255, 255, 255, 0);
|
||||||
|
}
|
||||||
float x = display.transform.localPosition.x;
|
float x = display.transform.localPosition.x;
|
||||||
float z = display.transform.localPosition.z;
|
float z = display.transform.localPosition.z;
|
||||||
display.transform.localPosition = new Vector3(x, positionY, z);
|
display.transform.localPosition = new Vector3(x, positionY, z);
|
||||||
@ -47,6 +51,16 @@ namespace Assets.Scripts
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool isFinishedQuest()
|
||||||
|
{
|
||||||
|
return isFinished;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete()
|
||||||
|
{
|
||||||
|
GameObject.Destroy(display);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user