コード例 #1
0
        public IEnumerator UpdatePlacementStatus(MonoBehaviour moderator)
        {
            if (this.destination.tag == TagModerator)
            {
                this.isPlacementSucceeded = this.IsDeliverySucceeded(moderator.transform.root);
            }
            else
            {
                if (this.graspingTarget.transform.root == this.robot.transform.root)
                {
                    this.isPlacementSucceeded = false;

                    SIGVerseLogger.Info("Target placement failed: HSR has the grasping target.");
                }
                else
                {
                    PlacementChecker placementChecker = this.destination.GetComponentInChildren <PlacementChecker>();

                    IEnumerator <bool?> isPlaced = placementChecker.IsPlaced(this.graspingTarget);

                    yield return(moderator.StartCoroutine(isPlaced));

                    this.isPlacementSucceeded = (bool)isPlaced.Current;
                }
            }
        }
コード例 #2
0
        private void AddPlacementChecker(GameObject destination)
        {
            // Add Placement checker to triggers
            Transform judgeTriggerOn = destination.transform.Find(JudgeTriggerNameOn);
            Transform judgeTriggerIn = destination.transform.Find(JudgeTriggerNameIn);

            if (judgeTriggerOn == null && judgeTriggerIn == null)
            {
                throw new Exception("No JudgeTrigger. name=" + destination.name);
            }
            if (judgeTriggerOn != null && judgeTriggerIn != null)
            {
                throw new Exception("Too many JudgeTrigger. name=" + destination.name);
            }

            if (judgeTriggerOn != null)
            {
                PlacementChecker placementChecker = judgeTriggerOn.gameObject.AddComponent <PlacementChecker>();
                placementChecker.Initialize(PlacementChecker.JudgeType.On);
            }
            if (judgeTriggerIn != null)
            {
                PlacementChecker placementChecker = judgeTriggerIn.gameObject.AddComponent <PlacementChecker>();
                placementChecker.Initialize(PlacementChecker.JudgeType.In);
            }
        }
コード例 #3
0
    private void Start()
    {
        ufo     = GameObject.Find("UFO").transform;
        checker = GameObject.Find("PlacementChecker").GetComponent <PlacementChecker>();

        offset            = transform.position - ufo.position;
        original_position = transform.position;
    }
コード例 #4
0
    private void Start()
    {
        init_vel = velocity;

        checker = GameObject.Find("PlacementChecker").GetComponent <PlacementChecker>();

        source = GetComponent <AudioSource>();

        // Spawn first block
        Instantiate(HandoffNextBlock(GetComponent <BlockQueue>().GetNextBlock()), transform);
    }
コード例 #5
0
    private void Start()
    {
        source = GetComponent <AudioSource>();

        cam_shake = Camera.main.GetComponent <CameraShake>();

        checker = GameObject.Find("PlacementChecker").GetComponent <PlacementChecker>();

        if (SceneManager.GetActiveScene().name == "GoldenGate")
        {
            current_ground_sound = water_sound;
        }
        else
        {
            current_ground_sound = ground_sound;
        }
    }
