Added inheritance for quests, finished quest implementation (90%), v1.4.0
This commit is contained in:
87
Assets/Scripts/Quests/CollectQuest.cs
Normal file
87
Assets/Scripts/Quests/CollectQuest.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts
|
||||
{
|
||||
public class CollectQuest : Quest
|
||||
{
|
||||
public CollectQuest(GameObject display) : base(display)
|
||||
{
|
||||
current = 0;
|
||||
goal = getRandomNumber(10) + 1;
|
||||
questname = "Collect " + goal + " ";
|
||||
int index = getRandomNumber(7);
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
questname = questname + "slimeballs";
|
||||
keyword = "Slimeball";
|
||||
break;
|
||||
case 1:
|
||||
questname = questname + "stones";
|
||||
keyword = "Stone";
|
||||
break;
|
||||
case 2:
|
||||
questname = questname + "wood";
|
||||
keyword = "Wood";
|
||||
break;
|
||||
case 3:
|
||||
questname = questname + "common items";
|
||||
keyword = "Common";
|
||||
break;
|
||||
case 4:
|
||||
questname = questname + "rare items";
|
||||
keyword = "Rare";
|
||||
break;
|
||||
case 5:
|
||||
questname = questname + "epic items";
|
||||
keyword = "Epic";
|
||||
break;
|
||||
case 6:
|
||||
questname = questname + "legendary items";
|
||||
keyword = "Legendary";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
override
|
||||
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"))
|
||||
{
|
||||
current = current + amount;
|
||||
}
|
||||
if (current >= goal)
|
||||
{
|
||||
isFinished = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/Quests/CollectQuest.cs.meta
Normal file
11
Assets/Scripts/Quests/CollectQuest.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 87adb6ce71d334d41832c6e5946c8401
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
29
Assets/Scripts/Quests/ExploreQuest.cs
Normal file
29
Assets/Scripts/Quests/ExploreQuest.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts
|
||||
{
|
||||
public class ExploreQuest : Quest
|
||||
{
|
||||
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;
|
||||
coordinates = new Vector3(playerPos.x + coordX, 0, playerPos.z + coordZ);
|
||||
questname = "Travel to " + coordinates.x + "/" + 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)
|
||||
{
|
||||
isFinished = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Scripts/Quests/ExploreQuest.cs.meta
Normal file
11
Assets/Scripts/Quests/ExploreQuest.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc8224ede819f4b478849d299ab24004
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
83
Assets/Scripts/Quests/FindQuest.cs
Normal file
83
Assets/Scripts/Quests/FindQuest.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts
|
||||
{
|
||||
public class FindQuest : Quest
|
||||
{
|
||||
public FindQuest(GameObject display) : base(display)
|
||||
{
|
||||
current = 0;
|
||||
goal = getRandomNumber(10) + 1;
|
||||
questname = "Find " + goal + " ";
|
||||
int index = getRandomNumber(5);
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
questname = questname + "planes";
|
||||
keyword = "Plane";
|
||||
break;
|
||||
case 1:
|
||||
questname = questname + "mountains";
|
||||
keyword = "Mountain";
|
||||
break;
|
||||
case 2:
|
||||
questname = questname + "forests";
|
||||
keyword = "Forest";
|
||||
break;
|
||||
case 3:
|
||||
questname = questname + "rivers";
|
||||
keyword = "River";
|
||||
break;
|
||||
case 4:
|
||||
questname = questname + "lakes";
|
||||
keyword = "Lake";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void generateCityQuest()
|
||||
{
|
||||
questname = "Find all cities";
|
||||
keyword = "City";
|
||||
current = 0;
|
||||
goal = GameObject.Find("WorldGenerator").GetComponent<WorldGenerator>().getCityAmount();
|
||||
}
|
||||
|
||||
override
|
||||
public void update(object obj, int amount)
|
||||
{
|
||||
GameObject tile = (GameObject)obj;
|
||||
string tilename = tile.GetComponent<Tile>().getTileType();
|
||||
if (keyword == "Forest" && tilename.ToLower().Contains("forest"))
|
||||
{
|
||||
current++;
|
||||
}
|
||||
if (keyword == "Plane" && tilename.ToLower().Contains("plane"))
|
||||
{
|
||||
current++;
|
||||
}
|
||||
if (keyword == "Mountain" && tilename.ToLower().Contains("mountain"))
|
||||
{
|
||||
current++;
|
||||
}
|
||||
if (keyword == "River" && tilename.ToLower().Contains("river"))
|
||||
{
|
||||
current++;
|
||||
}
|
||||
if (keyword == "Lake" && tilename.ToLower().Contains("lake"))
|
||||
{
|
||||
current++;
|
||||
}
|
||||
if (keyword == "City" && tilename.ToLower().Contains("city"))
|
||||
{
|
||||
current++;
|
||||
}
|
||||
if (current >= goal)
|
||||
{
|
||||
isFinished = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Quests/FindQuest.cs.meta
Normal file
11
Assets/Scripts/Quests/FindQuest.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b0e62c53b5e7b84f991f4d464fe3c6e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
56
Assets/Scripts/Quests/KillQuest.cs
Normal file
56
Assets/Scripts/Quests/KillQuest.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts
|
||||
{
|
||||
public class KillQuest : Quest
|
||||
{
|
||||
public KillQuest(GameObject display) : base(display)
|
||||
{
|
||||
current = 0;
|
||||
goal = getRandomNumber(20) + 1;
|
||||
questname = "Kill " + goal + " ";
|
||||
int index = getRandomNumber(3);
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
questname = questname + "slimes";
|
||||
keyword = "slime";
|
||||
break;
|
||||
case 1:
|
||||
questname = questname + "boss slimes";
|
||||
keyword = "boss";
|
||||
break;
|
||||
case 2:
|
||||
questname = questname + "mini boss slimes";
|
||||
keyword = "miniboss";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
override
|
||||
public void update(object obj, int amount)
|
||||
{
|
||||
GameObject enemy = (GameObject)obj;
|
||||
string enemyname = enemy.GetComponent<Enemy>().getEnemyName();
|
||||
if (keyword == "miniboss" && enemyname.ToLower().Contains("miniboss"))
|
||||
{
|
||||
current++;
|
||||
}
|
||||
if (keyword == "boss" && enemyname.ToLower().Contains("boss"))
|
||||
{
|
||||
current++;
|
||||
}
|
||||
if (keyword == "slime")
|
||||
{
|
||||
current++;
|
||||
}
|
||||
if (current >= goal)
|
||||
{
|
||||
isFinished = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Scripts/Quests/KillQuest.cs.meta
Normal file
11
Assets/Scripts/Quests/KillQuest.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab96793c0acfd754390101cc53d060bb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
52
Assets/Scripts/Quests/Quest.cs
Normal file
52
Assets/Scripts/Quests/Quest.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts
|
||||
{
|
||||
public class Quest
|
||||
{
|
||||
protected string questname;
|
||||
protected string keyword;
|
||||
protected int current;
|
||||
protected int goal;
|
||||
protected bool isFinished = false;
|
||||
protected Vector3 coordinates;
|
||||
protected GameObject display;
|
||||
|
||||
public Quest(GameObject display)
|
||||
{
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
public virtual void update(object obj, int amount)
|
||||
{
|
||||
//empty
|
||||
}
|
||||
|
||||
public void show(float positionY)
|
||||
{
|
||||
display.transform.Find("txtName").GetComponent<Text>().text = questname;
|
||||
display.transform.Find("txtAmount").GetComponent<Text>().text = current + "/" + goal;
|
||||
if (isFinished)
|
||||
{
|
||||
display.transform.Find("imgDone").GetComponent<RawImage>().color = new Color(255,255,255,255);
|
||||
}
|
||||
float x = display.transform.localPosition.x;
|
||||
float z = display.transform.localPosition.z;
|
||||
display.transform.localPosition = new Vector3(x, positionY, z);
|
||||
}
|
||||
|
||||
public int getRandomNumber(int max)
|
||||
{
|
||||
int result = 0;
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
result = Random.Range(0,max);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/Quests/Quest.cs.meta
Normal file
11
Assets/Scripts/Quests/Quest.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93eb495c6c5d698468ca9b047933ed31
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user