public override TaskStatus OnUpdate() { IA_AutoShootSystem aiShoot = targetGameobject.GetComponent <IA_AutoShootSystem>(); aiShoot.gameObject.GetComponent <NavMeshAgent>().isStopped = false; Vector3 ammoPoint; if (aiShoot.target != null) { ammoPoint = IA_GameManager.GetClosestElement(aiShoot.gameObject.transform.position, AI_AmmoSpawner.instance.GetSpawnedPositions(), aiShoot.target.GetComponent <IA_AutoShootSystem>()); } else { ammoPoint = AI_AmmoSpawner.instance.GetSpawnedPositions()[0]; } aiShoot.target = null; if (targetGameobject.GetComponent <Patrol_Movement>() != null) { targetGameobject.GetComponent <Patrol_Movement>().SetDestination(ammoPoint); } else { targetGameobject.GetComponent <IA_Wander_Movement>().SetDestination(ammoPoint); } aiShoot.currentState = TankState.PICKING_AMMO; Debug.Log("Moving to new ammo box"); return(TaskStatus.COMPLETED); }
private void Awake() { if (instance != null) { Debug.LogError("More than one game manager in the scene"); } instance = this; Time.timeScale = 1f; }