Exemplo n.º 1
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Ball")
     {
         BallBehaviour i_ballBehaviour = other.GetComponent <BallBehaviour>();
         if (i_ballBehaviour.GetState() == BallState.Flying)
         {
             if (i_ballBehaviour.GetCurrentThrower() == pawnController && (i_ballBehaviour.GetCurrentBounceCount() < passController.minBouncesBeforePickingOwnBall || i_ballBehaviour.GetTimeFlying() < passController.delayBeforePickingOwnBall))
             {
                 return;
             }
             passController.Receive(i_ballBehaviour);
         }
         else if (i_ballBehaviour.GetState() == BallState.Grounded)
         {
             passController.Receive(i_ballBehaviour);
         }
     }
     if (other.tag == "GrabbableTrigger" && playerController)
     {
         GrabbableInformation grabbableInformation = other.GetComponent <GrabbableInformation>();
         grabbableInformation.EnablePreviewForPlayer(playerController);
         playerController.targetedGrabbable.Add(grabbableInformation);
     }
 }
Exemplo n.º 2
0
 private void OnTriggerExit(Collider other)
 {
     if (other.tag == "GrabbableTrigger" && playerController)
     {
         GrabbableInformation grabbableInformation = other.GetComponent <GrabbableInformation>();
         grabbableInformation.DisablePreviewForPlayer(playerController);
         playerController.targetedGrabbable.Remove(grabbableInformation);
     }
 }
Exemplo n.º 3
0
 void RemoveGrabbableInformation(GrabbableInformation _inf)
 {
     if (grabbable.grabbableInformation.Contains(_inf))
     {
         grabbable.grabbableInformation.Remove(_inf);
         DestroyImmediate(_inf.gameObject);
     }
     UpdateInformations();
 }
Exemplo n.º 4
0
    private GrabbableInformation GetPrioritaryGrabInformation()
    {
        GrabbableInformation i_prioritaryInformation = targetedGrabbable[0];
        Vector3 i_prioritaryDirection = i_prioritaryInformation.targetedPosition.position - GetCenterPosition();

        i_prioritaryDirection.y = 0;
        float i_prioritaryAngle = Vector3.SignedAngle(lookInput, i_prioritaryDirection, Vector3.up);

        foreach (GrabbableInformation gi in targetedGrabbable)
        {
            Vector3 i_giDirection = gi.targetedPosition.position - GetCenterPosition();
            i_giDirection.y = 0;
            float i_newAngle = Vector3.SignedAngle(lookInput, i_giDirection, Vector3.up);
            if (Mathf.Abs(i_newAngle) < Mathf.Abs(i_prioritaryAngle))
            {
                i_prioritaryInformation = gi;
                i_prioritaryAngle       = i_newAngle;
            }
        }
        return(i_prioritaryInformation);
    }
Exemplo n.º 5
0
    private void CheckRightShoulder()
    {
        if (state.Buttons.RightShoulder == ButtonState.Pressed)
        {
            rightButtonWaitForRelease = true;
            rbPressDuration          += Time.deltaTime;
            if (extendingArmsController != null && targetedGrabbable.Count > 0)
            {
                float i_pressPercent = rbPressDuration / extendingArmsController.minGrabHoldDuration;
                i_pressPercent = Mathf.Clamp(i_pressPercent, 0f, 1f);
                extendingArmsController.UpdateDecalSize(i_pressPercent);

                prioritaryGrabInformation = GetPrioritaryGrabInformation();
                if (prioritaryGrabInformation != null)
                {
                    passController.StopAim();
                    extendingArmsController.TogglePreview(true);
                    ForceLookAt(prioritaryGrabInformation.targetedPosition.position); //Player will rotate toward look input
                }
            }
            else if (extendingArmsController != null)
            {
                extendingArmsController.TogglePreview(false);
            }
        }
        else if (state.Buttons.RightShoulder == ButtonState.Released && rightButtonWaitForRelease)
        {
            rightButtonWaitForRelease = false;
            if (extendingArmsController != null)
            {
                extendingArmsController.TogglePreview(false);
                if (rbPressDuration >= extendingArmsController.minGrabHoldDuration && targetedGrabbable.Count > 0)
                {
                    extendingArmsController.ExtendArm();
                }
            }
            rbPressDuration = 0;
        }
    }
Exemplo n.º 6
0
    private void CheckGrapple()
    {
        if (bindings.grapple.key)
        {
            rbPressDuration += Time.deltaTime;
            if (extendingArmsController != null && targetedGrabbable.Count > 0)
            {
                float i_pressPercent = rbPressDuration / extendingArmsController.minGrabHoldDuration;
                i_pressPercent = Mathf.Clamp(i_pressPercent, 0f, 1f);
                extendingArmsController.UpdateDecalSize(i_pressPercent);

                prioritaryGrabInformation = GetPrioritaryGrabInformation();
                if (prioritaryGrabInformation != null)
                {
                    passController.StopAim();
                    extendingArmsController.TogglePreview(true);
                    ForceLookAt(prioritaryGrabInformation.targetedPosition.position); //Player will rotate toward look input
                }
            }
            else if (extendingArmsController != null)
            {
                extendingArmsController.TogglePreview(false);
            }
        }
        else if (bindings.grapple.keyUp)
        {
            if (extendingArmsController != null)
            {
                extendingArmsController.TogglePreview(false);
                if (rbPressDuration >= extendingArmsController.minGrabHoldDuration && targetedGrabbable.Count > 0)
                {
                    extendingArmsController.ExtendArm();
                }
            }
            rbPressDuration = 0;
        }
    }
Exemplo n.º 7
0
    public void OnSceneGUI()
    {
        for (int i = 0; i < grabbable.grabbableInformation.Count; i++)
        {
            GrabbableInformation gi = grabbable.grabbableInformation[i];
            if (gi.previewLine.sharedMaterial != datas.editorLineRendererMaterial)
            {
                gi.previewLine.sharedMaterial = datas.editorLineRendererMaterial;
            }
            if (gi.previewLine.startWidth != datas.editorLineRendererWidth)
            {
                gi.previewLine.startWidth = datas.editorLineRendererWidth;
                gi.previewLine.endWidth   = datas.editorLineRendererWidth;
            }
            //Move collider
            Handles.Label(gi.transform.position, "GrabInfo[" + gi.id + "]");
            EditorGUI.BeginChangeCheck();
            Vector3 newColliderPosition = Handles.PositionHandle(gi.transform.position, Quaternion.identity);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(gi, "Change grabbable information collider position");
                gi.transform.position = newColliderPosition;
                grabbable.UpdateLine();
            }

            //Move target
            EditorGUI.BeginChangeCheck();
            Vector3 newTargetPosition = Handles.PositionHandle(gi.targetedPosition.position, Quaternion.identity);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(gi, "Change grabbable information target position");
                gi.targetedPosition.position = newTargetPosition;
                grabbable.UpdateLine();
            }
        }
    }