void Awake() { agent = GetComponent <NavMeshAgent>(); nextPoint = ClosestPoint(); towerhp = waypoints[nextPoint].GetComponent <ArtScenestats>(); //unitStats = gameObject.GetComponent<UnitStats>(); // unitStats from different script //agent.stoppingDistance = 0; //dust.GetComponent<ParticleSystem>().enableEmission = false; //hit.GetComponent<ParticleSystem>().enableEmission = false; }
void Update() { if (currentState == ArtState.Move) { //dust.GetComponent<ParticleSystem>().enableEmission = true; if (CloseEnoughToWaypoint()) { //dust.GetComponent<ParticleSystem>().enableEmission = false; agent.velocity = Vector3.zero; //agent.transform.position = waypoints[nextPoint].position; if (towerhp.towerMaxHP <= 0) { // we have decided that last tower is element 2. Not the best way, could be good to redo this at some point nextPoint = 2; if (nextPoint > waypoints.Count - 1) { nextPoint = 0; } towerhp = waypoints[nextPoint].GetComponent <ArtScenestats>(); } curTime += Time.deltaTime; if (curTime >= hitTime && towerhp.towerMaxHP > 0) { towerhp.towerMaxHP -= attackPower; // hit.GetComponent<ParticleSystem>().enableEmission = true; curTime = curTime - hitTime; } } ContinuePatrol(); } if (currentState == ArtState.Attack) { //attack(); // minion stops // starts attacking and changes animation to attack animation // if waypoint "castle" is destroyed, starts to move towards next closest castle } }