protected virtual void Awake()
    {
        // Call the base class's function to initialize all variables
        base.Awake();

        // Find all UI elements in the scene
        PB_MenuTitle = GameObject.Find("PB_MenuTitle").GetComponent<Text>();
        PB_TimeLeftText = GameObject.Find("PB_TimeLeftText").GetComponent<Text>();
        PB_PassPhoneButton = GameObject.Find("PB_PassPhoneButton").GetComponent<Button>();
        PB_HintField = GameObject.Find("PB_HintField").GetComponent<InputField>();
        PB_HintField2 = GameObject.Find("PB_HintField2").GetComponent<InputField>();
        PB_HintField3 = GameObject.Find("PB_HintField3").GetComponent<InputField>();
        PB_InsertHints = GameObject.Find("PB_InsertHints").GetComponent<Button>();
        PB_HideHints = GameObject.Find("PB_HideHints").GetComponent<Button>();
        PB_PlantBomb = GameObject.Find("PB_PlantBomb").GetComponent<Button>();
		PB_Waiting = GameObject.Find ("PB_Waiting").GetComponent<Text>();
        PB_ArmTimeLeftText = GameObject.Find("PB_ArmTimeLeftText").GetComponent<Text>();
        PB_ReplantBomb = GameObject.Find("PB_ReplantBomb").GetComponent<Button>();
        PB_TutorialPlant = GameObject.Find("PB_TutorialPlant").GetComponent<Button>();
        PB_TutorialReplant = GameObject.Find("PB_TutorialReplant").GetComponent<Button>();
        PB_TutorialHints = GameObject.Find("PB_TutorialHints").GetComponent<Button>();
        PB_GiveUp = GameObject.Find ("PB_GiveUp").GetComponent<Button>();

        userDefinedTargetHandler = GameObject.Find("UserDefinedTargetBuilder").GetComponent<UserDefinedTargetEventHandler>();
    }
Esempio n. 2
0
    /// <summary>
    /// This method turns extended tracking on or off for all currently available targets.
    /// Extended tracking allows to track targets when they are not in view.
    /// Returns true of extended tracking is supported; false otherwise
    /// </summary>
    private bool ExtendedTracking(bool tf)
    {
        // the StateManager gives access to all available TrackableBehavours
        StateManager stateManager = TrackerManager.Instance.GetStateManager();

        // We iterate over all TrackableBehaviours to start or stop extended tracking for the targets they represent.
        foreach (var behaviour in stateManager.GetTrackableBehaviours())
        {
            var imageBehaviour = behaviour as ImageTargetBehaviour;
            if (imageBehaviour != null)
            {
                imageBehaviour.ImageTarget.StopExtendedTracking();
            }
        }

        //As of now, UserDefinedTargets can handle Enable/Disable ExtendedTracking on only one TrackableBehaviour.
        //So, we find the latest TrackableBehaviour from the set of user-defined targets and start/stop extended tracking on it.
        List <TrackableBehaviour> list = stateManager.GetTrackableBehaviours().ToList();

        if (list.Count > 0)
        {
            UserDefinedTargetEventHandler component = FindObjectOfType <UserDefinedTargetEventHandler>() as UserDefinedTargetEventHandler;

            ImageTargetBehaviour bhvr = list[component.IndexForMostRecentlyAddedTrackable] as ImageTargetBehaviour;
            Debug.Log("OTT For ImageTargetBehaviour " + bhvr.gameObject.name + " enabled");
            if (bhvr != null)
            {
                if (tf)
                {
                    if (bhvr.ImageTarget.StartExtendedTracking())
                    {
                        return(true);
                    }
                    else
                    {
                        Debug.LogWarning("Extended Tracking is not supported on this device");
                        return(false);
                    }
                }
                else
                {
                    if (bhvr.ImageTarget.StopExtendedTracking())
                    {
                        return(true);
                    }
                    else
                    {
                        Debug.LogWarning("Extended Tracking is not supported on this device");
                        return(false);
                    }
                }
            }
        }
        else
        {
            return(tf);
        }

        return(tf);
    }
    // Draws a custom UI for the user defined target event handler inspector
    public override void OnInspectorGUI()
    {
        UserDefinedTargetEventHandler udtehb = (UserDefinedTargetEventHandler)target;

        EditorGUILayout.HelpBox("Here you can set the ImageTargetBehaviour from the scene that will be used to augment user created targets.", MessageType.Info);
        bool allowSceneObjects = !EditorUtility.IsPersistent(target);

        udtehb.ImageTargetTemplate = (ImageTargetBehaviour)EditorGUILayout.ObjectField("Image Target Template",
                                                                                       udtehb.ImageTargetTemplate, typeof(ImageTargetBehaviour), allowSceneObjects);
    }
