Beispiel #1
0
//		public bool go = false;

        void Awake()
        {
            // Get the robot
            this.robot = GameObject.FindGameObjectWithTag(TagRobot);


            // Get the graspables
            this.graspables = GameObject.FindGameObjectsWithTag(TagGraspables).ToList <GameObject>();

            if (graspables.Count == 0)
            {
                throw new Exception("Count of Graspables is zero.");
            }

            // Check the name conflict of graspables.
            if (this.graspables.Count != (from graspable in this.graspables select graspable.name).Distinct().Count())
            {
                throw new Exception("There is the name conflict of graspable objects.");
            }

            SIGVerseLogger.Info("Count of Graspables = " + this.graspables.Count);


            // Get the destination candidates
            this.destinationCandidates = GameObject.FindGameObjectsWithTag(TagDestinationCandidates).ToList <GameObject>();

            if (this.destinationCandidates.Count == 0)
            {
                throw new Exception("Count of DestinationCandidates is zero.");
            }

            // Check the name conflict of destination candidates.
            if (this.destinationCandidates.Count != (from destinations in this.destinationCandidates select destinations.name).Distinct().Count())
            {
                throw new Exception("There is the name conflict of destination candidates objects.");
            }

            SIGVerseLogger.Info("Count of DestinationCandidates = " + this.destinationCandidates.Count);


            this.graspingTarget = this.graspables           [UnityEngine.Random.Range(0, this.graspables.Count)];
            this.destination    = this.destinationCandidates[UnityEngine.Random.Range(0, this.destinationCandidates.Count)];

            SIGVerseLogger.Info("Grasping target is " + graspingTarget.name);
            SIGVerseLogger.Info("Destination is " + destination.name);

            this.graspingTargetRigidbody = this.graspingTarget.GetComponentInChildren <Rigidbody>();

            this.avatarLeftHandController  = this.GetComponentsInChildren <CleanupAvatarVRHandController>().Where(item => item.handType == CleanupAvatarVRHandController.HandType.LeftHand).First();
            this.avatarRightHandController = this.GetComponentsInChildren <CleanupAvatarVRHandController>().Where(item => item.handType == CleanupAvatarVRHandController.HandType.RightHand).First();

            this.avatarHandController = this.avatarLeftHandController;             // Set default

            this.stepTimer = new StepTimer();
        }
Beispiel #2
0
        // Update is called once per frame
        void Update()
        {
            //if (this.go)
            //{
            //	this.receivedMessageMap[MsgPointIt] = true;

            //	this.go = false;
            //}

            if (this.receivedMessageMap[MsgTellMe])
            {
                StartCoroutine(this.SendMessage(this.taskMessage, 0.0f));

                this.receivedMessageMap[MsgTellMe] = false;
            }

            if (this.receivedMessageMap[MsgPointIt])
            {
                switch (this.pointingStep)
                {
                case PointingStep.PointTarget:
                {
                    if (UnityEngine.Random.Range(0, 2) == 0)
                    {
                        // Left Hand
                        this.avatarHandController = this.avatarLeftHandController;
                    }
                    else
                    {
                        // Right Hand
                        this.avatarHandController = this.avatarRightHandController;
                    }

                    this.avatarHandController.PointTarget(this.graspingTarget);

                    this.pointingStep++;
                    break;
                }

                case PointingStep.WaitForPointingTarget:
                {
                    if (this.avatarHandController.IsWaiting())
                    {
                        this.pointingStep++;
                    }

                    break;
                }

                case PointingStep.Stay1:
                {
                    if (this.stepTimer.IsTimePassed((int)this.pointingStep, 3000))
                    {
                        this.pointingStep++;
                    }
                    break;
                }

                case PointingStep.SpeechPickItUp:
                {
                    StartCoroutine(this.SendMessage(MsgPickItUp, 0.0f));
                    this.pointingStep++;

                    break;
                }

                case PointingStep.Stay2:
                {
                    if (this.stepTimer.IsTimePassed((int)this.pointingStep, 3000))
                    {
                        this.pointingStep++;
                    }
                    break;
                }

                case PointingStep.PointDestination:
                {
                    this.avatarHandController.PointDestination(this.destination);

                    this.pointingStep++;
                    break;
                }

                case PointingStep.WaitForPointingDestination:
                {
                    if (this.avatarHandController.IsWaiting())
                    {
                        this.pointingStep++;
                    }

                    break;
                }

                case PointingStep.Stay3:
                {
                    if (this.stepTimer.IsTimePassed((int)this.pointingStep, 3000))
                    {
                        this.pointingStep++;
                    }
                    break;
                }

                case PointingStep.SpeechCleanUp:
                {
                    StartCoroutine(this.SendMessage(MsgCleanUp, 0.0f));
                    this.pointingStep++;

                    break;
                }

                case PointingStep.Stay4:
                {
                    if (this.stepTimer.IsTimePassed((int)this.pointingStep, 3000))
                    {
                        this.pointingStep++;
                    }
                    break;
                }

                case PointingStep.Return:
                {
                    this.avatarHandController.Return();

                    this.pointingStep++;
                    break;
                }

                case PointingStep.WaitForReturn:
                {
                    if (this.avatarHandController.IsWaiting())
                    {
                        this.avatarHandController.Wait();

                        this.pointingStep = PointingStep.PointTarget;

                        this.receivedMessageMap[MsgPointIt] = false;
                    }
                    break;
                }
                }
            }
        }