コード例 #1
0
ファイル: HandAction.cs プロジェクト: digiz3d/Protokov
    public static PlayerHandAction CreateAction(HandActionId id, GameObject interactorGameObject, GameObject interactedGameObject)
    {
        PlayerHandAction action = null;

        switch (id)
        {
        case HandActionId.Cancel:
            action = new CancelAction(interactorGameObject, interactedGameObject);
            break;

        case HandActionId.OpenDoor:
            break;

        case HandActionId.PressButton:
            action = new PressButtonAction(interactorGameObject, interactedGameObject);
            break;

        case HandActionId.Take:
            action = new TakeAction(interactorGameObject, interactedGameObject);
            break;

        default:
            break;
        }

        return(action);
    }
コード例 #2
0
    public void TriggeredBy(HandActionId action, GameObject actorGameObject)
    {
        PlayerActionsManager actorActionsManager = actorGameObject.GetComponent <PlayerActionsManager>();

        PlayerHandAction playerHandAction = PlayerHandAction.CreateAction(action, actorGameObject, gameObject);

        actorActionsManager.EnqueueAction(playerHandAction);
    }
コード例 #3
0
    void ExecuteAction(PlayerHandAction action)
    {
        if (isExecutingAction || currentCoroutine != null)
        {
            return;
        }

        isExecutingAction = true;
        currentCoroutine  = StartCoroutine(action.GetBehaviour());
        loadingAction.Show(action.Duration);
    }
コード例 #4
0
 void Update()
 {
     if (actionsQueue.Count > 0)
     {
         PlayerHandAction nextAction = actionsQueue.Peek();
         if (CanExecuteAction(nextAction))
         {
             ExecuteAction(actionsQueue.Dequeue());
         }
     }
 }
コード例 #5
0
    bool CanExecuteAction(PlayerHandAction action)
    {
        if (IsLeftHandBusy && action.RequiresLeftHand)
        {
            return(false);
        }
        if (IsRightHandBusy && action.RequiresRightHand)
        {
            return(false);
        }

        return(true);
    }
コード例 #6
0
    public void Awake()
    {
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible   = false;

        if (!photonView.IsMine && PhotonNetwork.IsConnected)
        {
            this.enabled = false;
        }
        else
        {
            //
            _instance = this;

            _currentInput.PositionInput = Vector3.zero;
            _currentInput.RotationInput = Vector3.zero;

            _playerMovement = GetComponent <PlayerMovement>();
            if (CheckComponentValue())
            {
                Debug.Log("Player InputController : Components are Unset, Please Check Object");
                gameObject.SetActive(false);
            }

            _playerCameraComponent         = PlayerCamera.GetComponent <Camera>();
            _playerCameraComponent.enabled = true;
            PlayerCamera.GetComponent <AudioListener>().enabled = true;

            _leftHandAction  = PlayerHandL.GetComponent <PlayerHandAction>();
            _rightHandAction = PlayerHandR.GetComponent <PlayerHandAction>();

            // Delegate : Bind Input by Controller Type
            if (XRDevice.isPresent)
            {
                _trackedObjRightHand = PlayerHandR.GetComponent <SteamVR_Behaviour_Pose>();
                _trackedObjLeftHand  = PlayerHandL.GetComponent <SteamVR_Behaviour_Pose>();

                _north = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("North");
                _south = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("South");
                _west  = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("West");
                _east  = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("East");

                _interaction = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("InteractUI");

                InputBinderForUpdate += new InputBinder(SVRPositionInput);
                InputBinderForUpdate += new InputBinder(SVRRotationInput);
                InputBinderForUpdate += new InputBinder(SVRActionInput);

                _leftHandAction.SetVRPlayerHandProperties(true);
                _rightHandAction.SetVRPlayerHandProperties(false);
            }
            else
            {
                InputBinderForUpdate += new InputBinder(KMPositionInput);
                InputBinderForUpdate += new InputBinder(KMRotationInput);
                InputBinderForUpdate += new InputBinder(KMActionInput);

                _leftHandAction.SetKMPlayerHandProperties(KMPlayerHandLenght, "Fire1", true);
                _rightHandAction.SetKMPlayerHandProperties(KMPlayerHandLenght, "Fire2", false);
            }
        }
    }
コード例 #7
0
 public void EnqueueAction(PlayerHandAction action)
 {
     actionsQueue.Enqueue(action);
 }