Vector2 getInput(float horizontal, float vertical) { //calculating direction vector Vector3 direction = new Vector3(horizontal, 0.0f, vertical); //create rotated transform that is locked to avoid up/down camera angle affecting direction magnitude Quaternion cameraRotation = cam.transform.rotation; cam.transform.Rotate(Vector3.left, cam.transform.localRotation.eulerAngles.x); direction = cam.transform.TransformDirection(direction); direction.y = 0.0f; //revert camera's rotation cam.transform.rotation = cameraRotation; //limit input magnitude (to avoid high-magnitude input when moving diagonally) direction = Vector3.Normalize(direction); //ease direction for smoother movement (dampen direction change if in air) float changer = directionChangeSpeed; if (jumping) { changer *= airDampening; } targetDirection.x = Nox.ease(targetDirection.x, direction.x, changer); targetDirection.y = Nox.ease(targetDirection.y, direction.z, changer); //amplify normalized vector to desired speed return(new Vector2(targetDirection.x, targetDirection.y) * targetSpeed); }
void handleInput() { //get input float mouseX = Input.GetAxis("Mouse X"); float mouseY = -Input.GetAxis("Mouse Y"); if (!ready) { mouseX = 0; mouseY = 0; } //rotation manipulation rotY += mouseX * mouseSensitivity * Time.deltaTime; rotX += mouseY * mouseSensitivity * Time.deltaTime; rotX = Mathf.Clamp(rotX, -clampAngle, clampAngle); //ease rotation currentX = Nox.ease(currentX, rotX, easeSpeed); currentY = Nox.ease(currentY, rotY, easeSpeed); //apply rotation Quaternion localRotation = Quaternion.Euler(currentX, currentY, 0.0f); transform.rotation = localRotation; }
void Update() { if (Nox.player.GetComponent <PlayerMove>().flying&& Input.GetMouseButton(0)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, Mathf.Infinity, mask)) { targetPoint = hit.point; } soundSystem.addEnergy(1f); } if (Mathf.Abs(targetPoint.x - flyPoint.transform.position.x) > 1f && Mathf.Abs(targetPoint.z - flyPoint.transform.position.z) > 1f) { float newX = Nox.ease(flyPoint.transform.position.x, targetPoint.x, 1f); float newY = Nox.ease(flyPoint.transform.position.y, targetPoint.y, 1f); float newZ = Nox.ease(flyPoint.transform.position.z, targetPoint.z, 1f); flyPoint.transform.position = new Vector3(newX, newY, newZ); } //audio if (Nox.player.GetComponent <PlayerMove>().flying&& Input.GetMouseButtonDown(0)) { soundSystem.dynamicToggle("pads", true); } if (Nox.player.GetComponent <PlayerMove>().flying&& Input.GetMouseButtonUp(0)) { soundSystem.dynamicToggle("pads", false); } }
void shake() { //increment perlin 'cursor' perlinX += shakeSpeed * Time.deltaTime; perlinY += shakeSpeed * Time.deltaTime; perlinZ += shakeSpeed * Time.deltaTime; //remap to -1 to 1 and amplify according to shake quantity float x = Nox.remap(Mathf.PerlinNoise(perlinX, 0), 0f, 1f, -1f, 1f) * shakeQuantity; float y = Nox.remap(Mathf.PerlinNoise(perlinY, 0), 0f, 1f, -1f, 1f) * shakeQuantity; float z = Nox.remap(Mathf.PerlinNoise(perlinZ, 0), 0f, 1f, -1f, 1f) * shakeQuantity; //use player speed as subtraction to shake speed modifier //the faster the player moves, the less camera shake there is playerSpeed = player.GetComponent <PlayerMove>().getSpeed(); float shakeSpeedModifier = 1f - (playerSpeed * 0.005f); if (shakeSpeedModifier < 0) { shakeSpeedModifier = 0; } //apply perlin noise as rotation transform.localEulerAngles = new Vector3(transform.localEulerAngles.x + (x * shakeSpeedModifier), transform.localEulerAngles.y + (y * shakeSpeedModifier), transform.localEulerAngles.z + (z * shakeSpeedModifier)); }
void Update() { if (Input.GetMouseButtonDown(1)) { if (letterBox != null) { StopCoroutine(letterBox); } letterBox = StartCoroutine(changeAspectRatio(aspectRatio)); } if (Input.GetMouseButtonUp(1)) { if (letterBox != null) { StopCoroutine(letterBox); } letterBox = StartCoroutine(changeAspectRatio(cam.aspect)); } //override when flying if (Nox.player.GetComponent <PlayerMove>().flying) { if (letterBox != null) { StopCoroutine(letterBox); } if (currentAspect != cam.aspect) { currentAspect = Nox.ease(currentAspect, cam.aspect, aspecRatioChangeSpeed / 4f); } forceAspectRatio(currentAspect); } }
void follow() { float x = Nox.ease(transform.position.x, player.transform.position.x, followSpeed); float y = Nox.ease(transform.position.y, player.transform.position.y + 0.5f, followSpeed); float z = Nox.ease(transform.position.z, player.transform.position.z, followSpeed); transform.position = new Vector3(x, y, z); }
private void findAndTouch(Nox n, Image <Bgr, byte> b) { Tuple <int, int> result = findImage(n, b); if (result != null) { touch(result, n.device); } }
void setFOV() { if (GameObject.Find("Camera").GetComponent <SunClick>().transitioning == null) { if (!flying) { targetFOV = Nox.ease(targetFOV, Nox.remap(targetSpeed, walkSpeed, sprintSpeed, defaultFOV, fastFOV), FOVease); } camComponent.fieldOfView = targetFOV; } }
void follow() { Vector3 targetPosition = Camera.main.transform.position + (Camera.main.transform.forward * targetDistance); Vector3 newPosition = transform.position; newPosition.x = Nox.ease(newPosition.x, targetPosition.x, followSpeed); newPosition.y = Nox.ease(newPosition.y, targetPosition.y, followSpeed); newPosition.z = Nox.ease(newPosition.z, targetPosition.z, followSpeed); transform.position = newPosition; transform.rotation = Camera.main.transform.rotation; }
IEnumerator Fade(float target) { yield return(new WaitForSeconds(fadeDelay)); while (Mathf.Abs(opacity - target) > 0.01f) { yield return(new WaitForSeconds(0.01f)); opacity = Nox.ease(opacity, target, fadeSpeed); } opacity = target; }
void FixedUpdate() { Vector3 targetPosition = Camera.main.transform.position + (Camera.main.transform.forward * distanceFromCamera); Vector3 newPosition = transform.position; newPosition.x = Nox.ease(newPosition.x, targetPosition.x, followSpeed); newPosition.y = Nox.ease(newPosition.y, targetPosition.y, followSpeed); newPosition.z = Nox.ease(newPosition.z, targetPosition.z, followSpeed); velocity = Vector3.Distance(transform.position, newPosition); rb.MovePosition(newPosition); }
IEnumerator FadeBackground(float target) { while (Mathf.Abs(backgroundOpacity - target) > 0.02f) { yield return(new WaitForSeconds(0.01f)); backgroundOpacity = Nox.ease(backgroundOpacity, target, 0.1f); storyBackground.GetComponent <CanvasGroup>().alpha = backgroundOpacity; } backgroundOpacity = target; storyBackground.GetComponent <CanvasGroup>().alpha = backgroundOpacity; }
IEnumerator FadeSky(float target) { while (Mathf.Abs(skyOpacity - target) > 0.02f) { yield return(new WaitForSeconds(0.01f)); skyOpacity = Nox.ease(skyOpacity, target, 0.05f); sky.multiplier.value = skyOpacity; } skyOpacity = target; sky.multiplier.value = skyOpacity; }
IEnumerator Glow() { float alpha = maxAlpha; light.SetFloat("_Alpha", alpha); while (alpha > minAlpha) { yield return(new WaitForSeconds(0.01f)); alpha = Nox.ease(alpha, minAlpha, 2f); light.SetFloat("_Alpha", alpha); } }
IEnumerator SwitchWorlds() { negative = !negative; float cut; mix.GetFloat("LP_Freq", out cut); FOV = camComponent.fieldOfView; while (FOV > 10f) { yield return(new WaitForSeconds(0.01f)); FOV = Nox.ease(FOV, 9.9f, 10f); cut = Nox.ease(cut, 3000f, 0.1f); mix.SetFloat("LP_Freq", cut); camComponent.fieldOfView = FOV; } //filter cutoff if (negative) { mix.SetFloat("LP_Freq", 1500f); } else { mix.SetFloat("LP_Freq", 22000f); } //post-processing effects if (negative) { pp.SetActive(true); } else { pp.SetActive(false); } while (FOV < 65f) { yield return(new WaitForSeconds(0.01f)); FOV = Nox.ease(FOV, 66f, 5f); camComponent.fieldOfView = FOV; } routineEnded = true; }
private void LoadScripts(Nox nox) { if (nox.Actions.Count > 0) { if (nox.Configs.Count == 0) { var xmlPath = GetXmlPath(nox.Actions.FirstOrDefault()); //nox.Actions = new List<Action>() { (Action)lsvAction.CheckedItems[0] }; nox.Configs = ImportScript(xmlPath); } DisplayListView(nox.Configs); } }
public Tuple <int, int> findImage(Nox nox, Image <Bgr, byte> small) { //Take screenshot of that device. Rectangle rect = nox.rectNox; Bitmap bmp = new Bitmap(rect.Width, rect.Height); Graphics g = Graphics.FromImage(bmp); g.CopyFromScreen(rect.Left, rect.Top, 0, 0, bmp.Size, CopyPixelOperation.SourceCopy); bmp.Save(nox.name + ".png", ImageFormat.Png); Image <Bgr, byte> source = new Image <Bgr, byte>(bmp); // Screen cap Image <Bgr, byte> imageToShow = source.Copy(); using (Image <Gray, float> result = source.MatchTemplate(small, Emgu.CV.CvEnum.TemplateMatchingType.CcoeffNormed)) { double[] minValues, maxValues; Point[] minLocations, maxLocations; List <Rectangle> rectangles = new List <Rectangle>(); result.MinMax(out minValues, out maxValues, out minLocations, out maxLocations); // You can try different values of the threshold. I guess somewhere between 0.75 and 0.95 would be good. if (maxValues[0] > 0.9) { // This is a match. Do something with it, for example draw a rectangle around it. Rectangle match = new Rectangle(maxLocations[0], small.Size); imageToShow.Draw(match, new Bgr(Color.Red), 3); if (nox.name.Equals("lead")) { setImage1(imageToShow); } else { setImage2(imageToShow); } //Normalized coordinates int X = maxLocations[0].X * DEVICE_WIDTH / nox.rectNox.Width; int Y = maxLocations[0].Y * DEVICE_HEIGHT / nox.rectNox.Height; return(new Tuple <int, int>(X, Y)); } else { return(null); } // Show imageToShow in an ImageBox (here assumed to be called imageBox1) } }
IEnumerator changeAspectRatio(float desiredRatio) { while (currentAspect != desiredRatio) { yield return(new WaitForSeconds(0.01f)); if (Mathf.Abs(currentAspect - desiredRatio) < 0.01f) { currentAspect = desiredRatio; } else { currentAspect = Nox.ease(currentAspect, desiredRatio, aspecRatioChangeSpeed); forceAspectRatio(currentAspect); } } }
void handleSound() { if (flying && sprinting) { soundSystem.addEnergy(2.4f); } else if (flying && !sprinting) { soundSystem.addEnergy(1.8f); } else if (sprinting) { soundSystem.addEnergy(1.4f); } else if (getSpeed() > 1f) { soundSystem.addEnergy(0.4f); } //need listener specifically for a single event //repeated calls to dynamicToggle result in loss of functionality if (Input.GetKeyDown(KeyCode.LeftShift)) { soundSystem.dynamicToggle("percussion", true); } if (Input.GetKeyUp(KeyCode.LeftShift)) { soundSystem.dynamicToggle("percussion", false); } if (jumping) { float cut; mix.GetFloat("Frequency_Cutoff", out cut); mix.SetFloat("Frequency_Cutoff", Nox.ease(cut, 1100f, 1f)); } else { float cut; mix.GetFloat("Frequency_Cutoff", out cut); mix.SetFloat("Frequency_Cutoff", Nox.ease(cut, 10f, 5f)); } }
private void MainBotForm_Load(object sender, EventArgs e) { DebugPictureBox = DebugImageBox; BotLogTextbox = BotLog; SelectedEmuInstance = EmulatorInstComboBox; Adb = new ADB(); Clicks = new Clicks(); ImageSearch = new ImageSearchClass(); CaptureImage = new CaptureImage(); Nox = new Nox(); foreach (var item in Nox.ListNoxInstances()) { Log(item); SelectedEmuInstance.Items.Add(item); SelectedEmuInstance.SelectedIndex = 0; } }
void Update() { //modes switch (triggerLayer) { case "flight": if (Nox.player.GetComponent <PlayerMove>().flying) { if (fader != null) { StopCoroutine(fader); } if (opacity != targetOpacity) { opacity = Nox.ease(opacity, targetOpacity, (fadeSpeed / 2f) * fadeDelay); } } else { if (fader != null) { StopCoroutine(fader); } if (opacity != 0f) { opacity = Nox.ease(opacity, 0f, fadeSpeed / 2f); } } break; case "control": if (Input.GetMouseButtonDown(1)) { if (fader != null) { StopCoroutine(fader); } fader = StartCoroutine(Fade(targetOpacity)); } if (Input.GetMouseButtonUp(1)) { if (fader != null) { StopCoroutine(fader); } fader = StartCoroutine(Fade(0f)); } if (Input.GetMouseButtonDown(2)) { if (fader != null) { StopCoroutine(fader); } fader = StartCoroutine(Fade(0f)); } if (Nox.player.GetComponent <PlayerMove>().flying) { if (fader != null) { StopCoroutine(fader); } if (opacity != 0f) { opacity = Nox.ease(opacity, 0f, fadeSpeed / 2f); } } break; case "movement": if (Input.GetMouseButtonDown(2)) { if (fader != null) { StopCoroutine(fader); } fader = StartCoroutine(Fade(targetOpacity)); } if (Input.GetMouseButtonUp(2)) { if (fader != null) { StopCoroutine(fader); } fader = StartCoroutine(Fade(0f)); } if (Input.GetMouseButtonDown(1)) { if (fader != null) { StopCoroutine(fader); } fader = StartCoroutine(Fade(0f)); } if (Nox.player.GetComponent <PlayerMove>().flying) { if (fader != null) { StopCoroutine(fader); } if (opacity != 0f) { opacity = Nox.ease(opacity, 0f, fadeSpeed / 2f); } } break; } GetComponent <CanvasGroup>().alpha = opacity; }
public void setStage(int stage, Nox n) { n.setCurrentStage(stage); }
public Boolean isInStage(int stage, Nox n) { return(n.getCurrentStage() == stage); }
void move() { //get input float horizontal = 0f; float vertical = 0f; if (Mathf.Abs(Input.GetAxis("Horizontal")) > 0.1f) { horizontal = Input.GetAxis("Horizontal"); } if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.1f) { vertical = Input.GetAxis("Vertical"); } Vector2 direction = getInput(horizontal, vertical); Vector3 newLoc = new Vector3(gameObject.transform.position.x + direction.x, gameObject.transform.position.y, gameObject.transform.position.z + direction.y); //glue to ground, or add gravity for jump if (!flying) { if (!jumping) { newLoc = groundPlayer(newLoc); } else { rb.AddForce(new Vector3(0, -gravity, 0)); } } else { //fly rb.velocity = new Vector3(0, 0, 0); targetFOV = Nox.ease(targetFOV, flyingFOV, FOVease); if (transform.position.y < flyHeight - 0.001f) { newLoc = new Vector3(newLoc.x, Nox.ease(transform.position.y, flyHeight, flyEase), newLoc.z); } else { newLoc = new Vector3(newLoc.x, flyHeight, newLoc.z); } } //apply movement rb.MovePosition(newLoc); //jump if (Input.GetKeyDown(KeyCode.Space) && isGrounded(groundedHeight) && !jumping && !flying) { jumping = true; rb.AddForce(Vector3.up * (jumpSpeed)); StartCoroutine(jumpDelay()); } sprinting = false; //no movement - stop all forces (excluding vertical force for jumping) if (horizontal == 0f && vertical == 0f && isGrounded(groundedHeight)) { targetSpeed = Nox.ease(targetSpeed, 0f, speedChangeStop); rb.velocity = new Vector3(0, rb.velocity.y, 0); //sprint } else if (Input.GetKey(KeyCode.LeftShift)) { sprinting = true; targetSpeed = Nox.ease(targetSpeed, sprintSpeed, speedChangeSprint); //walk } else { targetSpeed = Nox.ease(targetSpeed, walkSpeed, speedChangeWalk); } }
private Boolean isImageFound(Nox n, Image <Bgr, byte> b) { Tuple <int, int> result = findImage(n, b); return(result != null); }
void Start() { s = GameObject.Find("Nox").GetComponent <Story>(); n = GameObject.Find("Nox").GetComponent <Nox>(); soundSystem = GameObject.Find("Nox").GetComponent <Sound>(); }
void Start() { storyText = GameObject.Find("Story - Text/Text").GetComponent <Text>(); storyTextCanvas = GameObject.Find("Story - Text"); storyBackground = GameObject.Find("Story - Background"); soundSystem = GetComponent <Sound>(); n = GetComponent <Nox>(); pp = GameObject.Find("Rendering").GetComponent <Volume>(); HDRISky temp; if (pp.profile.TryGet <HDRISky>(out temp)) { sky = temp; } sun.SetActive(false); gates.SetActive(true); sky.multiplier.value = 0f; talk = new string[20]; //intro talk[0] = "We have a stable port to Qurotema. RO, your vision should come in soon."; talk[1] = "We should remind you that because of the Gates, this is only a one-way communication channel."; talk[2] = "Beyond this point is only the unknown. We will keep watch, and study Qurotema alongside you, Operator."; talk[3] = "Your vessel should be equipped with a control module through which you can interact with the world.\nHow it functions is beyond our understanding, but we trust you will discover its abilities in time."; talk[4] = "Good luck with your research, RO. Make Sino proud."; //first monolith discovery talk[5] = "What you see in front of you is one of the Monoliths Dr. Sino spoke about. There should be a writing 'eminating' from it. Do you see anything?"; //first monolith interaction talk[6] = "We have a feed of the characters. Sino called this script 'i-tema'. He claims there's no way to speak it, as it is a written-only language."; talk[7] = "This set of symbols in particular were already translated by Sino. They say: 'The night will flow when black time's sand knows foreign touch.'"; talk[8] = "Nothing else was translated other than the writing on the gates, 'Quro' and 'Tema'."; talk[9] = "We are not sure how Sino felt so confident in his understanding of i-tema, but finding more Monoliths will help us fill a database for linguistic analysis."; //first instrument discovery talk[10] = "What is that? Nothing like that was documented in Sino's notes. It's not coming in clear."; //instrument playtime story progress talk[11] = "We have signals of faint acitivity away from your vessel's current position."; talk[12] = "We've lost sight of your feed, but we are still getting readings about your position. Keep up the research."; talk[13] = "Our connection is becoming unreliable. We are going to pull you out soon."; //ending talk[14] = "We are losing connection fast. Abandoning vessel."; talk[15] = "RO? Di? Your body in the lab is unresponsive. Initiate return protocol immediately so we can resuscitate."; talk[16] = "Di, I don't know what's going on but we have no connection to Qurotema, can't even find it with Sino's systems."; talk[17] = "It's possible that Qurotema is gone, and your vessel is in the Void."; talk[18] = "I'm going to be honest. I don't know what we're going to do."; talk[19] = ""; if (!introductionFinished) { backgroundOpacity = 1f; storyBackground.GetComponent <CanvasGroup>().alpha = backgroundOpacity; talkTracker = 0; if (routine != null) { StopCoroutine(routine); } routine = StartCoroutine(PlayText(talkTracker)); } else { //skip intro sun.SetActive(true); gates.SetActive(false); sky.multiplier.value = 1f; } }
void setDistance() { targetDistance = Nox.remap(playerScript.targetFOV, playerScript.defaultFOV, playerScript.fastFOV, distanceFromCamera, minDistanceFromCamera); }