public HookState CreateState(HookStates state) { switch (state) { case HookStates.Waiting: { return(_waitingFactory.Create()); } case HookStates.Moving: { return(_movingFactory.Create()); } case HookStates.Returning: { return(_returningFactory.Create()); } case HookStates.Dead: { return(_deadFactory.Create()); } } throw Assert.CreateException(); }
public void HookProcessHandle(string processName, out HookStates hookState) { var p = Utils.GetProcessByName(processName); if (p != null) { _noxWndHandle = p.MainWindowHandle; if (_noxWndHandle != null) { Utils.Rect rect = GetCurrentWndRect(); if (rect.X < 0 || rect.Y < 0 || rect.Width <= 0 || rect.Height <= 0) { Console.WriteLine("Process hook is succcessful but window is minimized!!"); hookState = HookStates.WindowMinimized; } else { Console.WriteLine("Hook process window successed!!! " + p.ProcessName + " " + rect.Left + " " + rect.Right + " " + rect.Top + " " + rect.Bottom + " !!!!!!"); hookState = HookStates.Successed; } } else { Console.WriteLine("Hook process failed!!!"); hookState = HookStates.Failed; } } else { Console.WriteLine("There is no process!!! " + processName); hookState = HookStates.NoProcess; } }
void BeingShoot() { if (attached) { currentState = HookStates.Attached; } }
void StartGrapple() { if (Input.GetButtonDown("Fire1")) { RaycastHit hit; if (Physics.Raycast(origin: cam.transform.position, direction: cam.transform.forward, out hit, maxDistance, grappleLayer)) { grapplePoint = hit.point; //shootPoint.transform.position = hit.point; joint = playerTransform.gameObject.AddComponent <SpringJoint>(); joint.autoConfigureConnectedAnchor = false; joint.connectedAnchor = grapplePoint; float distanceFromPoint = Vector3.Distance(playerTransform.position, grapplePoint); joint.maxDistance = distanceFromPoint * jointMaxDistance; joint.minDistance = distanceFromPoint * jointMinDistance; joint.spring = jointSpringForce; joint.damper = jointDamper; joint.massScale = jointMassScale; currentHookState = HookStates.Attached; currentGrapplePosition = shootPoint.position; lineRenderer.positionCount = 2; } } }
public void ChangeState(HookStates state) { if (_state != null) { _state.Dispose(); _state = null; } _state = _stateFactory.CreateState(state); _state.Start(); }
void AttachedHook() { if (Input.GetButtonDown("Fire1")) { StartCoroutine(LerpHookGun(playerTransform, playerTransform.position, hitPosition, 0.5f)); hookTransform.parent = transform; hookTransform.localPosition = originalPosition; hookTransform.eulerAngles = originalRotation; attached = false; currentState = HookStates.Ready; hitPosition = Vector3.zero; } }
public IEnumerator LerpPos(Rigidbody r, Transform t, Vector3 startPos, Vector3 endPos, float timeTotal) { currentHookState = HookStates.Returning; float currentTime = 0; while (currentTime < timeTotal) { currentTime += Time.deltaTime; r.MovePosition(Vector3.Lerp(startPos, endPos, (currentTime / timeTotal))); //t.localPosition = Vector3.Lerp(startPos, endPos, (currentTime / timeTotal)); yield return(null); } yield return(null); }
void StopGrapple() { if (Input.GetButtonDown("Fire1")) { StartCoroutine(LerpPos(rigid, playerTransform, playerTransform.position, currentGrapplePosition, 0.3f)); lineRenderer.positionCount = 0; Destroy(joint); currentHookState = HookStates.Ready; //shootPoint.localPosition = shootPointOriginalPosition; } else if (Input.GetButtonDown("Fire2")) { lineRenderer.positionCount = 0; Destroy(joint); currentHookState = HookStates.Ready; } }
void Shoot() { var rayOrigin = playerCam.ScreenPointToRay(Input.mousePosition); RaycastHit hit; Debug.Log(rayOrigin); if (Input.GetButtonDown("Fire1")) { if (Physics.Raycast(rayOrigin, out hit)) { hitPosition = hit.point; hookTransform.position = Vector3.MoveTowards(hookTransform.position, hitPosition, 3); hookTransform.parent = null; attached = true; currentState = HookStates.Shooting; } } }
void Start() { currentHookState = HookStates.Ready; }