/// <summary> /// Maps control to state. If we want to change the key controls, change them here, /// without changing anywhere else. /// </summary> void MapInputToState() { if (Input.GetKey (KeyCode.UpArrow) && Input.GetKey (KeyCode.LeftArrow)){ lookingState = Looking.UpLeft; } else if (Input.GetKey (KeyCode.UpArrow) && Input.GetKey (KeyCode.RightArrow)){ lookingState = Looking.UpRight; } else if (Input.GetKey (KeyCode.DownArrow) && Input.GetKey (KeyCode.LeftArrow)){ lookingState = Looking.DownLeft; } else if (Input.GetKey (KeyCode.DownArrow) && Input.GetKey (KeyCode.RightArrow)){ lookingState = Looking.DownRight; } else if (Input.GetKey(KeyCode.UpArrow)){ lookingState = Looking.Up; } else if (Input.GetKey (KeyCode.DownArrow) ){ lookingState = Looking.Down; } else if (Input.GetKey (KeyCode.LeftArrow)){ lookingState = Looking.Left; } else if (Input.GetKey (KeyCode.RightArrow)){ lookingState = Looking.Right; } }
public override void Draw(SpriteBatch sb) { base.Draw(sb); ShapeRenderer.Rect(sb, Color, GetDrawPosition(), BoundingBox * 2); ShapeRenderer.Rect(sb, Color, (int)Position.X, (int)Position.Y, (int)BoundingBox.X, (int)BoundingBox.Y); Looking = Looking.Forward; float rotation = 0; if (LookingDown) { rotation = (float)Math.PI; } if (LookingUp) { } if (Facing == Facing.Right) { ShapeRenderer.Rect(sb, Color.DarkBlue, GetDrawPosition() + new Vector2(BoundingBox.X * 2, 0), new Vector2(30, 10)); } if (Facing == Facing.Left) { ShapeRenderer.Rect(sb, Color.DarkBlue, GetDrawPosition() - new Vector2(30, 0), new Vector2(30, 10)); } //ShapeRenderer.Rect(sb, Color.DarkBlue, GetDrawPosition(), new Vector2(20, 8), rotation); TextRenderer.Print(sb, Health.ToString(), GetDrawPosition(), Color.Green); }
void SendLooking(GameObject go) { //Debug.Log("PlayerInteract.SendLooking"); Looking looking = new Looking(); looking.actor = interactorCamera.transform; FFMessageBoard <Looking> .SendToLocalToAllConnected(looking, go); }
private void ChangeDirection() { var randomValue = new Random(DateTime.Now.Millisecond + DateTime.Now.Second).NextDouble(); var movement = (int)Math.Floor(randomValue * 4); var arrayOfMovement = new Looking[] { Looking.Left, Looking.Up, Looking.Down, Looking.Right }; this.Direction = arrayOfMovement[movement]; }
// Update is called once per frame void Update() { cLooking = camera.GetComponent<CameraMovement>().cLooking; float targetProfile = 1; float target3D = 1; float targetTop = 1; switch (cLooking) { case Looking.l3D: targetProfile = 1; target3D = 0; targetTop = 1; break; case Looking.lProfile: targetProfile = 0; target3D = 1; targetTop = 1; break; case Looking.lTop: targetProfile = 1; target3D = 1; targetTop = 0; break; } foreach (GameObject goProfile in profile) { Color colorAux = goProfile.GetComponent<MeshRenderer>().material.color; float finalAlpha = Mathf.SmoothDamp(goProfile.GetComponent<MeshRenderer>().material.color.a, targetProfile, ref alfaVelocityProfile, smoothTime); colorAux.a = finalAlpha; goProfile.GetComponent<MeshRenderer>().material.color = colorAux; if (finalAlpha > 0.8) { goProfile.GetComponent<BoxCollider>().enabled = true; goProfile.GetComponent<MeshRenderer>().enabled = true; } else if (finalAlpha < 0.2) { goProfile.GetComponent<BoxCollider>().enabled = false; goProfile.GetComponent<MeshRenderer>().enabled = false; } } foreach (GameObject go3D in vista3D) { Color colorAux = go3D.GetComponent<MeshRenderer>().material.color; float finalAlpha = Mathf.SmoothDamp(go3D.GetComponent<MeshRenderer>().material.color.a, target3D, ref alfaVelocity3D, smoothTime); colorAux.a = finalAlpha; go3D.GetComponent<MeshRenderer>().material.color = colorAux; if (finalAlpha > 0.8) { go3D.GetComponent<BoxCollider>().enabled = true; go3D.GetComponent<MeshRenderer>().enabled = true; } else if (finalAlpha < 0.2) { go3D.GetComponent<BoxCollider>().enabled = false; go3D.GetComponent<MeshRenderer>().enabled = false; } } }
protected override void Update() { base.Update(); var input = GetMoveInput(); if (Moving) Moving.MoveInDirection(input); if (Looking) Looking.LookInDirection(input); if (Picking) { if (IsButtonDown("Fire1")) Picking.PickUpOrRelease(); if (enemySelecting) enemySelecting.SetEnabled(Picking.IsHolding); } }
private void Rotate(ConsoleKey keyCode) { switch (keyCode) { case ConsoleKey.NumPad3: case ConsoleKey.RightArrow: this.interimDirection = Looking.Right; break; case ConsoleKey.NumPad1: case ConsoleKey.LeftArrow: this.interimDirection = Looking.Left; break; case ConsoleKey.NumPad5: case ConsoleKey.UpArrow: this.interimDirection = Looking.Up; break; default: this.interimDirection = Looking.Down; break; } }
void Update() { movement.x = Input.GetAxisRaw("Horizontal"); movement.y = Input.GetAxisRaw("Vertical"); if (movement.x == 0 && movement.y == 0) { isMoving = false; } else { isMoving = true; } mousePOS = cam.ScreenToWorldPoint(Input.mousePosition); if (lookDir.x > 0f && Mathf.Abs(lookDir.x) > Mathf.Abs(lookDir.y)) { looking = Looking.Right; } if (lookDir.x < 0f && Mathf.Abs(lookDir.x) > Mathf.Abs(lookDir.y)) { looking = Looking.Left; } if (lookDir.y > 0f && Mathf.Abs(lookDir.x) < Mathf.Abs(lookDir.y)) { looking = Looking.Up; } if (lookDir.y < 0f && Mathf.Abs(lookDir.x) < Mathf.Abs(lookDir.y)) { looking = Looking.Down; } // Visual for slowed effect if (isSlowed) { sr.color = Color.green; } else if (!isSlowed) { sr.color = Color.white; } }
public void DashAbility(Looking direction) { if (canDash) { canDash = false; StartCoroutine(ToggleIsDashingBool()); switch (direction) { default: throw new System.Exception("invalid dash direction provided"); case Looking.Up: rb.velocity = new Vector2(rb.velocity.x, rb.velocity.y + dashSpeed); anim.Play("Human_Dash_Up"); // shaker.CombatShaker("Up"); dashCoolDown = Time.time; break; case Looking.Down: rb.velocity = new Vector2(rb.velocity.x, rb.velocity.y - dashSpeed); anim.Play("Human_Dash_Down"); // shaker.CombatShaker("Down"); dashCoolDown = Time.time; break; case Looking.Left: rb.velocity = new Vector2(rb.velocity.x - dashSpeed, rb.velocity.y); anim.Play("Human_Dash_Left"); dashCoolDown = Time.time; break; case Looking.Right: rb.velocity = new Vector2(rb.velocity.x + dashSpeed, rb.velocity.y); anim.Play("Human_Dash_Right"); // shaker.CombatShaker("Right"); dashCoolDown = Time.time; break; } } }
public virtual async void Move(Position coordinates, Looking direction) { var currentLeft = coordinates.Left; var currentTop = coordinates.Top; if (direction == Looking.Left) { coordinates.Top = currentTop; coordinates.Left = Math.Max(currentLeft - this.Velocity, 0); } else { if (direction == Looking.Up) { coordinates.Top = Math.Max(currentTop - this.Velocity, this.TopScoreBoard); coordinates.Left = currentLeft; } else { BrowserDimension window = await GetBrowserDimensionAsync(); if (direction == Looking.Right) { coordinates.Top = currentTop; coordinates.Left = Math.Min(currentLeft + this.Velocity, window.Width - this.Size - this.Border); } else { coordinates.Top = Math.Min(currentTop + this.Velocity, window.Height - this.Size - this.Border); coordinates.Left = currentLeft; } } } StateHasChanging(); }
public override void Update(float delta) { base.Update(delta); //Console.WriteLine(Position); if (MovingLeft) { Facing = Facing.Left; } if (MovingRight) { Facing = Facing.Right; } if (LookingDown) { Looking = Looking.Down; } if (LookingUp) { Looking = Looking.Up; } }
// Update is called once per frame void Update() { lastMovement += Time.deltaTime; if(Input.GetKeyDown(KeyCode.Space)){ if(cLooking != Looking.l3D){ cLooking = Looking.l3D; moving = true; rotating = true; lastMovement = 0; this.GetComponent<Camera>().orthographic = false; } else { cLooking = Looking.lProfile; moving = true; rotating = true; lastMovement = 0; this.GetComponent<Camera>().orthographic = true; this.GetComponent<Camera>().orthographicSize = 5.5f; } } //if ( Input.GetKeyDown( KeyCode.Alpha1 ) || Mathf.Abs( Input.acceleration.x ) < 0.3 ) { if ( Input.GetKeyDown( KeyCode.Alpha1 ) ) { if ( cLooking != Looking.l3D ) lastMovement = 0; cLooking = Looking.l3D; moving = true; rotating = true; this.GetComponent<Camera>().orthographic = false; } else if (Input.GetKeyDown(KeyCode.Alpha2)) { // if ( Input.GetKeyDown( KeyCode.Alpha2 ) || Mathf.Abs( Input.acceleration.x ) > 0.7 ) { if ( cLooking != Looking.lProfile ) lastMovement = 0; cLooking = Looking.lProfile; moving = true; rotating = true; this.GetComponent<Camera>().orthographic = true; this.GetComponent<Camera>().orthographicSize = 5.5f; } /* else if (Input.GetKeyDown(KeyCode.Alpha3)) { cLooking = Looking.lTop; moving = true; rotating = true; lastMovement = 0; this.GetComponent<Camera>().orthographic = false; }*/ if (!moving && !rotating) return; // MOVING targetPosition = Vector3.zero; Vector3 targetRotation = Vector3.zero; switch (cLooking) { case Looking.l3D: targetPosition = t3D; targetRotation = r3D; canvasLand.SetActive(false); canvasPort.SetActive(true); break; case Looking.lProfile: targetPosition = tProfile; targetRotation = rProfile; if (transform.localEulerAngles.y > targetRotation.y + 360) targetRotation.y += 360; canvasLand.SetActive(true); canvasPort.SetActive(false); break; case Looking.lTop: targetPosition = tTop; targetRotation = rTop; break; } if (moving) { transform.localPosition = Vector3.SmoothDamp (transform.localPosition, targetPosition, ref velocity, smoothTime); if (Vector3.Distance (transform.localPosition, targetPosition) < 0.0001) { moving = false; velocity = Vector3.zero; } } if (rotating) { Vector3 auxTargetRotation = targetRotation; if (Mathf.Abs(targetRotation.y - transform.localEulerAngles.y) > 180) { if (transform.localEulerAngles.y > targetRotation.y) auxTargetRotation.y += 360; else auxTargetRotation.y -= 360; } Vector3 rotation = Vector3.SmoothDamp (transform.localEulerAngles, auxTargetRotation, ref angularVelocity, smoothTime); transform.localEulerAngles = rotation; /*if (Vector3.Distance (transform.localEulerAngles, auxTargetRotation) < 0.00001) { rotating = false; angularVelocity = Vector3.zero; }*/ } if (Input.GetKeyDown(KeyCode.Z)) shake(); }
void Point() { switch(lookingState){ case Looking.Up: if (lookingState != previousLookingState){ ResetState(); } rigidbody2D.velocity = new Vector2(0, speed); previousLookingState = lookingState; break; case Looking.Down: if (lookingState != previousLookingState){ ResetState(); transform.Rotate(Vector3.forward*-180); } rigidbody2D.velocity = new Vector2(0, -speed); previousLookingState = lookingState; break; case Looking.Left: if (lookingState != previousLookingState){ ResetState(); transform.Rotate(Vector3.forward*90); } rigidbody2D.velocity = new Vector2(-speed, 0); previousLookingState = lookingState; break; case Looking.Right: if (lookingState != previousLookingState){ ResetState(); transform.Rotate(Vector3.forward*-90); } rigidbody2D.velocity = new Vector2(speed, 0); previousLookingState = lookingState; break; case Looking.UpLeft: if (lookingState != previousLookingState){ ResetState(); transform.Rotate(Vector3.forward*45); } rigidbody2D.velocity = new Vector2(-speed, speed); previousLookingState = lookingState; break; case Looking.UpRight: if (lookingState != previousLookingState){ ResetState(); transform.Rotate(Vector3.forward*-45); } rigidbody2D.velocity = new Vector2(speed, speed); previousLookingState = lookingState; break; case Looking.DownLeft: if (lookingState != previousLookingState){ ResetState(); transform.Rotate(Vector3.forward*-225); } rigidbody2D.velocity = new Vector2(-speed, -speed); previousLookingState = lookingState; break; case Looking.DownRight: if (lookingState != previousLookingState){ ResetState(); transform.Rotate(Vector3.forward*-135); } rigidbody2D.velocity = new Vector2(speed, -speed); previousLookingState = lookingState; break; default : //lookingState = Looking.Up; break; } }