void Update() { MenuGUI menuState = FindObjectOfType <MenuGUI>(); if (menu == null && menuState.state == MenuGUI.MenuState.Hidden && (Input.GetKeyDown(KeyCode.Escape) || InputSynchronizer.GetFlyStickButtonDown(3))) { menu = RadialMenuSpawner.ins.SpawnMenu(this); // fade music if in menu modus GameObject BackgroundMusic = GameObject.Find("BackgroundMusic"); AudioSource backgroundMusicSource = BackgroundMusic.GetComponent <AudioSource>(); backgroundMusicSource.volume = 0.5f; Debug.Log("Radial Menu created"); } else if (menu != null && (Input.GetKeyDown(KeyCode.Escape) || InputSynchronizer.GetFlyStickButtonDown(3))) { // music back to full volume GameObject BackgroundMusic = GameObject.Find("BackgroundMusic"); AudioSource backgroundMusicSource = BackgroundMusic.GetComponent <AudioSource>(); backgroundMusicSource.volume = 1.0f; menu.Trigger(); Destroy(menu.gameObject); menu = null; Debug.Log("Radial Menu destroyed"); } }
// Update is called once per frame void Update() { if (InputSynchronizer.GetKeyUp("flystick 0")) { if (selected) { if (ViewController.logDistance > 0) { inputController.SelectPlanet(transform.parent.gameObject); } else { transform.GetChild(0).gameObject.SetActive(true); descTextMesh.text = ""; transitionTime = 0; } } else { transform.GetChild(0).gameObject.SetActive(false); transitionTime = totalTransitionTime; } } if (transitionTime < totalTransitionTime) { transitionTime = Mathf.Min(totalTransitionTime, transitionTime + TimeSynchronizer.deltaTime); descTextMesh.text = description.Substring(0, (int)(transitionTime / totalTransitionTime * description.Length)); } }
private void Update() { if (enable) { if (InputSynchronizer.GetKeyDown("space")) { float minDistance = float.MaxValue; float distance; foreach (InteractableItem item in objectsHoveringOver) { distance = (item.transform.position - transform.position).sqrMagnitude; if (distance < minDistance) { minDistance = distance; closestItem = item; } } interactingItem = closestItem; closestItem = null; GameObject towerObject = GameObject.Find("DynamicTower"); if (towerObject != null && interactingItem != null) { TowerInteractivity tower = towerObject.GetComponent <TowerInteractivity>(); if (interactingItem.name.Contains(TowerInteractivity.MaxRow.ToString()) && interactingItem.GetComponent <Renderer>().material.color != Color.green) { return; } if (interactingItem.GetComponent <Renderer>().material.color != Color.green) { if (tower.FirstSelected == null) { tower.select(interactingItem.transform.gameObject); } else { return; } } } if (interactingItem) { if (interactingItem.isInteracting()) { interactingItem.EndInteraction(this); } interactingItem.BeginInteraction(this); } } if (InputSynchronizer.GetKeyUp("space") && interactingItem != null) { interactingItem.EndInteraction(this); } } }
void Update() { if (state != MenuState.Hidden) { GameObject flystickSim = GameObject.Find("FlystickSim"); GameObject flystick = GameObject.Find("Flystick"); RaycastHit hit; if (flystickSim && Physics.Raycast(flystickSim.transform.position + flystickSim.transform.up, flystickSim.transform.up, out hit, 10) || flystick && Physics.Raycast(flystick.transform.position, flystick.transform.forward, out hit)) { if (hit.collider.name == "Plane") { return; } GameObject hitObj = hit.collider.gameObject; Button hitButton = hitObj.GetComponent <Button>(); if (selectedButton != null && selectedButton != hitButton) { selectedButton.GetComponent <Image>().color = Color.white; } selectedButton = hitButton; selectedButton.GetComponent <Image>().color = Color.green; } else if (selectedButton != null) { selectedButton.GetComponent <Image>().color = Color.white; selectedButton = null; } if (selectedButton != null && (selectedButton.name == "Btn_2Player" || selectedButton.name == "Btn_3Player" || selectedButton.name == "Btn_4Player")) { nrOfPlayers = selectedButton.gameObject; } if (selectedButton != null && (InputSynchronizer.GetFlyStickButtonDown(0) || Input.GetButtonDown("Submit"))) { selectedButton.onClick.Invoke(); } } }
// Update is called once per frame void Update() { if (initialized) { gameObject.transform.position = flyStick.transform.position; gameObject.transform.rotation = flyStick.transform.rotation; if (InputSynchronizer.GetKeyUp("flystick 1")) { currColor = (currColor + 1) % colors.Length; lasersword.GetComponent <Renderer>().material.SetColor("_Color", colors[currColor]); } if (InputSynchronizer.GetKeyUp("flystick 3")) { currColor = (currColor + colors.Length - 1) % colors.Length; lasersword.GetComponent <Renderer>().material.SetColor("_Color", colors[currColor]); } } }
// Update is called once per frame void Update() { if (this.FlystickSphere == null) { this.FlystickSphere = GameObject.Find("Flystick/FlystickSphere"); Debug.Log(FlystickSphere); } if (this.FlystickSphere != null) { if (Input.GetKey(KeyCode.I) || InputSynchronizer.GetFlyStickButton(2)) { FlystickSphere.SetActive(true); } else { FlystickSphere.SetActive(false); } } }
// Update is called once per frame void Update() { if (ViewController.logDistance == 0 && (InputSynchronizer.GetKeyUp("right") || InputSynchronizer.GetKeyUp("flystick 1")) && planetIndex < planets.Length - 1) { viewController.SelectPlanet(planets[++planetIndex], planets); } if (ViewController.logDistance == 0 && (InputSynchronizer.GetKeyUp("left") || InputSynchronizer.GetKeyUp("flystick 3")) && planetIndex > 0) { viewController.SelectPlanet(planets[--planetIndex], planets); } if (InputSynchronizer.GetKeyUp("down") || InputSynchronizer.GetKeyUp("flystick 2")) { if (ViewController.logDistance > 0) { viewController.ZoomIn(planets[planetIndex], planets); } else { viewController.ZoomOut(planets); } } viewController.ChangeSpeed(InputSynchronizer.GetAxis("flystick horizontal") * TimeSynchronizer.deltaTime * 10 + 1); }
void Update() { Vector3 moveVector = new Vector3(); // up if (InputSynchronizer.GetKey("y")) { moveVector.y += speed; } // down if (InputSynchronizer.GetKey("x")) { moveVector.y -= speed; } // forward if (InputSynchronizer.GetKey("w")) { moveVector.z += speed; } // backward if (InputSynchronizer.GetKey("s")) { moveVector.z -= speed; } // left if (InputSynchronizer.GetKey("a")) { moveVector.x -= speed; } // right if (InputSynchronizer.GetKey("d")) { moveVector.x += speed; } // Rotation Vector3 rotationVector = new Vector3(); if (InputSynchronizer.GetKey("u")) { rotationVector.x += rotationSpeed; } if (InputSynchronizer.GetKey("j")) { rotationVector.x -= rotationSpeed; } if (InputSynchronizer.GetKey("h")) { rotationVector.z += rotationSpeed; } if (InputSynchronizer.GetKey("k")) { rotationVector.z -= rotationSpeed; } if (InputSynchronizer.GetKey("n")) { rotationVector.y += rotationSpeed; } if (InputSynchronizer.GetKey("m")) { rotationVector.y -= rotationSpeed; } gameObject.transform.Translate(moveVector * TimeSynchronizer.deltaTime, Space.World); gameObject.transform.Rotate(rotationVector * TimeSynchronizer.deltaTime, Space.World); }
// Update is called once per frame void Update() { if (flyStickInteraction == null) { initFlyStickEvents(); } if (InputSynchronizer.GetFlyStickButtonDown(0)) { grabBrick(); } if (InputSynchronizer.GetFlyStickButtonUp(0)) { if (interactingItem) { interactingItem.EndInteraction(flyStickInteraction); interactingItem = null; } } if (InputSynchronizer.GetKey("o") || InputSynchronizer.GetFlyStickButtonDown(1)) { if (state == State.BlockCorrectlyPlaced) { state = State.BlockPlacing; deselect(); Player.changeActivePlayer(); Debug.Log("Player " + (Player.ActivePlayer + 1) + " is on the move and has " + Players[Player.ActivePlayer].Score + " Points"); } } if (Input.GetKeyDown(KeyCode.E)) { addRow(); } maxRow = transform.childCount; if (Input.GetMouseButtonDown(0)) { RaycastHit hitInfo = new RaycastHit(); cam = GameObject.Find("Camera").GetComponent <Camera>(); bool hit = Physics.Raycast(cam.ScreenPointToRay(Input.mousePosition), out hitInfo); if (hit) { if (hitInfo.transform.gameObject.tag == "Brick") { rows = hitInfo.transform.parent.parent.childCount; if (hitInfo.transform.gameObject != SelectedObj && hitInfo.transform.parent.name != "Row#" + rows) { select(hitInfo.transform.gameObject); Debug.Log("select"); } else { deselect(); Debug.Log("deselect"); } } } } }