// Update is called once per frame void Update() { if (mouseHold && Input.GetMouseButtonUp(0)) { mouseHold = false; var minDst = float.MaxValue; var minAlign = DragObject.transform.position; var idx = 0; for (var i = 0; i < AlignPosition.Length; i++) { var align = AlignPosition[i]; var dst = (DragObject.transform.position - align).magnitude; if (dst < minDst) { idx = i; minDst = dst; minAlign = align; } } MoveTo.MoveOptions options = new MoveTo.MoveOptions(DragObject, minAlign, AlignTime); options.OnFinished += (sender, e) => { var callback = DragObject.GetComponent <WaypointCallback>(); if (callback != null) { callback.ConnectCallback(idx); } }; MoveTo.Start(options); } if (mouseHold) { var ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; var dv = new Vector3(); if (Physics.Raycast(ray, out hit, 500, 1 << 8)) { dv.y = hit.point.y - holdPos.y; print(hit.point); dv.y *= DragVector.y; } if (Physics.Raycast(ray, out hit, 500, 1 << 9)) { dv.x = hit.point.x - holdPos.x; dv.x *= DragVector.x; } if (Physics.Raycast(ray, out hit, 500, 1 << 10)) { dv.z = hit.point.z - holdPos.z; dv.z *= DragVector.z; } DragObject.transform.position = startPos + dv; var callback = DragObject.GetComponent <WaypointCallback>(); if (callback != null) { callback.DisConnectCallback(0); } } }
// Use this for initialization void Start() { var options = new MoveTo.MoveOptions(gameObject, transform.position + new Vector3(0, -10, 0), 20); options.OnFinished += (sender, e) => { GameObject.Find("GameSystem").GetComponent <GameSystem>().EndGame(); }; MoveTo.Start(options); }
// Use this for initialization void Start() { var options = new MoveTo.MoveOptions(Player, StartPosition.transform.position, 1); options.OnFinished += (sender, e) => { Player.GetComponent <Player>().enabled = true; SpawnBlock.transform.position = MoveSpawnTo; }; MoveTo.Start(options); }
// Use this for initialization void Start() { var player = GameObject.Find("Player"); var options = new MoveTo.MoveOptions(player, StartPosition.transform.position, 1); options.OnFinished += (sender, e) => { player.GetComponent <Player>().enabled = true; var spawn = GameObject.Find("Spawn"); MoveTo.Start(new MoveTo.MoveOptions(spawn, new Vector3(0, -100, 0), 100)); }; MoveTo.Start(options); }
public override void GameEndingCallback() { var player = Player.GetComponent <Player>(); player.Docking = true; player.dockedDepth = 0; var body = Player.transform.Find("Body").gameObject; var options = new MoveTo.MoveOptions(body, body.transform.position - new Vector3(0, player.DockDepth, 0), player.DockTime); options.OnFinished += (sender, e) => { player.Docking = false; EndGame(); }; MoveTo.Start(options); }
public override void GameEndingCallback() { var player = Player.GetComponent <Player>(); player.Docking = true; player.dockedDepth = 0; var body = Player.transform.Find("Body").gameObject; var options = new MoveTo.MoveOptions(body, body.transform.position - new Vector3(0, player.DockDepth, 0), player.DockTime); options.OnFinished += (sender, e) => { player.Docking = false; GameObject.Find("Main Camera").GetComponent <ShakeCamera>().Enable = true; GameObject.Find("Map-End").GetComponent <EndScript>().enabled = true; GameObject.Find("Map-End").transform.Find("Blocks-Drop").gameObject.SetActive(true); }; MoveTo.Start(options); }
public override void GameEndingCallback() { var player = Player.GetComponent <Player>(); player.Docking = true; player.dockedDepth = 0; var body = Player.transform.Find("Body").gameObject; var options = new MoveTo.MoveOptions(body, body.transform.position - new Vector3(0, player.DockDepth, 0), player.DockTime); options.OnFinished += (sender, e) => { //EndGame(); GameObject.Find("Tower").GetComponent <Map3_1TowerRotation>().enabled = true; GameObject.Find("Other").GetComponent <Map3_1Rotation>().enabled = true; player.Docking = false; var endPad = GameObject.Find("EndPad").transform; var waypointObj = endPad.transform.Find("Waypoint"); var waypoint = waypointObj.GetComponent <Waypoint>(); waypoint.ClearWaypoint(); }; MoveTo.Start(options); }