void OnTriggerEnter(Collider collision) { if(collision.gameObject.tag != "undefined") { Debug.Log ("Currently touching : " + collision.gameObject.tag); } if(collision.gameObject.tag == "testing") { collision.gameObject.tag = "checked"; } if (currentQ == questType.Quest1 && collision.gameObject.tag == "data") { currentQ = questType.Quest2; Destroy (collision.gameObject); Debug.Log ("CurrentQuest : quest2 entered"); } else if (currentQ == questType.Quest2 && collision.gameObject.tag == "comp") { currentQ = questType.Quest3; GameObject newData = Instantiate (_dataPrefab) as GameObject; newData.transform.position = collision.transform.position + Vector3.right; Debug.Log ("CurrentQuest : quest3 entered"); } else if (currentQ == questType.Quest3 && collision.gameObject.tag == "bomb") { currentQ = questType.Quest4; _hasBomb = true; Destroy (collision.gameObject); } else if (currentQ == questType.Quest4 && collision.gameObject.tag == "mark" && _hasBomb) { GameObject newBomb = Instantiate (_bombPrefab) as GameObject; Vector3 _pos = collision.gameObject.transform.position; newBomb.transform.position = collision.transform.position; collision.gameObject.tag = "marked"; } }
void TakeDamage(float damage) { health -= damage; if(health <=0 ) { currentQ = questType.GameOver; } }
private static string genQuestTitle() { Array types = Enum.GetValues(typeof(questType)); questType type = (questType)types.GetValue(rnd.Next(types.Length)); switch (type) { case questType.defend: return($"Defend{defendWhat[rnd.Next(defendWhat.Count)]}{defendFrom[rnd.Next(defendFrom.Count)]}"); case questType.rescue: return($"Rescue{defendWhat[rnd.Next(defendWhat.Count)]}{defendFrom[rnd.Next(defendFrom.Count)]}"); case questType.explore: return($"Explore{exploreSeverity[rnd.Next(exploreSeverity.Count)]}{exploreLocation[rnd.Next(exploreLocation.Count)]}"); default: return("rescue nothing from nothing"); } }
// Update is called once per frame void Update() { _marked = GameObject.FindGameObjectsWithTag("mark"); if (_marked.Length == 0 && _posted) { currentQ = questType.Finish; Debug.Log ("CurrentQuest : finished"); _posted = false; } if(currentQ == questType.GameOver) { // Destroy(this.gameObject); } }
// Use this for initialization void Start() { currentQ = questType.Quest1; _hasBomb = false; _posted = true; }