private IEnumerator Co_Gather(TreeTrunk trunk) { Speaker.Speak(); _isLoadPointSet = false; Animator.SetBool(_dragStateName, true); if (!RobotModel.Programs.Any(_ => _.Template.Type == ProgramType.Gather)) { EndCoProgram(); yield break; } _movable.LinearSpeed = basicSpeed; if (trunk == null || trunk.IsCarring) { EndCoProgram(); yield break; } trunk.IsCarring = true; yield return(null); trunk.Carry(Joint); _trunk = trunk; var ark = WorldObjects.Instance.GetFirstItem <Ark>(); _navAgent.nextPosition = transform.position; _navAgent.ResetPath(); _navAgent.SetDestination(ark.transform.position); yield return(null); ResetTime(); Animator.SetBool(_walkStateName, true); while (!trunk.IsRecycling && _navAgent.pathStatus != NavMeshPathStatus.PathInvalid) { var direction = _navAgent.desiredVelocity.normalized; Steer(new Vector2(direction.x, direction.z), true); _navAgent.velocity = _movable.Velocity; _navAgent.nextPosition = transform.position; ComputeTime(Time.deltaTime, ProgramType.Gather); yield return(null); } EndCoProgram(); }
public void FindDragTarget() { if (burden != null) { burden.Drop(); burden.RecycleAction -= OnBurdenRecycled; burden = null; } else { if (_interactive[0] != null) { var treeTrunk = _interactive[0].GetComponentInParent <TreeTrunk>(); burden = treeTrunk; burden.RecycleAction += OnBurdenRecycled; burden.Carry(Joint); } } Drag = burden != null; }