Esempio n. 1
0
        private void InitSensor()
        {
            GameObject obj;

            obj         = root.transform.Find(this.transform.name + "/" + this.parts.GetColorSensor()).gameObject;
            colorSensor = obj.GetComponentInChildren <Hakoniwa.Assets.IRobotColorSensor>();
            colorSensor.Initialize(obj);

            obj = root.transform.Find(this.transform.name + "/" + this.parts.getUltraSonicSensor()).gameObject;
            ultrasonicSensor = obj.GetComponentInChildren <Hakoniwa.Assets.IRobotUltraSonicSensor>();
            ultrasonicSensor.Initialize(obj);
        }
        private void InitSensor()
        {
            GameObject obj;
            string     subParts = this.parts.GetColorSensor();

            if (subParts != null)
            {
                obj         = root.transform.Find(this.transform.name + "/" + this.parts.GetColorSensor()).gameObject;
                colorSensor = obj.GetComponentInChildren <Hakoniwa.Assets.IRobotColorSensor>();
                colorSensor.Initialize(obj);
            }
            subParts = this.parts.getUltraSonicSensor();
            if (subParts != null)
            {
                obj = root.transform.Find(this.transform.name + "/" + this.parts.getUltraSonicSensor()).gameObject;
                ultrasonicSensor = obj.GetComponentInChildren <Hakoniwa.Assets.IRobotUltraSonicSensor>();
                ultrasonicSensor.Initialize(obj);
            }
            subParts = this.parts.getTouchSensor0();
            if (subParts != null)
            {
                obj          = root.transform.Find(this.transform.name + "/" + this.parts.getTouchSensor0()).gameObject;
                touchSensor0 = obj.GetComponentInChildren <Hakoniwa.Assets.IRobotTouchSensor>();
                touchSensor0.Initialize(obj);
            }
            subParts = this.parts.getTouchSensor1();
            if (subParts != null)
            {
                obj          = root.transform.Find(this.transform.name + "/" + this.parts.getTouchSensor1()).gameObject;
                touchSensor1 = obj.GetComponentInChildren <Hakoniwa.Assets.IRobotTouchSensor>();
                touchSensor1.Initialize(obj);
            }
            subParts = this.parts.getGyroSensor();
            if (subParts != null)
            {
                if (root.transform.Find(this.transform.name + "/" + this.parts.getGyroSensor()) != null)
                {
                    obj        = root.transform.Find(this.transform.name + "/" + this.parts.getGyroSensor()).gameObject;
                    gyroSensor = obj.GetComponentInChildren <Hakoniwa.Assets.IRobotGyroSensor>();
                    gyroSensor.Initialize(obj);
                }
            }
        }