Added NPCs to game, fixed explore and collect quest, added quest remove, fixed quest update, v1.4.0

This commit is contained in:
Nicola Sovic
2022-07-14 23:48:37 +02:00
parent 3f8d9c0551
commit 59e34ef728
10 changed files with 199 additions and 62 deletions

View File

@@ -49,31 +49,7 @@ namespace Assets.Scripts
public void update(object obj, int amount)
{
Item item = (Item)obj;
if (keyword == "Slimeball" && item.getName().ToLower().Contains("slimeball"))
{
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"))
if (checkItem(item))
{
current = current + amount;
}
@@ -81,7 +57,73 @@ namespace Assets.Scripts
{
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;
}
}
}

View File

@@ -9,17 +9,17 @@ namespace Assets.Scripts
public ExploreQuest(GameObject display) : base(display)
{
Vector3 playerPos = GameObject.Find("Player").GetComponent<Player>().transform.position;
float coordX = getRandomNumber(20) - 10;
float coordZ = getRandomNumber(20) - 10;
float coordX = getRandomNumber(1000) - 500;
float coordZ = getRandomNumber(1000) - 500;
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
public void update(object obj, int amount)
{
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;
}

View File

@@ -33,6 +33,10 @@ namespace Assets.Scripts
{
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 z = display.transform.localPosition.z;
display.transform.localPosition = new Vector3(x, positionY, z);
@@ -47,6 +51,16 @@ namespace Assets.Scripts
}
return result;
}
public bool isFinishedQuest()
{
return isFinished;
}
public void delete()
{
GameObject.Destroy(display);
}
}
}