コード例 #6
0
    void Awake()
    {
        camTransform = GetComponent(typeof(Transform)) as Transform;

        checker = GameObject.Find("PlacementChecker").GetComponent <PlacementChecker>();
    }
        private void Initialize(EnvironmentInfo environmentInfo, HandymanScoreManager scoreManager, AudioSource objectCollisionAudioSource)
        {
            List <GameObject> objectCollisionDestinations = new List <GameObject>();

            objectCollisionDestinations.Add(scoreManager.gameObject);
            objectCollisionDestinations.Add(this.playbackRecorder.gameObject);

            foreach (GameObject graspable in this.graspables)
            {
                CollisionTransferer collisionTransferer = graspable.AddComponent <CollisionTransferer>();

                collisionTransferer.Initialize(objectCollisionDestinations, Score.GetObjectCollisionVeloticyThreshold(), 0.1f, objectCollisionAudioSource);
            }


            Dictionary <RelocatableObjectInfo, GameObject> graspablesPositionMap    = null;            //key:GraspablePositionInfo,   value:Graspables
            Dictionary <RelocatableObjectInfo, GameObject> destinationsPositionsMap = null;            //key:DestinationPositionInfo, value:DestinationCandidate

            if (HandymanConfig.Instance.configFileInfo.isGraspableObjectsPositionRandom)
            {
                this.graspingTarget = this.DecideGraspingTarget();
                this.destination    = this.DecideDestination();

                graspablesPositionMap    = this.CreateGraspablesPositionMap();
                destinationsPositionsMap = this.CreateDestinationsPositionsMap();
            }
            else
            {
                this.DeactivateGraspingCandidatesPositions();

                this.graspingTarget = (from graspable in this.graspables where graspable.name == environmentInfo.graspingTargetName select graspable).First();

                if (this.graspingTarget == null)
                {
                    throw new Exception("Grasping target not found. name=" + environmentInfo.graspingTargetName);
                }

                graspablesPositionMap = new Dictionary <RelocatableObjectInfo, GameObject>();

                foreach (RelocatableObjectInfo graspablePositionInfo in environmentInfo.graspablesPositions)
                {
                    GameObject graspableObj = (from graspable in this.graspables where graspable.name == graspablePositionInfo.name select graspable).First();

                    if (graspableObj == null)
                    {
                        throw new Exception("Graspable object not found. name=" + graspablePositionInfo.name);
                    }

                    graspablesPositionMap.Add(graspablePositionInfo, graspableObj);
                }


                // Destination object
                this.destination = (from destinationCandidate in this.destinationCandidates where destinationCandidate.name == environmentInfo.destinationName select destinationCandidate).First();

                if (this.destination == null)
                {
                    throw new Exception("Destination not found. name=" + environmentInfo.destinationName);
                }

                // Destination candidates position map
                destinationsPositionsMap = new Dictionary <RelocatableObjectInfo, GameObject>();

                foreach (RelocatableObjectInfo destinationPositionInfo in environmentInfo.destinationsPositions)
                {
                    GameObject destinationObj = (from destinationCandidate in this.destinationCandidates where destinationCandidate.name == destinationPositionInfo.name select destinationCandidate).First();

                    if (destinationObj == null)
                    {
                        throw new Exception("Destination candidate not found. name=" + destinationPositionInfo.name);
                    }

                    destinationsPositionsMap.Add(destinationPositionInfo, destinationObj);
                }
            }


            if (this.destination.tag != TagModerator)
            {
                // Add Placement checker to triggers
                Transform judgeTriggerOn = this.destination.transform.Find(JudgeTriggerNameOn);
                Transform judgeTriggerIn = this.destination.transform.Find(JudgeTriggerNameIn);

                if (judgeTriggerOn == null && judgeTriggerIn == null)
                {
                    throw new Exception("No JudgeTrigger. name=" + this.destination.name);
                }
                if (judgeTriggerOn != null && judgeTriggerIn != null)
                {
                    throw new Exception("Too many JudgeTrigger. name=" + this.destination.name);
                }

                if (judgeTriggerOn != null)
                {
                    PlacementChecker placementChecker = judgeTriggerOn.gameObject.AddComponent <PlacementChecker>();
                    placementChecker.Initialize(PlacementChecker.JudgeType.On);
                }
                if (judgeTriggerIn != null)
                {
                    PlacementChecker placementChecker = judgeTriggerIn.gameObject.AddComponent <PlacementChecker>();
                    placementChecker.Initialize(PlacementChecker.JudgeType.In);
                }
            }


            foreach (KeyValuePair <RelocatableObjectInfo, GameObject> pair in graspablesPositionMap)
            {
                pair.Value.transform.position    = pair.Key.position;
                pair.Value.transform.eulerAngles = pair.Key.eulerAngles;

//				Debug.Log(pair.Key.name + " : " + pair.Value.name);
            }

            foreach (KeyValuePair <RelocatableObjectInfo, GameObject> pair in destinationsPositionsMap)
            {
                pair.Value.transform.position    = pair.Key.position;
                pair.Value.transform.eulerAngles = pair.Key.eulerAngles;

//				Debug.Log(pair.Key.name + " : " + pair.Value.name);
            }

            this.targetRoom = this.GetTargetRoom();

            if (HandymanConfig.Instance.configFileInfo.isGraspableObjectsPositionRandom)
            {
                this.taskMessage           = this.CreateTaskMessage();
                this.correctedTaskMessage  = string.Empty;
                this.isEnvironmentNameSent = true;
            }
            else
            {
                this.taskMessage          = environmentInfo.taskMessage;
                this.correctedTaskMessage = environmentInfo.correctedTaskMessage;

                this.isEnvironmentNameSent = environmentInfo.isEnvironmentNameSent;
            }


            if (HandymanConfig.Instance.configFileInfo.isGraspableObjectsPositionRandom)
            {
                SaveEnvironmentInfo(this.taskMessage, this.correctedTaskMessage, this.environmentName, this.isEnvironmentNameSent, this.graspingTarget.name, this.destination.name, graspablesPositionMap, destinationsPositionsMap);
            }

            this.rosConnections = SIGVerseUtils.FindObjectsOfInterface <IRosConnection>();

            SIGVerseLogger.Info("ROS connection : count=" + this.rosConnections.Length);


            // Set up the voice (Using External executable file)
            this.speechProcess = new System.Diagnostics.Process();
            this.speechProcess.StartInfo.FileName       = Application.dataPath + "/" + SpeechExePath;
            this.speechProcess.StartInfo.CreateNoWindow = true;
            this.speechProcess.StartInfo.WindowStyle    = System.Diagnostics.ProcessWindowStyle.Hidden;

            this.isSpeechUsed = System.IO.File.Exists(this.speechProcess.StartInfo.FileName);

            this.speechInfoQue = new Queue <SpeechInfo>();

            SIGVerseLogger.Info("Text-To-Speech: " + Application.dataPath + "/" + SpeechExePath);


            this.isPlacementSucceeded = null;
        }
コード例 #8
0
 private void Awake()
 {
     instance = this;
 }