-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c7c71a
commit 695470b
Showing
5 changed files
with
133 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
|
||
public class ArmTask | ||
{ | ||
public enum Type | ||
{ | ||
Finished, | ||
MoveObject | ||
} | ||
public Type type = Type.Finished; | ||
|
||
// moveObject | ||
public Vector3 move_start; | ||
public Vector3 move_end; | ||
|
||
public void InitAsMoveObject(Vector3 start, Vector3 end) | ||
{ | ||
type = Type.MoveObject; | ||
move_start = start; | ||
move_end = end; | ||
} | ||
} | ||
public class TaskManager : MonoBehaviour | ||
{ | ||
public ArmTask task = new ArmTask(); | ||
|
||
public Transform ArmEnd; | ||
public IKController IKSolver; | ||
public RouteGenerator routeGenerator; | ||
|
||
Coroutine taskRoutine; | ||
|
||
GameObject taskSouce; | ||
|
||
public void GetTask(ArmTask t, GameObject sender) | ||
{ | ||
|
||
if (task.type == ArmTask.Type.Finished) | ||
{ | ||
task = t; | ||
taskSouce = sender; | ||
Debug.Log("New " + task.type.ToString() + " task assigned."); | ||
|
||
if (taskRoutine != null) | ||
{ | ||
} | ||
else | ||
{ | ||
taskRoutine = StartCoroutine(ExecuteMoveObject()); | ||
} | ||
} | ||
else | ||
{ | ||
Debug.Log("Current task not finished."); | ||
} | ||
|
||
} | ||
|
||
IEnumerator ExecuteMoveObject() | ||
{ | ||
Debug.Log("Start move object coroutine."); | ||
// generate the action sequence | ||
List<KeyPoint> turningPoint = new List<KeyPoint>(); | ||
turningPoint.Add(new KeyPoint(ArmEnd.position, false)); | ||
turningPoint.Add(new KeyPoint(task.move_start, true)); | ||
turningPoint.Add(new KeyPoint(task.move_end, false)); | ||
routeGenerator.SetRoute(turningPoint); | ||
|
||
|
||
|
||
yield return new WaitForSeconds(3); | ||
taskRoutine = null; | ||
task = new ArmTask(); | ||
try | ||
{ | ||
taskSouce.GetComponent<ObjectFrame>().CancelAim(); | ||
} | ||
catch { } | ||
|
||
Debug.Log("Task Finished"); | ||
yield break; | ||
} | ||
|
||
// Start is called before the first frame update | ||
void Start() | ||
{ | ||
|
||
} | ||
|
||
// Update is called once per frame | ||
void Update() | ||
{ | ||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters