Beispiel #1
0
    public void process(float segs)
    {
        if (possibleObject != null && allowToGrab && !objectInHand)
        {
            voObject       = possibleObject;
            possibleObject = null;
            StartCoroutine(setHand(false, segs));
            // hand.setDraw(false);
            objectInHand = true;
        }
        else if (voObject != null)
        {
            trackerMannager.fLeftTracker.detach();
            trackerMannager.fRightTracker.detach();
            possibleObject = voObject;
            voObject       = null;
            //hand.setDraw(true);

            StartCoroutine(setHand(true, segs));
            objectInHand = false;
            PropSpecs propSpecs = possibleObject.GetComponent <PropSpecs>();
            propSpecs.objectGrabbed(false);
            propSpecs.objectGreen(false);
        }
    }
Beispiel #2
0
    public void relocatePropDock()
    {
        PropSpecs propSpecs = currentEndObject.GetComponent <PropSpecs>();

        propSpecs.ghost.transform.parent        = transform;
        propSpecs.ghost.transform.localPosition = Vector3.zero;
    }
Beispiel #3
0
 private void OnTriggerExit(Collider other)
 {
     if (possibleObject != null)
     {
         PropSpecs propSpecs = possibleObject.GetComponent <PropSpecs>();
         propSpecs.objectGreen(false);
         propSpecs.objectGrabbed(false);
         possibleObject = null;
     }
 }
Beispiel #4
0
 private void OnTriggerEnter(Collider other)
 {
     if (allowToGrab && !objectInHand)
     {
         GameObject possibleObjectT = other.gameObject;
         PropSpecs  propSpecs       = possibleObjectT.GetComponent <PropSpecs>();
         if (propSpecs != null && !propSpecs.grabbed)
         {
             propSpecs.objectGrabbed(true);
             propSpecs.objectGreen(true);
             possibleObject = possibleObjectT;
         }
     }
 }
Beispiel #5
0
    public void movePropDock(bool toHomePoint, Quaternion nOrientation)
    {
        PropSpecs  propSpecs = currentEndObject.GetComponent <PropSpecs>();
        GameObject dockProp  = propSpecs.ghost;

        //if (dockProp.GetComponent<PhotonView>().owner.ID != PhotonNetwork.player.ID)
        //dockProp.GetComponent<PhotonView>().TransferOwnership(PhotonNetwork.player.ID);
        if (toHomePoint)
        {
            dockProp.transform.parent        = homePositions[currentPlayer].transform.parent.transform;
            dockProp.transform.localPosition = new Vector3(0.0f, 0f, 0.0f);
            dockProp.transform.rotation      = nOrientation;
        }
        else
        {
            dockProp.transform.rotation = nOrientation;
            dockProp.transform.Rotate(new Vector3(0f, 180f, 0));
            dockProp.transform.parent        = currentEndPosition.transform;
            dockProp.transform.localPosition = Vector3.zero;
        }
    }
Beispiel #6
0
    public void setActiveGhost(bool active)
    {
        PropSpecs propSpecs = currentEndObject.GetComponent <PropSpecs>();

        propSpecs.ghost.SetActive(active);
    }
Beispiel #7
0
    public void refreshPlayerProp()
    {
        PropSpecs propSpecs = currentEndObject.GetComponent <PropSpecs>();

        playerMasters[(currentPlayer + 1) % 2].presetPtop(propSpecs.type);
    }
Beispiel #8
0
    public bool conditionsToProceed(int stage)
    {
        bool answer = true;

        if (stage == 0)     // The hand must be touchin point zero;
        {
            NewGoal newGoal = homePosition.GetComponent <NewGoal>();
            answer = newGoal.handOnInitialPosition;
            if (!answer)
            {
                //personalNotifications.messageToUser("Be sure your hand is on the sphere");
                personalNotifications.messageToUser("La mano en la esfera");
            }
        }
        else if (stage == 1)
        {
            answer = (handLogic.possibleObject != null);     // Implicit threshold lies in the size of both hand and objects
            if (!answer)
            {
                //personalNotifications.messageToUser("Be sure your hands is on the object. \n Do not move it");
                personalNotifications.messageToUser("La mano sobre el objeto");
            }
        }
        else if (stage == 2)
        {
            float     threshold = 0.02f;
            PropSpecs propSpecs = currentEndObject.GetComponent <PropSpecs>();
            answer = propSpecs.distanceToDock() < threshold;
            if (!answer)
            {
                //notificationsMannager.messageToUser(@"It seems you are not in the final position");
                personalNotifications.messageToUser("Que coincida el objeto y el fantasma");
            }
        }
        else if (stage == 3)
        {
            NewGoal newGoal = homePosition2.GetComponent <NewGoal>();
            answer = newGoal.handOnInitialPosition;
            if (!answer)
            {
                //notificationsMannager.messageToUser(@"It seems you are not in the final position");
                personalNotifications.messageToUser("La mano sobre la esfera");
            }
        }
        else if (stage == 4)
        {
            answer = (handLogic.possibleObject != null);
            if (!answer)
            {
                //notificationsMannager.messageToUser("Be sure your hand is on the sphere");
                personalNotifications.messageToUser("La mano sobre el objeto");
            }
        }
        else if (stage == 5)
        {
            float     threshold = 0.02f;
            PropSpecs propSpecs = currentEndObject.GetComponent <PropSpecs>();
            answer = propSpecs.distanceToDock() < threshold;
            if (!answer)
            {
                //notificationsMannager.messageToUser("Be sure your hand is on the sphere");
                personalNotifications.messageToUser("Que coincida el objeto y el fantasma");
            }
        }
        else if (stage == 0)    // The hand must be touchin point zero;
        {
            NewGoal newGoal = homePosition.GetComponent <NewGoal>();
            answer = newGoal.handOnInitialPosition;
            if (!answer)
            {
                //personalNotifications.messageToUser("Be sure your hand is on the sphere");
                personalNotifications.messageToUser("La mano en la esfera");
            }
        }

        return(answer || testCond);
    }
Beispiel #9
0
    // All movements are isolated from the other user. TODO review this in order to male it more collaborative
    // The movement starts with the hand on the home point. This could be sync with the realease movement of the othe user
    // Once the hand is on the homepoint and trigger is pressed, the user can grabthe object. TODO // Some visual feedback to
    //              make clear that the user can proceed to grab the object. Why? In this case the user wills e the object all the time
    //              but the begining iof the movement must to be set to apply the retargetting correctly
    // The user grab the object and press the trigger
    // The ghost appears and the users must make it match and press the triggger. In this case the trigger must be placed on te table,not elevated.
    // The user releases the object and place his hand on this right in a home point, in the mean while the object changes (or not ) its shape
    // The user grab the object again
    // The user releases the the object and the other participant starts. (think if pressing the trigger is o r not neccesary)
    public void reGoal()
    {
        if (conditionsToProceed(stage))
        {
            //Pre There is nothing // Maybe we can skup this part. Make it sync with the other user ending
            //Post Homeposition sphere activated
            if (stage == -1)
            {
                //fillPlayerInformation(); TODO fill player information at the begining of one set of trials

                logicGame.GetComponent <PhotonView>().RPC("enableHomePoint", PhotonTargets.All, idPlayer, true, false);
                //homePosition.SetActive(true);
                currentEndObject   = logicGame.currentEndObject;
                currentEndPosition = logicGame.currentEndPosition;
                if (currentEndObject.GetComponent <PhotonView>().ownerId != PhotonNetwork.player.ID)
                {
                    currentEndObject.GetComponent <PhotonView>().TransferOwnership(PhotonNetwork.player.ID);
                    PropSpecs spcs = currentEndObject.GetComponent <PropSpecs>();
                    if (spcs.ghost.GetComponent <PhotonView>().ownerId != PhotonNetwork.player.ID)
                    {
                        spcs.ghost.GetComponent <PhotonView>().TransferOwnership(PhotonNetwork.player.ID);
                    }
                }
                stage = 0;
            }
            //Pre Hand on home position.
            //Post Home position desactivated. Object allowed to be grabbed in end position
            else if (stage == 0)
            {
                targetedController.disableRT = false;

                targetedController.starShifting(currentEndPosition.transform.position, hand.giveRealPosition());

                //currentEndObject.GetComponent<PropSpecs>().activeChildren(false);

                //targetedController.starShifting(currentEndPosition.transform.position, hand.giveRealPosition());

                currentEndObject.transform.position = currentEndPosition.transform.position;
                StartCoroutine(transformProp());
                logicGame.GetComponent <PhotonView>().RPC("enableHomePoint", PhotonTargets.All, idPlayer, false, false);

                persistanceManager.startDocking(stage);

                stage = 1;
            }
            // Pre the user´s hand on object
            // Post hand hiden, object green and allowed to manipulate. Ghost on home position in radom orientation
            else if (stage == 1)     // Hand in object Maybe should check the coliders are overlapped. Pre No shadow in scene. Pos shadow in point Z
            {
                persistanceManager.tracker       = currentTracker;
                persistanceManager.trackedObject = currentEndObject.GetComponent <PropSpecs>();
                persistanceManager.saveDocking();

                if (masterController.condition == MasterController.CONDITION.NM_RT ||
                    masterController.condition == MasterController.CONDITION.SM_RT)
                {
                    currentEndObject.transform.position = targetedController.retargetedPosition.transform.position;
                }
                else
                {
                    currentEndObject.transform.position = currentEndPosition.transform.position;
                }
                currentEndObject.GetComponent <PropSpecs>().resetProp(true);
                pairTracker(true);
                handLogic.process(0f); logicGame.GetComponent <PhotonView>().RPC("setActiveGhost", PhotonTargets.All, true);

                Quaternion orientationPlayerC;

                // this is normal
                //Quaternion orientationPlayerC = orientationsPlayer.Dequeue();
                // this isfull orientation
                int posObj  = currentEndObject.GetComponent <PropSpecs>().idProp;
                int posSpot = currentEndPosition.GetComponent <SpotSide>().idSoptSide;
                orientationPlayerC = orientationsPlayerMatrix[posObj, posSpot].Dequeue();

                logicGame.GetComponent <PhotonView>().RPC("movePropDock", PhotonTargets.All, true, homePosition.transform.rotation * orientationPlayerC);
                //movePropDock(true);// TODO maybe add some animation to make the "transformation between objects"

                // persistanceManager.saveDocking();
                // persistanceManager.startDocking(stage);

                persistanceManager.startDocking(stage);

                stage = 2;
            }
            // Pre object on ghost in a correct orientation and position
            // Pos Hand appears, Objet released, HP appears on the rigth side.
            else if (stage == 2)
            {
                persistanceManager.tracker       = currentTracker;
                persistanceManager.trackedObject = currentEndObject.GetComponent <PropSpecs>();
                persistanceManager.saveDocking();
                // bool isLeft = idPlayer == 0 ;

                handLogic.process(0f);
                targetedController.disableRT        = true;
                currentEndObject.transform.rotation = currentEndObject.GetComponent <PropSpecs>().ghost.transform.rotation;
                currentEndObject.transform.position = currentEndObject.GetComponent <PropSpecs>().ghost.transform.position;
                logicGame.GetComponent <PhotonView>().RPC("setActiveGhost", PhotonTargets.All, false);
                logicGame.GetComponent <PhotonView>().RPC("relocatePropDock", PhotonTargets.All);
                handLogic.allowToGrab = false;
                logicGame.GetComponent <PhotonView>().RPC("enableHomePoint", PhotonTargets.All, idPlayer, true, true);
                //persistanceManager.saveDocking();
                //propContr.movePropDock(false);
                persistanceManager.startDocking(stage);
                stage = 3;
            }
            // Pre hand on HP2
            // Pos Object transformed, HP2 Hidden
            else if (stage == 3)     // Object moved to initial position in desired orientation. Pre. Shadow on, initial status off. Pos Shadow off, initial position on
            {
                persistanceManager.tracker       = currentTracker;
                persistanceManager.trackedObject = currentEndObject.GetComponent <PropSpecs>();
                persistanceManager.saveDocking();
                Quaternion lastOrientation = currentEndObject.transform.rotation;
                Debug.Log("Last end orientation " + lastOrientation);
                logicGame.GetComponent <PhotonView>().RPC("enableHomePoint", PhotonTargets.All, idPlayer, false, true);
                //TODO Animation for transform the object
                currentEndObject.SetActive(false);
                currentScenario    = scenariosPlayer.Dequeue();
                currentEndObject   = objects[currentScenario[0]];
                currentEndPosition = positions[currentScenario[1]];
                logicGame.GetComponent <PhotonView>().RPC("refreshObjectAndPosition", PhotonTargets.All, currentScenario[0], currentScenario[1]);
                //logicGame.GetComponent<PhotonView>().RPC("refreshOtherPlayerProp", PhotonTargets.All, currentScenario[0], currentScenario[1]);
                if (currentEndObject.GetComponent <PhotonView>().ownerId != PhotonNetwork.player.ID)
                {
                    currentEndObject.GetComponent <PhotonView>().TransferOwnership(PhotonNetwork.player.ID);
                    PropSpecs spcs = currentEndObject.GetComponent <PropSpecs>();
                    if (spcs.ghost.GetComponent <PhotonView>().ownerId != PhotonNetwork.player.ID)
                    {
                        spcs.ghost.GetComponent <PhotonView>().TransferOwnership(PhotonNetwork.player.ID);
                    }
                }

                StartCoroutine(transformProp());
                currentEndObject.transform.position = homePosition.transform.position;
                currentEndObject.transform.rotation = lastOrientation;
                currentEndObject.GetComponent <PropSpecs>().resetProp(true);
                currentEndObject.transform.Rotate(new Vector3(0f, 180f, 0f));


                Debug.Log("Orientation before pairing " + currentEndObject.transform.rotation);
                currentEndObject.transform.GetChild(0).gameObject.SetActive(false);
                currentEndObject.SetActive(true);
                currentEndObject.transform.GetChild(0).gameObject.SetActive(false);
                handLogic.allowToGrab = true;


                persistanceManager.startDocking(stage);
                stage = 4;
            }
            // Pre, hand on object
            // Pos hand dissapears and object in moving mood.
            else if (stage == 4)
            {
                persistanceManager.tracker       = currentTracker;
                persistanceManager.trackedObject = currentEndObject.GetComponent <PropSpecs>();
                persistanceManager.saveDocking();
                pairTracker(false);
                targetedController.disableRT = false;
                handLogic.process(0f);
                //targetedController.starShifting(currentEndPosition.transform.position, currentEndObject.transform.position);
                targetedController.starShifting(currentEndPosition.transform.position, currentEndObject.transform.parent.transform.position);
                logicGame.GetComponent <PhotonView>().RPC("setActiveGhost", PhotonTargets.All, true);
                Quaternion neutral = homePosition.transform.rotation;

                logicGame.GetComponent <PhotonView>().RPC("movePropDock", PhotonTargets.All, false, homePosition.transform.rotation);
                //currentTracker.objectTracked = currentEndObject;
                //currentEndObject.SetActive(true);
                //homePosition.SetActive(false);
                //Vector3 po = homePosition.transform.position;
                //homePosition.transform.position = new Vector3(po.x - 0.15f, po.y, po.z);
                persistanceManager.startDocking(stage);
                stage = 5;
            }
            // Pre object on end position
            // Pos end. hand appears
            else if (stage == 5)
            {
                persistanceManager.tracker       = currentTracker;
                persistanceManager.trackedObject = currentEndObject.GetComponent <PropSpecs>();
                persistanceManager.saveDocking();
                handLogic.process(3f);
                PropSpecs propSpecs = currentEndObject.GetComponent <PropSpecs>();
                currentEndObject.transform.rotation = propSpecs.ghost.transform.rotation;
                currentEndObject.transform.position = propSpecs.ghost.transform.position;
                propSpecs.ghost.SetActive(false);
                logicGame.GetComponent <PhotonView>().RPC("relocatePropDock", PhotonTargets.All);
                propSpecs.resetProp(false);
                onTurn = false;
                logicGame.GetComponent <PhotonView>().RPC("nextStep", PhotonTargets.All);
                stage = -1;                          // put here 6 to fix the problem with  the issue RT
                targetedController.disableRT = true; // and delete this
                                                     // and add   logicGame.GetComponent<PhotonView>().RPC("enableHomePoint", PhotonTargets.All, idPlayer, true, false);
            }
            else if (stage == 6)
            {
                logicGame.GetComponent <PhotonView>().RPC("enableHomePoint", PhotonTargets.All, idPlayer, false, false);
                stage = -1;
                targetedController.disableRT = true;
            }
            if (stage != -1)
            {
                notificationsMannager.lightStepNotification(stage + 1);
            }
        }
    }