void Start() { _nav = GetComponent <NavMeshAgent>(); m_CurrentState = VeggieState.Hungry; }
void Searching() { Debug.Log(currentVeggie); veggiePoints = GameObject.FindGameObjectsWithTag("Vegetable"); if (currentVeggie == null) { Debug.Log("New Veggie To Chase"); if (veggiePoints == null || veggiePoints.Length == 0) { m_CurrentState = VeggieState.Winner; } else { index = Random.Range(0, veggiePoints.Length); currentVeggie = veggiePoints[index]; } } _moveTo = currentVeggie.transform; //Debug.Log(_moveTo.position); }
void OnTriggerEnter(Collider other) { if (other.tag == "Weapon") { Debug.Log("Kill"); spiritDead = true; Destroy(gameObject); } else if (m_CurrentState == VeggieState.Searching) { if (other.tag == "Vegetable") { other.transform.parent = transform; other.transform.localPosition = Vector3.zero + new Vector3(0, 1f, 0); _moveTo = escapePoint.transform; Debug.Log("escape"); m_CurrentState = VeggieState.Eating; } } else if (m_CurrentState == VeggieState.Eating) { if (other.tag == "Shrine") { foreach (Transform child in transform) { if (child.tag == "Vegetable") { Destroy(child.gameObject); } } currentVeggie = null; targetTime = 2.0f; m_CurrentState = VeggieState.Hungry; } } }
void Hungry() { //distance is close to carrot m_CurrentState = VeggieState.Searching; }