private void CheckAxis() { float h = Input.GetAxis(joyInputs.xAxisKey); float v = Input.GetAxis(joyInputs.yAxisKey); float x, y; if (h > 0.3f || h < -0.3f) { x = h; } else { x = 0; } if (v > 0.3f || v < -0.3f) { y = v; } else { y = 0; } AxisMovement?.Invoke(new Vector2(x, y)); x = 0; if (Input.GetKey(KeyCode.LeftArrow)) { x = -1; } if (Input.GetKey(KeyCode.RightArrow)) { x = 1; } y = 0; if (Input.GetKey(KeyCode.UpArrow)) { y = -1; } if (Input.GetKey(KeyCode.DownArrow)) { y = 1; } if (x != 0 && joyInputs.xAxisInvert) { x *= -1; } if (y != 0 && joyInputs.yAxisInvert) { y *= -1; } AxisInput = new Vector2(x, y); AxisMovement?.Invoke(new Vector2(x, y)); }
// Update is called once per frame void Update() { moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0.0f, Input.GetAxis("Vertical")); moveDirection *= speed * Time.deltaTime; controller.Move(moveDirection * Time.deltaTime); if (moveDirection.magnitude > 0) { OnMove?.Invoke(transform.position); } }
private void CheckAxis3rd() { float h = Input.GetAxis(joyInputs._3thAxisKey); float v = Input.GetAxis(joyInputs._5thAxisKey); int x, y; if (v > 0.3f) { x = 1; } else if (v < -0.3f) { x = -1; } else { x = 0; } if (h > 0.3f) { y = 1; } else if (h < -0.3f) { y = -1; } else { y = 0; } if (x != 0 && joyInputs._3thAxisInvert) { x *= -1; } if (y != 0 && joyInputs._5thAxisInvert) { y *= -1; } if (Mathf.Abs(x) > 0.3f || Mathf.Abs(y) > 0.3f) { Axis3rdMoveMent?.Invoke(new Vector2(x, y)); } }
// Update is called once per frame void Update() { movementDelegate?.Invoke(new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"))); rotationDelegate?.Invoke(new Vector3(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"), 0)); if (Input.GetKeyDown(KeyCode.C)) { abilityDelegate?.Invoke(true, false, false); } else if (Input.GetKey(KeyCode.C)) { abilityDelegate?.Invoke(false, true, false); } else if (Input.GetKeyUp(KeyCode.C)) { abilityDelegate?.Invoke(false, false, true); } }
public void AddWithRandomPosition(ISpatialEntity entity, Vector3 min, Vector3 max, bool grid, MovementDelegate movementDelegate) { //Evaluate dimesions var shapeTmp = new Vector3(entity.Shape.Bounds.Length / 2, entity.Shape.Bounds.Height / 2, entity.Shape.Bounds.Width / 2); if (!checkBoundarys(min - shapeTmp, max + shapeTmp)) { movementDelegate.Invoke(new MovementResult()); return; } if (gpuActive) gpuActiveWait.WaitOne(); Interlocked.Increment(ref m_ActiveOperationCount); Vector3 freepos = GetNextFreeCell(min, max); if (freepos == Vector3.Null) { var rnd = new Random(); freepos = new Vector3((double)rnd.Next((int)min.X, (int)max.X), (double)rnd.Next((int)min.Y, (int)max.Y), (double)rnd.Next((int)min.Z, (int)max.Z)); } var objId = getNextObjId(); var objData = objId | FLAG_NEW; m_AddDelegates.Add(new Tuple<long, MovementDelegate>(objData, movementDelegate)); objIdList.Add(objId); spatialObjIdMap.Add(entity, objId); objIdSpatialMap.Add(objId, entity); entity.Shape = new Cuboid(entity.Shape.Bounds.Dimension, freepos); clShapeObject act; clPoint center; center.x = (float)entity.Shape.Bounds.Position.X; center.y = (float)entity.Shape.Bounds.Position.Y; center.z = (float)entity.Shape.Bounds.Position.Z; clPoint front; front.x = (float)entity.Shape.Bounds.LeftBottomFront.X; front.y = (float)entity.Shape.Bounds.LeftBottomFront.Y; front.z = (float)entity.Shape.Bounds.LeftBottomFront.Z; clPoint rear; rear.x = (float)entity.Shape.Bounds.RightTopRear.X; rear.y = (float)entity.Shape.Bounds.RightTopRear.Y; rear.z = (float)entity.Shape.Bounds.RightTopRear.Z; act.center = center; act.leftBottomFront = front; act.rigthTopRear = rear; envFreshAddedObjs.Add(objData, act); /* shapeList.Add(act); objIdClShapeMap.Add(objId, act); */ // Added Element -> Now wait until the CollisionDetection did its work at the LayerTick Interlocked.Decrement(ref m_ActiveOperationCount); // envActEnvObjs.Add(objId, act); // We need the list with free positions first }
public void Add(ISpatialEntity entity, Vector3 position, Direction rotation, MovementDelegate movementDelegate) { entity.Shape.Transform(position - entity.Shape.Position, null); // First check boundarys if (!checkBoundarys(entity.Shape.Bounds.LeftBottomFront,entity.Shape.Bounds.RightTopRear)) { movementDelegate.Invoke(new MovementResult()); return; } bool res; if (gpuActive) gpuActiveWait.WaitOne(); Interlocked.Increment(ref m_ActiveOperationCount); int objId = getNextObjId(); long objData = objId | FLAG_NEW; m_AddDelegates.Add(new Tuple<long,MovementDelegate>(objData,movementDelegate)); objIdList.Add(objId); spatialObjIdMap.Add(entity, objId); objIdSpatialMap.Add(objId, entity); clShapeObject act; clPoint center; center.x = (float)entity.Shape.Bounds.Position.X; center.y = (float)entity.Shape.Bounds.Position.Y; center.z = (float)entity.Shape.Bounds.Position.Z; clPoint front; front.x = (float)entity.Shape.Bounds.LeftBottomFront.X; front.y = (float)entity.Shape.Bounds.LeftBottomFront.Y; front.z = (float)entity.Shape.Bounds.LeftBottomFront.Z; clPoint rear; rear.x = (float)entity.Shape.Bounds.RightTopRear.X; rear.y = (float)entity.Shape.Bounds.RightTopRear.Y; rear.z = (float)entity.Shape.Bounds.RightTopRear.Z; act.center = center; act.leftBottomFront = front; act.rigthTopRear = rear; objIdClShapeMap.Add(objId, act); envFreshAddedObjs.Add(objData, act); /* shapeList.Add(act); objIdClShapeMap.Add(objId, act); */ Interlocked.Decrement(ref m_ActiveOperationCount); }