Esempio n. 4
0
    public void Start()
    {
        // register for the OnInitialized event at the QCARBehaviour
        QCARBehaviour qcarBehaviour = (QCARBehaviour)FindObjectOfType(typeof(QCARBehaviour));

        if (qcarBehaviour)
        {
            qcarBehaviour.RegisterTrackerEventHandler(this);
        }

        // look up the UserDefinedTargetEventHandler
        mUserDefinedTargetEventHandler = (UserDefinedTargetEventHandler)FindObjectOfType(typeof(UserDefinedTargetEventHandler));

        // load and set gui style
        mUISkin = Resources.Load("UserInterface/ButtonSkins") as GUISkin;

        // remember all custom styles in gui skin to avoid constant lookups
        mButtonGUIStyles = new Dictionary <string, GUIStyle>();
        foreach (GUIStyle customStyle in mUISkin.customStyles)
        {
            mButtonGUIStyles.Add(customStyle.name, customStyle);
        }
    }
    // Use this for linking the states with their variables
    void Awake()
    {
        exceptHandler = GameObject.Find("GameManager").AddComponent<MyExceptionHandler>();
        exceptHandler.setGameManager(this);
        // Set exceptions to be raised whenever an Assert statement fails
        Assert.raiseExceptions = true;

        udtHandler = GameObject.Find("UserDefinedTargetBuilder")
            .GetComponent<UserDefinedTargetEventHandler>();
        Assert.IsNotNull(udtHandler, "Cannot find udtHandler");


        // Set the timers for each state
        plantTimer = new Timer(10);
        armBombTimer = new Timer(4);
        defuseTimer = new Timer(10);
        passTimer = new Timer(10);

        // Set Screen Size
        stateList = new List<State>();
        screenSize = new Vector2(Screen.width, Screen.height);

        // Find the cameras in the game scene
        arCamera = GameObject.Find(arCameraName);
        vuforiaCamera = GameObject.Find(vuforiaCameraName).GetComponent<Camera>();

        Assert.IsNotNull(arCamera, "Cannot find" + arCameraName);
        Assert.IsNotNull(vuforiaCamera, "Cannot find" + vuforiaCameraName);

        // Get references to all states
        mainMenuState = GetComponentInChildren<MainMenuState>();
        sharedModeMenuState = GetComponentInChildren<SharedModeMenuState>();
        multiplayerMenuState = GetComponentInChildren<MultiplayerMenuState>();
        multiplayerLobbyState = GetComponentInChildren<MultiplayerLobbyState>();
        plantBombState = GetComponentInChildren<PlantBombState>();
        passingState = GetComponentInChildren<PassingState>();
        defuseState = GetComponentInChildren<DefuseState>();
        gameOverState = GetComponentInChildren<GameOverState>();
        errorState = GetComponentInChildren<ErrorState>();

        // Add all of the states to the stateList to keep track of them
        stateList.Add(mainMenuState);
        stateList.Add(sharedModeMenuState);
        stateList.Add(multiplayerMenuState);
        stateList.Add(multiplayerLobbyState);
        stateList.Add(plantBombState);
        stateList.Add(passingState);
        stateList.Add(defuseState);
        stateList.Add(gameOverState);
        stateList.Add(errorState);

        // Check if any of the states are null
        foreach (State s in stateList)
        {
            Assert.IsNotNull(s, "One of the states is NOT FOUND");
        }
    }
Esempio n. 6
0
 public override void InitManager()
 {
     base.InitManager ();
     mTargetHandler = GameObject.FindObjectOfType(typeof(UserDefinedTargetEventHandler)) as UserDefinedTargetEventHandler;
     mTargetHandler.Init();
 }
Esempio n. 7
0
    // *** Ends method Update.
    // --------------------------------------------------------------

    public void InitManager()
    {
        mTargetHandler = GameObject.FindObjectOfType(typeof(UserDefinedTargetEventHandler)) as UserDefinedTargetEventHandler;
        mTargetHandler.Init();
    }