Example #1
0
    // Use this for initialization
    void Start()
    {
        disable_display_coroutine = disableDisplay();
        GameObject GameControllerObject = GameObject.FindWithTag("GameController");

//		if (GameControllerObject != null) {
//			SendVibrationSignalController = GameControllerObject.GetComponent<SendVibrationSignal> ();
//		} else {
//			Debug.Log ("DetectCollision: Can not find SendVibrationSignal!");
//		}

        if (GameControllerObject != null)
        {
            OutputSystemController = GameControllerObject.GetComponent <OutputSystem> ();
        }
        else
        {
            Debug.Log("DetectCollision: Can not find OutputSystem!");
        }

//		GameObject OSCDataSenderObject = GameObject.FindWithTag ("OSCDataSender");
//		if (OSCDataSenderObject != null) {
//			OSCDataSenderController = OSCDataSenderObject.GetComponent<OscDataSender> ();
//		}

        GameObject soundManagerControllerObject = GameObject.FindWithTag("SoundManager");

        if (soundManagerControllerObject != null)
        {
            soundManagerController = soundManagerControllerObject.GetComponent <SoundManager> ();
        }
        else
        {
            Debug.Log("GameController: Can not find SoundManager!");
        }

//		GameObject OSCDataSenderObject = GameObject.FindWithTag ("OSCDataSender");
//		if (OSCDataSenderObject != null) {
//			OSCDataSenderController = OSCDataSenderObject.GetComponent<OscDataSender> ();
//		}

        GameObject gameControllerObject = GameObject.FindWithTag("GameController");

        if (gameControllerObject != null)
        {
            gameController = gameControllerObject.GetComponent <GameController> ();
        }

        for (int i = 0; i < flangeNutNum; i++)
        {
            flangeNutObjects [i] = GameObject.FindWithTag(flangeNutTags [i]);
        }

        wrenchFittingObject = GameObject.FindWithTag("WrenchFitting");
    }
Example #2
0
        static void Main(string[] args)
        {
            Stopwatch sw = Stopwatch.StartNew();

            Engine engine = new Engine();

            engine.DefineComponent <Components.Debug>();
            engine.DefineComponent <Targetable>();
            engine.DefineComponent <Room>();
            engine.DefineComponent <Present>();
            engine.DefineComponent <Containable>();
            engine.DefineComponent <Notable>();
            engine.DefineComponent <Openable>();
            engine.DefineComponent <Container>();

            var output = new OutputSystem();

            engine.AddSystem(output);
            var targetingSystem = new TargetingSystem();

            engine.AddSystem(targetingSystem);
            engine.AddSystem(new SightSystem());
            var interpreter = new InterpreterSystem();

            engine.AddSystem(interpreter);
            engine.AddSystem(new DebuggingSystem());
            engine.AddSystem(new RoomSystem());
            engine.AddSystem(new PlayerSystem());
            engine.AddSystem(new LabelSystem());
            engine.AddSystem(new ContainmentSystem());
            engine.AddSystem(new OpenableSystem());

            var roomId = engine.CreateEntity();

            engine.AddComponentToEntity(roomId, new Room {
                Title = "Zoop", Description = "It's Zoop!"
            });

            var newEntityIdentifier = engine.CreateEntity();

            engine.AddComponentToEntity(newEntityIdentifier, new Components.Debug {
                Label = "Wenceslaus"
            });
            engine.AddComponentToEntity(newEntityIdentifier, new Targetable("Wenceslaus", new[] { "Jingle", "Punished" }));
            engine.AddComponentToEntity(newEntityIdentifier, new Present {
                RoomEntityId = roomId
            });

            newEntityIdentifier = engine.CreateEntity();
            engine.AddComponentToEntity(newEntityIdentifier, new Components.Debug {
                Label = "The Juice"
            });
            engine.AddComponentToEntity(newEntityIdentifier, new Targetable("Juice", new[] { "Tasty", "Orange" }));
            engine.AddComponentToEntity(newEntityIdentifier, new Present {
                RoomEntityId = roomId
            });

            newEntityIdentifier = engine.CreateEntity();
            engine.AddComponentToEntity(newEntityIdentifier, new Components.Debug {
                Label = "The Other Juice"
            });
            engine.AddComponentToEntity(newEntityIdentifier, new Targetable("Apple Juice", new[] { "Spoiled" }));
            engine.AddComponentToEntity(newEntityIdentifier, new Present {
                RoomEntityId = roomId
            });

            newEntityIdentifier = engine.CreateEntity();
            engine.AddComponentToEntity(newEntityIdentifier, new Components.Debug {
                Label = "Crate"
            });
            engine.AddComponentToEntity(newEntityIdentifier, new Targetable("Crate"));
            engine.AddComponentToEntity(newEntityIdentifier, new Present {
                RoomEntityId = roomId
            });
            engine.AddComponentToEntity(newEntityIdentifier, new Openable {
                IsOpen = false, IsLocked = false
            });

            //interpreter.Register(new TestAction(newEntityIdentifier));

            bool done = false;

            while (!done)
            {
                Console.WriteLine(output.Print());
                Console.Write("> ");
                var input = Console.ReadLine();

                if (input == "quit")
                {
                    done = true;
                }
                else
                {
                    interpreter.HandleUserInput(input);
                }
            }
        }
Example #3
0
    // Use this for initialization
    void Start()
    {
//		Debug.Log ("Newly start!");
        //		setMoverioController ();

        GameObject wrenchFittingObject = GameObject.FindWithTag("WrenchFitting");

        if (wrenchFittingObject != null)
        {
            wireframe_renderer = wrenchFittingObject.GetComponent <MeshRenderer> ();
        }

        standard_shader  = Shader.Find("Standard");
        wireframe_shader = Shader.Find("Digicrafts/Wireframe/Unlit/Transparent Cutout");


        start_vibration_coroutine = startVibration();
        stop_vibration_coroutine  = stopVibration();

        if (haptic)
        {
            hapticFeedback = true;
        }
        else
        {
            hapticFeedback = false;
        }

        time_record [2 * (round_index - 1)] = System.DateTime.Now;
//		Debug.Log (System.DateTime.Now);


        Debug.Log("round_index: " + round_index);

        OscDataReceiver.Instance.setChangeSmoothPos(changeSmoothPos);

//		GameObject drillCombinationObject = GameObject.FindWithTag ("DrillCombination");
//		if (drillCombinationObject != null) {
//			drillCombinationController_placementAroundACircle = drillCombinationObject.GetComponent<PlacementAroundACircle> ();
//			drillCombinationController_placementAroundACircle.setRadius (radius);
//
//			drillCombinationController_simplePositionMovement = drillCombinationObject.GetComponent<SimplePositionMovement> ();
//			drillCombinationController_simplePositionMovement.setReference (localReference);
//		} else {
//			if (openOutput) {
//				Debug.Log ("GameController: can not find drillCombinationController_circle");
//			}
//		}

        GameObject handleObject = GameObject.FindWithTag("Handle");

        if (handleObject != null)
        {
            handleController_simplePositionMovement = handleObject.GetComponent <SimplePositionMovement> ();
            handleController_simplePositionMovement.setReference(localReference);
        }
        else
        {
            if (openOutput)
            {
                Debug.Log("GameController: can not find handleController_simplePositionMovement");
            }
        }

        GameObject triggerObject = GameObject.FindWithTag("Trigger");

        if (triggerObject != null)
        {
            triggerController = triggerObject.GetComponent <TwoAngleRotation> ();

            triggerController.setRotationSpeed(triggerRotationSpeed);
            triggerController.setRotationDiff(triggerRotationDiff);
            triggerController.setRotationAxis(triggerRotationAxis);
        }
        else
        {
            if (openOutput)
            {
                Debug.Log("GameController: can not find triggerController");
            }
        }

        GameObject rotationTriggerObject = GameObject.FindWithTag("RotationTrigger");

        if (rotationTriggerObject != null)
        {
            rotationTriggerController = rotationTriggerObject.GetComponent <TwoPointsMovement> ();

            rotationTriggerController.setMovementSpeed(rotationTriggerMovementSpeed);
            rotationTriggerController.setPosDiff(rotationTriggerPosDiff);
        }
        else
        {
            if (openOutput)
            {
                Debug.Log("GameController: can not find rotationTriggerController");
            }
        }

        GameObject airRegulatorObject = GameObject.FindWithTag("AirRegulator");

        if (airRegulatorObject != null)
        {
            airRegulatorController = airRegulatorObject.GetComponent <FixedAngleRotation> ();

            airRegulatorController.setRotationSpeed(airRegulatorRotationSpeed);
            airRegulatorController.setRotationDiff(airRegulatorRotationDiff);
            airRegulatorController.setRotationAxis(airRegulatorRotationAxis);
        }
        else
        {
            if (openOutput)
            {
                Debug.Log("GameController: can not find airRegulatorController");
            }
        }

        GameObject drillBitObject = GameObject.FindWithTag("DrillBit");

        if (drillBitObject != null)
        {
            drillBitController = drillBitObject.GetComponent <Rotation> ();
            drillBitController.setRotationAxis(drillBitRotationAxis);
        }
        else
        {
            if (openOutput)
            {
                Debug.Log("GameController: can not find drillBitController");
            }
        }

        for (int i = 0; i < subtask_cnt; i++)
        {
            GameObject flangeNutObject = GameObject.FindWithTag(flangenut_tags [i]);
            if (flangeNutObject != null)
            {
                flangeNut_Rotation [i] = flangeNutObject.GetComponent <flangeNutRotation> ();
                flangeNut_Rotation [i].setRotationAxis(drillBitRotationAxis);
            }
            else
            {
                if (openOutput)
                {
                    Debug.Log("GameController: can not find flangeNut_Rotation " + i);
                }
            }
            if (flangeNutObject != null)
            {
                FlangeNut_simplePositionMovement [i] = flangeNutObject.GetComponent <flangeNutSimplePositionMovement> ();
                FlangeNut_simplePositionMovement [i].setReference(localReference);
            }
            else
            {
                if (openOutput)
                {
                    Debug.Log("GameController: can not find FlangeNut_simplePositionMovement " + i);
                }
            }
        }

        wrenchFittingObject = GameObject.FindWithTag("WrenchFitting");
        if (wrenchFittingObject != null)
        {
            wrenchFittingController = wrenchFittingObject.GetComponent <DetectCollision> ();
        }
        else
        {
            if (openOutput)
            {
                Debug.Log("GameController: can not find wrenchFittingController");
            }
        }

        if (OSCControl)
        {
            GameObject OSCDataReceiverObject = GameObject.FindWithTag("OSCDataReceiver");
            if (OSCDataReceiverObject != null)
            {
                OSCDataReceiverController = OSCDataReceiverObject.GetComponent <OscDataReceiver> ();
            }
        }

        GameObject OSCDataSenderObject = GameObject.FindWithTag("OSCDataSender");

        if (OSCDataSenderObject != null)
        {
            OSCDataSenderController = OSCDataSenderObject.GetComponent <OscDataSender> ();
        }


        for (int i = 0; i < subtask_cnt; i++)
        {
            GameObject FlangeNutStateObject = GameObject.FindWithTag("flangenut_" + (char)(i + '0'));
            if (FlangeNutStateObject != null)
            {
                FlangeNutStateController [i] = FlangeNutStateObject.GetComponent <FlangeNutState> ();
            }
            else
            {
                Debug.Log("flangeNutRotation: can not find FlangeNutStateController " + (char)(i + '0'));
            }
        }


        GameObject GameControllerObject = GameObject.FindWithTag("GameController");

        if (GameControllerObject != null)
        {
            OutputSystemController = GameControllerObject.GetComponent <OutputSystem> ();
            Debug.Log("GameController: Set OutputSystem!");
        }
        else
        {
            Debug.Log("GameController: Can not find OutputSystem!");
        }


        for (int i = 0; i < subtask_cnt; i++)
        {
            string tmp = "arrow_indicator_" + (char)(i + '0');
            Debug.Log(tmp);
            current_arrow_indicator [i] = GameObject.FindWithTag(tmp);
        }


        GameObject SceneParameterManagerControllerObject = GameObject.FindWithTag("SceneParameterManager");

        if (SceneParameterManagerControllerObject != null)
        {
            SceneParameterManagerController = SceneParameterManagerControllerObject.GetComponent <SceneParameterManager> ();
        }
        else
        {
            Debug.Log("GameController: Can not find SceneParameterManager!");
        }


        GameObject soundManagerControllerObject = GameObject.FindWithTag("SoundManager");

        if (soundManagerControllerObject != null)
        {
            soundManagerController = soundManagerControllerObject.GetComponent <SoundManager> ();
        }
        else
        {
            Debug.Log("GameController: Can not find SoundManager!");
        }

        _2DCamera = GameObject.FindWithTag("2DCamera");
//		if (cameraObject != null) {
//			_2DCamera = cameraObject.GetComponent<Camera> ();
//		} else {
//			Debug.Log ("_2DCamer: Can not find 2DCamera!");
//		}


        if (!randomize_order)
        {
            subtask_order = subtask_order_array [0];
        }
        else
        {
            int rand = Random.Range(1, subtask_order_array.GetLength(0));

//			Debug.Log ("subtask_order_array.GetLength (0): " + subtask_order_array.GetLength (0));
//			Debug.Log ("rand: " + rand);

            subtask_order = subtask_order_array [rand];
        }

//		Debug.Log ("subtask_order: " + subtask_order);
    }