public void SetUp() { // check that the process can create web servers bool isProcessElevated = ElevationChecker.IsProcessElevated(false); Assert.IsTrue(isProcessElevated, "This test needs to run from an elevated IDE or nunit console"); // initialize custom HttpListener subclass to host the local files // https://docs.microsoft.com/en-us/dotnet/api/system.net.httplistener?redirectedfrom=MSDN&view=netframework-4.7.2 String filePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase).Replace("file:\\", ""); // Console.Error.WriteLine(String.Format("Using Webroot path: {0}", filePath)); pageServer = new SimpleHTTPServer(filePath); // implicitly does pageServer.Initialize() and pageServer.Listen(); Common.Port = pageServer.Port; /* * // options.IsMarionette = true; * // There is already an option for the marionette capability. Please use the instead. * // options.AddAdditionalCapability("marionette", true); * // options.IsMarionette = true; * // There is already an option for the marionette capability. Please use the instead. * // options.AddAdditionalCapability("marionette", true); * // DesiredCapabilities capabilities = DesiredCapabilities.Firefox(); * // capabilities.SetCapability("marionette", true); */ // String projectDirectory = System.IO.Directory.GetCurrentDirectory(); //FirefoxOptions options = new FirefoxOptions(); //options.UseLegacyImplementation = true; //System.Environment.SetEnvironmentVariable("webdriver.gecko.driver", String.Format(@"{0}\geckodriver.exe", System.IO.Directory.GetCurrentDirectory())); // driver = new FirefoxDriver(options); // driver = new ChromeDriver(System.IO.Directory.GetCurrentDirectory()); if (headless) { var option = new ChromeOptions(); option.AddArgument("--headless"); driver = new ChromeDriver(option); } else { driver = new ChromeDriver(); } driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(60); // driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(60)); driver.Manage().Window.Size = new System.Drawing.Size(700, 400); Common.NgDriver = ngDriver = new NgWebDriver(driver); driver.Manage().Window.Size = new System.Drawing.Size(window_width, window_heght); wait = new WebDriverWait(driver, TimeSpan.FromSeconds(wait_seconds)); // ngDriver.Navigate().GoToUrl(base_url); // Tests will fail due to page redesign - use the Common.GetLocalHostPageContent("ng_datepicker.htm"); actions = new Actions(driver); }
// Update is called once per frame void Update() { if (isGrounded) { elevationFunction = RayCaster.GetComponent <ElevationChecker>(); raycastResult = elevationFunction.detectGround; // print("RAY RESULT " + raycastResult); if (raycastResult) { foundElevation = elevationFunction.inclineFinder; Vector3 pos = transform.position; pos.y = foundElevation + raiser; transform.position = pos; } } }
public void SetUp() { // check that the process can create web servers bool isProcessElevated = ElevationChecker.IsProcessElevated(false); Assert.IsTrue(isProcessElevated, "This test needs to run from an elevated IDE or nunit console"); // initialize custom HttpListener subclass to host the local files // https://docs.microsoft.com/en-us/dotnet/api/system.net.httplistener?redirectedfrom=MSDN&view=netframework-4.7.2 String filePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase).Replace("file:\\", ""); // Console.Error.WriteLine(String.Format("Using Webroot path: {0}", filePath)); pageServer = new SimpleHTTPServer(filePath); // implicitly does pageServer.Initialize() and pageServer.Listen(); Common.Port = pageServer.Port; // Console.Error.WriteLine(String.Format("Using Port {0}", port)); // initialize the Selenium driver // driver = new FirefoxDriver(); // System.InvalidOperationException : Access to 'file:///...' from script denied (UnexpectedJavaScriptError) if (headless) { var option = new ChromeOptions(); option.AddArgument("--headless"); driver = new ChromeDriver(option); } else { driver = new ChromeDriver(); } driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(60); Common.NgDriver = ngDriver = new NgWebDriver(driver); wait = new WebDriverWait(driver, TimeSpan.FromSeconds(wait_seconds)); wait.PollingInterval = TimeSpan.FromMilliseconds(wait_poll_milliseconds); actions = new Actions(driver); }
void Update() { ablLock = gameObject.GetComponent <PlayerChar>(); // Sets lock state to prevent player form using abilities while dashing or charging for dash. rotateLock = EmitterObj.GetComponent <Emitter_Centering>(); // Sets lock state to prevent emitter from rotating within the Emitter_Centering Script. travelRate = dashSpeed * Time.deltaTime; // Travel rate that the object will eventually travel to its destination. trackerStartPos = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z); // starting position for the tracker obj. // maxTravelPos = new Vector3(gameObject.transform.position.x + 40, gameObject.transform.position.y, gameObject.transform.position.z); // Sets maximum dash distance. //Basic Movement with rotation in same direcction as input key w/ attack delays if (canMove == true) { if ((Input.GetKey(KeyCode.W)) && (!Input.GetKey(KeyCode.D)) && (!Input.GetKey(KeyCode.A))) { //transform.rotation = Quaternion.Euler(new Vector3(0, 270, 0)); transform.Translate(Vector3.right * Time.deltaTime * speed); anim.SetBool("forward", true); anim.SetBool("back", false); anim.SetBool("left", false); anim.SetBool("right", false); } else if ((Input.GetKey(KeyCode.D)) && (!Input.GetKey(KeyCode.W)) && (!Input.GetKey(KeyCode.S))) { //transform.rotation = Quaternion.Euler(new Vector3 (0,0,0)); transform.Translate(Vector3.right * Time.deltaTime * speed); anim.SetBool("forward", false); anim.SetBool("back", false); anim.SetBool("left", false); anim.SetBool("right", true); } else if ((Input.GetKey(KeyCode.S)) && (!Input.GetKey(KeyCode.D)) && (!Input.GetKey(KeyCode.A))) { //transform.rotation = Quaternion.Euler(new Vector3 (0,90,0)); transform.Translate(Vector3.right * Time.deltaTime * speed); anim.SetBool("forward", false); anim.SetBool("back", true); anim.SetBool("left", false); anim.SetBool("right", false); } else if ((Input.GetKey(KeyCode.A)) && (!Input.GetKey(KeyCode.W)) && (!Input.GetKey(KeyCode.S))) { //transform.rotation = Quaternion.Euler(new Vector3 (0,180,0)); transform.Translate(Vector3.right * Time.deltaTime * speed); anim.SetBool("forward", false); anim.SetBool("back", false); anim.SetBool("left", true); anim.SetBool("right", false); } else if ((Input.GetKey(KeyCode.W)) && (Input.GetKey(KeyCode.D))) { //transform.rotation = Quaternion.Euler(new Vector3 (0,315,0)); transform.Translate(Vector3.right * Time.deltaTime * speed); anim.SetBool("forward", true); anim.SetBool("back", false); anim.SetBool("left", false); anim.SetBool("right", false); } else if ((Input.GetKey(KeyCode.W)) && (Input.GetKey(KeyCode.A))) { //transform.rotation = Quaternion.Euler(new Vector3 (0,225,0)); transform.Translate(Vector3.right * Time.deltaTime * speed); anim.SetBool("forward", true); anim.SetBool("back", false); anim.SetBool("left", false); anim.SetBool("right", false); } else if ((Input.GetKey(KeyCode.S)) && (Input.GetKey(KeyCode.D))) { //transform.rotation = Quaternion.Euler(new Vector3 (0,45,0)); transform.Translate(Vector3.right * Time.deltaTime * speed); anim.SetBool("forward", false); anim.SetBool("back", true); anim.SetBool("left", false); anim.SetBool("right", false); } else if ((Input.GetKey(KeyCode.S)) && (Input.GetKey(KeyCode.A))) { //transform.rotation = Quaternion.Euler(new Vector3 (0,135,0)); transform.Translate(Vector3.right * Time.deltaTime * speed); anim.SetBool("forward", false); anim.SetBool("back", true); anim.SetBool("left", false); anim.SetBool("right", false); } else if ((!Input.GetKey(KeyCode.W)) && (!Input.GetKey(KeyCode.A)) && (!Input.GetKey(KeyCode.S)) && (!Input.GetKey(KeyCode.D))) { anim.SetBool("forward", false); anim.SetBool("back", false); anim.SetBool("left", false); anim.SetBool("right", false); } } if (canTurn) { if ((Input.GetKey(KeyCode.W)) && (!Input.GetKey(KeyCode.D)) && (!Input.GetKey(KeyCode.A))) // Moving upwards. { transform.rotation = Quaternion.Euler(new Vector3(0, 270, 0)); faceDir = 0; } else if ((Input.GetKey(KeyCode.D)) && (!Input.GetKey(KeyCode.W)) && (!Input.GetKey(KeyCode.S))) // Moving right. { transform.rotation = Quaternion.Euler(new Vector3(0, 0, 0)); faceDir = 1; } else if ((Input.GetKey(KeyCode.S)) && (!Input.GetKey(KeyCode.D)) && (!Input.GetKey(KeyCode.A))) // Moving down. { transform.rotation = Quaternion.Euler(new Vector3(0, 90, 0)); faceDir = 2; } else if ((Input.GetKey(KeyCode.A)) && (!Input.GetKey(KeyCode.W)) && (!Input.GetKey(KeyCode.S))) // Moving left. { transform.rotation = Quaternion.Euler(new Vector3(0, 180, 0)); faceDir = 3; } else if ((Input.GetKey(KeyCode.W)) && (Input.GetKey(KeyCode.D))) // Moving up-right. { transform.rotation = Quaternion.Euler(new Vector3(0, 315, 0)); faceDir = 4; } else if ((Input.GetKey(KeyCode.W)) && (Input.GetKey(KeyCode.A))) // Moving up-left. { transform.rotation = Quaternion.Euler(new Vector3(0, 225, 0)); faceDir = 5; } else if ((Input.GetKey(KeyCode.S)) && (Input.GetKey(KeyCode.D))) // Moving down-right. { transform.rotation = Quaternion.Euler(new Vector3(0, 45, 0)); faceDir = 6; } else if ((Input.GetKey(KeyCode.S)) && (Input.GetKey(KeyCode.A))) // Moving down-left. { transform.rotation = Quaternion.Euler(new Vector3(0, 135, 0)); faceDir = 7; } } if (isGrounded) // Check to determine if there is ground underneath the charcter and to attach them to it if there is. Can be switched off for jumping and dashing over pits. { // float raiser = 5.2744f; float raiser = 5.2744f; elevationFunction = RayCaster.GetComponent <ElevationChecker>(); raycastResult = elevationFunction.detectGround; if (raycastResult) { foundElevation = elevationFunction.inclineFinder; Vector3 pos = transform.position; pos.y = foundElevation + raiser; transform.position = pos; } /* Vector3 inclineFinder; * inclineFinder = new Vector3(transform.position.x, transform.position.y, transform.position.z); * * Ray groundRay = new Ray(inclineFinder, Vector3.down); * * * // groundRay.origin = inclineFinder; * // groundRay.direction = Vector3.down; * * print("ground check starting"); * * Debug.DrawRay(inclineFinder, Vector3.down, Color.green); * * RaycastHit hitInfo; * * LayerMask layer = 1 << LayerMask.NameToLayer("Ground"); * * if (Physics.Raycast(groundRay, out hitInfo, layer)) * { * float y = hitInfo.point.y; * * Vector3 pos = transform.position; * * pos.y = y; * * transform.position = pos; * * print("Ground Z: " + pos.y); * } */ } //Attack delays to restrict movement during attacking state. if (!dashLock) { if (Input.GetMouseButtonDown(0)) { //left click StartCoroutine(AttackDelay(meleeDelay)); } else if (Input.GetMouseButtonDown(1)) { //right click StartCoroutine(AttackDelay(rangedDelay)); } else if (Input.GetKeyDown(KeyCode.LeftShift)) { //left shift StartCoroutine(AttackDelay(shieldDelay)); } } //Code to make sure player is withing a grid if (player.IsSleeping()) { //MoveToCenter (); } if (!dashLocked) { if (Input.GetKeyDown("space") && Time.time > nextDash) // If player presses space to start dashing and isn't currently dashing. Need to look into managing the abiity to cancel out of abilities and other states to prevent dashing./*&& !dashLock*/ { //print("space down"); dashActive = true; //destPos = new Vector3(trackerStartPos.x, trackerStartPos.y, trackerStartPos.z); // Sets starting dash destination // Locks canMove = false; // Restricts movement. ablLock.abilityLock = true; // Sets abilityLock to true in PlayerChar script to prevent ability usage while space is held down. //print("abilities Locked" + ablLock.abilityLock); isCharging = true; // Starts the charging state. // print("isCharging" + isCharging); dashBuffer = true; // if (destPos.x <= maxTravelPos.x && isCharging) // if (destPos.x <= maxTravelPos.x) } if (isCharging) { StartCoroutine(DashActionBuffer(bufferTime)); if (!dashBuffer) { dashDistance += incSpeed * Time.deltaTime; //print("dashDistance " + dashDistance); } // print("dashDistance " + dashDistance); dashLock = true; } if (dashDistance > maxIncrease) { isCharging = false; fixer = dashDistance - maxIncrease; dashDistance = dashDistance - fixer; } if (dashDistance == maxIncrease && dashLock) { isCharging = false; // print("Final dashDistance " + dashDistance); } if (Input.GetKeyUp("space") && Time.time > nextDash && dashActive /*&& dashLock*/) { print("space up"); isCharging = false; // turns off isCharging just in case. Character still locked into dash windup state. // print("isCharging" + isCharging); canTurn = false; rotateLock.canRotate = false; //print("canTurn " + canTurn); inTransit = true; //print("inTransit state " + inTransit); dashDistance = dashDistance + 20f; //print("Totally Final Distance" + dashDistance); SetDashDirection(faceDir); // dashStartTime = Time.time; dashTimeOut = Time.time + 0.4f; // print("Dash Time Out " + dashTimeOut); nextDash = Time.time + dashCD; //print("nextDash " + nextDash); } if (inTransit) { if (gameObject.transform.position != travelTarget) // translate player character to the dash travel destination. //if ((gameObject.transform.position.x != travelTarget.x) && (gameObject.transform.position.z != travelTarget.z) || (gameObject.transform.position.x != travelTarget.x) && (gameObject.transform.position.z == travelTarget.z) || (gameObject.transform.position.x == travelTarget.x) && (gameObject.transform.position.z != travelTarget.z)) { canTurn = false; // gameObject.transform.position = Vector3.MoveTowards(gameObject.transform.position, travelTarget, travelRate); // translate player character to the dash travel destination. transform.Translate(Vector3.right * Time.deltaTime * dashSpeed); // print("dashing in process"); //gameObject.transform.Translate(Vector3.right * Time.deltaTime * speed); } if (Time.time >= dashTimeOut) { //print("dash timed out"); travelTarget = gameObject.transform.position; inTransit = false; } } //gameObject.transform.Translate(Vector3.right * Time.deltaTime * speed); /* if (destPos.x <= maxTravelPos.x) * { * gameObject.transform.position = Vector3.MoveTowards(gameObject.transform.position, travelTarget, travelRate); * } */ //if ((gameObject.transform.position.x == travelTarget.x) && (gameObject.transform.position.z == travelTarget.z)) if (gameObject.transform.position == travelTarget) { // print("DESTINATION REACHED"); // print("DASH TIME OUT"); StartCoroutine(DashRecovery(dashRecoveryTime)); // Starts delay on dash recovery after finishing dash travel. dashLock = false; ablLock.abilityLock = false; //print("abilities Locked " + ablLock.abilityLock); dashDistance = 0; inTransit = false; dashActive = false; } } // Release locks after action is done. This could probably be changed after animations are incorporated to include the animation durations. // Set this to the player for it. TravelObj is a child of the object that this script is attached to so that it doesnt have to worry about rotation. // Need to make sure that it locks player movement but not rotation when charging. // Needs to lock ability usage when charging as well. }