// Start is called before the first frame update void Awake() { checkMatch = gameObject.GetComponent <CheckMatch>(); if (handedness == Chirality.Left) { loadData = new LoadData("LeftHand.json"); if (PlayerPrefs.GetString("LeftHand.json") != "") { dataTransform = loadData.Load(); } } else { loadData = new LoadData("RightHand.json"); if (PlayerPrefs.GetString("RightHand.json") != "") { dataTransform = loadData.Load(); } } if (dataTransform != null) { getedPosition = dataTransform._handPosition; getedRotation = dataTransform._handRotation; } }
public void NewNode(Vector3 pos) { GameObject g = Instantiate(nodePrefabs[weightedRandom()], nodeParent); pos.x = (int)pos.x; pos.y = (int)pos.y; pos.z = (int)pos.z; g.transform.position = pos; allObjects.Add(g); CheckMatch.CheckAdjacentNodes(g); }
public IPlugin GetMatchingScript(CheckMatch check) { Dictionary <string, IPlugin> plugins; if (DomainMgr == null) { plugins = mActivePlugins; } else { plugins = DomainMgr.PluginMgr.GetActivePlugins(); } foreach (IPlugin plugin in plugins.Values) { if (check(plugin)) { return(plugin); } } return(null); }
void Awake() { InitCube(); instance = this; CheckMatch.CheckAllNodes(); }
// Update is called once per frame void Update() { if (rotTimeLeft > 0) { foreach (GameObject go in filteredObjects) { go.transform.position = rot * go.transform.position; } rotTimeLeft--; } else if (rotTimeLeft == 0 && !isChecked) { CheckMatch.CheckAllNodes(); isChecked = true; } else if (CheckMatch.nodesToBeDeleted.Count == 0 && movesLeft > 0) { if (Input.GetKeyDown(KeyCode.Mouse0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100)) { Vector3 pos = hit.transform.position; hitPos = hit.point; x = Mathf.RoundToInt(pos.x); y = Mathf.RoundToInt(pos.y); z = Mathf.RoundToInt(pos.z); mousePos = Input.mousePosition; } else { x = 0; y = 0; z = 0; } } if (Input.GetKeyUp(KeyCode.Mouse0)) { Vector2 newMousePos = Input.mousePosition; if (Vector2.Distance(newMousePos, mousePos) > 32) { if (x != 0 || y != 0 || z != 0) { Vector3 dragDir = Camera.main.transform.TransformDirection(newMousePos - mousePos); Vector3 hitDir = getGeneralDirection(hitPos); Vector3 axis = Vector3.Cross(dragDir, hitDir); axis = getGeneralDirection(axis); Rotate(x, y, z, axis); filteredObjects.Clear(); float E = 0.1f; foreach (GameObject go in MainController.allObjects) { if (axis.x != 0 && Mathf.Abs(go.transform.position.x - x) < E) { filteredObjects.Add(go); } else if (axis.y != 0 && Mathf.Abs(go.transform.position.y - y) < E) { filteredObjects.Add(go); } else if (axis.z != 0 && Mathf.Abs(go.transform.position.z - z) < E) { filteredObjects.Add(go); } } x = 0; y = 0; z = 0; } } } } if (CheckMatch.nodesToBeDeleted.Count == 0 && movesLeft == 0) { endGame.End(false); } }