Esempio n. 1
0
        //private InputBehavior inputBehavior = InputBehavior.CoherentUI_Unity3D;

        //-----------------------------------------------------------------------------

        public void Start()
        {
            this.coherentUiView = this.GetComponent <CoherentUIView>();
            this.coherentUiView.Listener.ReadyForBindings += this.BindMethods;

            this.coherentUiView.IsTransparent = true;
        }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        DontDestroyOnLoad(this.gameObject);
        // Separate the UI into its own group
        // so it doesn't get disabled when we change levels
        networkView.group = 1;

        this.m_View = GetComponent <CoherentUIView>();
        this.m_View.OnViewCreated   += (view) => { this.viewReady = true; };
        this.m_View.OnViewDestroyed += () => { this.viewReady = false; };

        this.playerManager.OnPlayerJoined  += this.PlayerJoinedEvent;
        this.playerManager.OnPlayerLeft    += this.PlayerLeftEvent;
        this.playerManager.OnPlayerUpdated += this.PlayerUpdatedEvent;

        this.gameManager.OnGameStarted += (sender) => {
            if (this.viewReady)
            {
                this.m_View.View.TriggerEvent("respondToStartGame");
            }
        };

        this.gameManager.OnGameEnded += (sender) => {
            if (this.viewReady)
            {
                this.m_View.View.TriggerEvent("respondToEndGame");
            }
        };

        // Make the Coherent View receive input
        if (this.m_View)
        {
            this.m_View.ReceivesInput = true;
        }
    }
    void Start()
    {
        gameObject.AddComponent("OrientationManager");
        orientationManager = gameObject.GetComponent<OrientationManager>();
        CoherentUISystem system = Object.FindObjectOfType(typeof (CoherentUISystem)) as CoherentUISystem;
        if (system != null)
        {
            if (system.camera == null)
                system.m_MainCamera = GameObject.FindGameObjectWithTag("MainCamera").camera;
        }

        _view = this.GetComponent<CoherentUIView>();
        _view.OnViewCreated += new UnityViewListener.CoherentUI_OnViewCreated(this.OnViewReady);

        _view.Listener.ReadyForBindings += (frameId, path, isMainFrame) =>
        {
            _view.View.BindCall("GoToDestination", (System.Action<string>)GoToDestination);
            _view.View.BindCall("IsFacebookSignedIn", (System.Action)IsFacebookSignedIn);
            _view.View.BindCall("FacebookSignOut", (System.Action)FacebookSignOut);
            _view.View.BindCall("StoreFacebook", (System.Action<string, string, string, string>)StoreFacebook);
            _view.View.BindCall("GetInvitationCount", (System.Action)GetInvitationCount);
        };

        _view.OnViewCreated += (view) => view.InterceptURLRequests(true);
        _view.Listener.URLRequest += OnURLRequestHandler;

        LocalAppURL = _view.Page;

        _userManager = Object.FindObjectOfType(typeof(UserManager)) as UserManager;
        _viewReady = false;
    }
	void Start()
    {
        _view = this.GetComponent<CoherentUIView>();
        LocalAppURL = _view.Page;
        _view.OnViewCreated += new UnityViewListener.CoherentUI_OnViewCreated(this.OnViewReady);
		_userManager = Object.FindObjectOfType(typeof(UserManager)) as UserManager;
		_eventManager = GameObject.Find("EventManager").GetComponent<EventManager>();
		_eventManager.RepopulateEvents();
		
		_view.Listener.ReadyForBindings += (frameId, path, isMainFrame) =>
        {
            _view.View.BindCall("RequestUsername", (System.Action)RequestUsername);
            _view.View.BindCall("CheckPin", (System.Action<string>)OnJournalClicked);
            _view.View.BindCall("OnSaveEntryClicked", (System.Action<string, string>)OnSaveEntryClicked);
			_view.View.BindCall("DeleteEntry", (System.Action<string>)DeleteEntry);
            _view.View.BindCall("GetCategories", (System.Action)GetCategories);
            _view.View.BindCall("UpdateCategories", (System.Action<string>)UpdateCategories);
            _view.View.BindCall("GetCommerce", (System.Action)GetCommerce);
            _view.View.BindCall("UpdateCommerce", (System.Action<string>)UpdateCommerce);
            _view.View.BindCall("SignOut", (System.Action)SignOut);
            _view.View.BindCall("GetFacebookInfoMB", (System.Action)GetFacebookInfoMB);
            _view.View.BindCall("RetrieveInvitations", (System.Action)RetrieveInvitations);
            _view.View.BindCall("RetrieveBusinesses", (System.Action)RetrieveBusinesses);
            _view.View.BindCall("JoinEvent", (System.Action<string>)JoinEvent);
            _view.View.BindCall("IsFacebookLoggedIn", (System.Action)IsFacebookLoggedIn);
            _view.View.BindCall("SignIntoFacebook", (System.Action)SignIntoFacebook);
            _view.View.BindCall("SignOutOfFacebook", (System.Action)SignOutOfFacebook);
            _view.View.BindCall("BusinessClicked", (System.Action<string>)BusinessClicked);
            _view.View.BindCall("JournalsLoaded", (System.Action)JournalsLoaded);
            _view.View.BindCall("GetFacebookAuth", (System.Action)GetFacebookAuth);
        };
        
        _viewReady = false;
    }
	// Use this for initialization
    void Start()
    {
        _user = GameObject.FindGameObjectWithTag("UserManager").GetComponent<UserManager>().CurrentUser;
        _view = this.GetComponent<CoherentUIView>();
        _view.OnViewCreated += new UnityViewListener.CoherentUI_OnViewCreated(this.OnViewReady);
        _view.Listener.ReadyForBindings += (frameId, path, isMainFrame) =>
        {
            _view.View.BindCall("ReadyForCategories", (System.Action)ReadyForCategories);
            _view.View.BindCall("GetBusinessSubCat", (System.Action<string>)GetBusinessSubCat);
            _view.View.BindCall("SetBusinessID", (System.Action<string>)SetBusinessID);
            _view.View.BindCall("LoadAdData", (System.Action)LoadAdData);
            _view.View.BindCall("SetBusinessIDForCard", (System.Action<string>)SetBusinessIDForCard);
            _view.View.BindCall("LoadBusinessCard", (System.Action)LoadBusinessCard);
            _view.View.BindCall("SetJsonString", (System.Action<string, int>)SetJsonString);
            _view.View.BindCall("SetFlashDealID", (System.Action<int>)SetFlashDealID);
            _view.View.BindCall("LoadFlashDeal", (System.Action)LoadFlashDeal);
            _view.View.BindCall("ClearFlashDeals", (System.Action)ClearFlashDeals);
            _view.View.BindCall("LoadFlashDeals", (System.Action)LoadFlashDeals);
            _view.View.BindCall("TrackUserAction", (System.Action<string, string, string>)TrackUserAction);
            _view.View.BindCall("OnAdPlayerWasClosed", (System.Action)OnAdPlayerWasClosed);
            _view.View.BindCall("FacebookLike", (System.Action<string>)FacebookLike);
			_view.View.BindCall("FacebookUnLike", (System.Action<string>)FacebookUnLike);
            _view.View.BindCall("CheckIfBusinessIsLiked", (System.Action)CheckIfBusinessIsLiked);
            _view.View.BindCall("SaveBusiness", (System.Action<string>)SaveBusiness);
            _view.View.BindCall("UnsaveBusiness", (System.Action<string>)UnsaveBusiness);
        };

        _adManager = GameObject.FindGameObjectWithTag("AdManager").GetComponent<AdManager>();
        _businessManager = GameObject.Find("BusinessManager").GetComponent<BusinessManager>();

    }
Esempio n. 6
0
	void Start()
	{
		m_View = GetComponent<CoherentUIView>();
		if (m_View)
		{
			m_View.Listener.ReadyForBindings += HandleReadyForBindings;
		}
	}
	// Use this for initialization
	void Start () {
		m_View = GetComponent<CoherentUIView>();
		
		m_GameOptions = new GameOptions {
			Backend = "Unity3D",
			Width = 1024,
			Height = 768,
			NetPort = 17777,
		};
	}
Esempio n. 8
0
	// Use this for initialization
	void Start ()
	{
		ViewComponent = GetComponent<CoherentUIView>();
		if (ViewComponent)
		{
			ViewComponent.OnReadyForBindings += this.RegisterBindings;
		}
	
		ViewComponent.ReceivesInput = true;
	}
Esempio n. 9
0
    // Use this for initialization
    void Start()
    {
        ViewComponent = GetComponent <CoherentUIView>();
        if (ViewComponent)
        {
            ViewComponent.OnReadyForBindings += this.RegisterBindings;
        }

        ViewComponent.ReceivesInput = true;
    }
Esempio n. 10
0
    // Use this for initialization
    void Start()
    {
        m_CameraView = m_MainCamera.gameObject.GetComponent <CoherentUIView>();
        if (m_CameraView && !m_CameraView.ClickToFocus)
        {
            m_CameraView.ReceivesInput              = true;
            m_CameraView.Listener.ReadyForBindings += HandleReadyForBindings;
        }

        ToggleMouseLook();         // Disable mouse look initially
    }
Esempio n. 11
0
    void Start()
    {
        DontDestroyOnLoad(this);
        if (GameObject.FindGameObjectWithTag("UserManager") == null)
            gameObject.tag = "UserManager";
        else
            Destroy(gameObject);

        _view = GameObject.Find("Main Camera").GetComponent<CoherentUIView>();
        //_view.OnViewCreated += new UnityViewListener.CoherentUI_OnViewCreated(this.OnViewReady);
    }
Esempio n. 12
0
	// Use this for initialization
	void Start () {
		m_View = GetComponent<CoherentUIView>();
		m_View.Listener.ReadyForBindings += HandleReadyForBindings;
		
		m_GameOptions = new GameOptions {
			Backend = "Unity3D",
			Width = 1024,
			Height = 768,
			NetPort = 17777,
		};
	}
Esempio n. 13
0
    // Use this for initialization
    void Start()
    {
        m_View = GetComponent <CoherentUIView>();

        m_GameOptions = new GameOptions {
            Backend = "Unity3D",
            Width   = 1024,
            Height  = 768,
            NetPort = 17777,
        };
    }
Esempio n. 14
0
    // Use this for initialization
    void Start()
    {
        m_View = GetComponent <CoherentUIView>();
        m_View.Listener.ReadyForBindings += HandleReadyForBindings;

        m_GameOptions = new GameOptions {
            Backend = "Unity3D",
            Width   = 1024,
            Height  = 768,
            NetPort = 17777,
        };
    }
Esempio n. 15
0
    // Use this for initialization
    void Start()
    {
        CoherentUIView view = GetComponent <CoherentUIView>();

        if (view == null)
        {
            Debug.LogError("The GameObject must have a CoherentUIView component!");
            return;
        }
        // This is the only view in the sample and we'll always forward the input to it
        view.ReceivesInput = true;
    }
Esempio n. 16
0
	void Start () {
		m_View = GetComponent<CoherentUIView>();
			
			// Obtain the Coherenet UI COmponenet and wait for the biding to be ready before working with it.
			m_View.Listener.ReadyForBindings += (frameId, path, isMainFrame) => {
				Debug.Log ("===> COUI is Ready to fire JS events");

				// Fire Playmaker event to display quote
			    PlayMakerFSM targetFSM = GameObject.Find("SFDC_COUI_Binder").GetComponent<PlayMakerFSM>();
				targetFSM.Fsm.Event ("couiBinderReady");
			};
		}
Esempio n. 17
0
	public void TriggerSomeUIEvent(string msg)
	{
		Debug.Log("triggering event on UI");

		ViewComponent = GetComponent<CoherentUIView>();
		var view = ViewComponent.View;
		if (view != null)
		{
			view.TriggerEvent("myJavascriptFunction", msg);
			Debug.Log(msg);
		}
				
	}	
Esempio n. 18
0
	// Use this for initialization
	void Start()
	{
		m_CameraView = m_MainCamera.gameObject.GetComponent<CoherentUIView>();
		if (m_CameraView && !m_CameraView.ClickToFocus)
		{
			m_CameraView.ReceivesInput = true;
		}
		if (m_CameraView)
		{
			m_CameraView.Listener.ReadyForBindings += HandleReadyForBindings;
		}
		ToggleMouseLook(); // Disable mouse look initially
	}
Esempio n. 19
0
    void Start()
    {
        m_View = GetComponent <CoherentUIView>();

        // Obtain the Coherenet UI COmponenet and wait for the biding to be ready before working with it.
        m_View.Listener.ReadyForBindings += (frameId, path, isMainFrame) => {
            Debug.Log("===> COUI is Ready to fire JS events");

            // Fire Playmaker event to display quote
            PlayMakerFSM targetFSM = GameObject.Find("SFDC_COUI_Binder").GetComponent <PlayMakerFSM>();
            targetFSM.Fsm.Event("couiBinderReady");
        };
    }
Esempio n. 20
0
    // Use this for initialization
    void Start()
    {
        //gradeManager = new TLGradeManager();
        ViewComponent = GetComponent <CoherentUIView>();
        if (ViewComponent)
        {
            ViewComponent.OnReadyForBindings += this.RegisterBindings;
        }

        ViewComponent.ReceivesInput = true;
        //InvokeRepeating("TestData1", 1, 15);
        InvokeRepeating("TestData2", 4, 15);
        TestData1();
    }
Esempio n. 21
0
    // Use this for initialization
    void Start()
    {
        DontDestroyOnLoad(this.gameObject);
        // Separate the UI into its own group
        // so it doesn't get disabled when we change levels
        networkView.group = 1;

        this.m_View = GetComponent<CoherentUIView>();
        this.m_View.OnViewCreated += (view) => {this.viewReady = true;};
        this.m_View.OnViewDestroyed += () => {this.viewReady = false;};

        // Make the Coherent View receive input
        if(this.m_View)
            this.m_View.ReceivesInput = true;
    }
Esempio n. 22
0
    private void CalculateScaledMouseCoordinates(ref MouseEventData data,
                                                 CoherentUIView view,
                                                 bool invertY)
    {
        var camWidth  = view.gameObject.camera.pixelWidth;
        var camHeight = view.gameObject.camera.pixelHeight;

        float factorX = view.WidthToCamWidthRatio(camWidth);
        float factorY = view.HeightToCamHeightRatio(camHeight);

        float y = (invertY)? (camHeight - data.Y) : data.Y;

        data.X = (int)(data.X * factorX);
        data.Y = (int)(y * factorY);
    }
Esempio n. 23
0
		public UnityViewListener(CoherentUIView component, int width, int height)
		{
	        m_ViewComponent = component;
			m_Width = width;
			m_Height = height;
			
			m_ObjectsToDestroy = new List<Object>();
			
			HasModalDialogOpen = false;

			this.ViewCreated += new CoherentUI_OnViewCreated(OnViewCreatedHandler);
			this.JavaScriptMessage += new CoherentUI_OnJavaScriptMessage(OnJavaScriptMessageHandler);
			#if UNITY_EDITOR || COHERENT_UNITY_STANDALONE
			this.GetAuthCredentials += new CoherentUI_OnGetAuthCredentials(OnGetAuthCredentialsHandler);
			#endif
		}
Esempio n. 24
0
	void OnPublicMessage(BaseEvent evt) {
		User sender = (User)evt.Params["sender"];
		
		if(sender == smartFox.MySelf) {
			Debug.Log ("I said " + (string)evt.Params["message"]);
		} else {
			Debug.Log ("User " + sender.Name + " said: " + (string)evt.Params["message"]);
		}
		
		ViewComponent = GetComponent<CoherentUIView>();
		var view = ViewComponent.View;
		if (view != null)
		{
			view.TriggerEvent("PostChatMessage", (string)evt.Params["message"]);
			Debug.Log("message sent to UI");
		}
	}
Esempio n. 25
0
    // Use this for initialization
    void Start()
    {
        DontDestroyOnLoad(this.gameObject);
        // Separate the UI into its own group
        // so it doesn't get disabled when we change levels
        networkView.group = 1;

        this.m_View = GetComponent <CoherentUIView>();
        this.m_View.OnViewCreated   += (view) => { this.viewReady = true; };
        this.m_View.OnViewDestroyed += () => { this.viewReady = false; };

        // Make the Coherent View receive input
        if (this.m_View)
        {
            this.m_View.ReceivesInput = true;
        }
    }
	// Use this for initialization
	void Start()
	{
#if COHERENT_UNITY_STANDALONE
		Debug.LogWarning("The mobile input emulation in the Editor " +
			"works only when you switch to Android/iOS!");
#endif

		m_CameraView = m_MainCamera.gameObject.GetComponent<CoherentUIView>();
		if (m_CameraView && !m_CameraView.ClickToFocus)
		{
			m_CameraView.ReceivesInput = true;
		}
		if (m_CameraView)
		{
			m_CameraView.Listener.ReadyForBindings += HandleReadyForBindings;
		}
		ToggleMouseLook(); // Disable mouse look initially
	}
    void MouseMovedViewUpdate(CoherentUIView view)
    {
        if (view.ReceivesInput && view != null && view.View != null)
        {
            if (view.MouseX != -1 && view.MouseY != -1)
            {
                m_MouseMoveEvent.X = view.MouseX;
                m_MouseMoveEvent.Y = view.MouseY;
            }
            else
            {
                CalculateScaledMouseCoordinates(ref m_MouseMoveEvent, view,
                                                true);
            }

            view.View.MouseEvent(m_MouseMoveEvent);
        }
    }
Esempio n. 28
0
    void Start()
    {
        gameObject.AddComponent("OrientationManager");
        orientationManager = gameObject.GetComponent<OrientationManager>();
        _view = this.GetComponent<CoherentUIView>();
        _view.OnViewCreated += new UnityViewListener.CoherentUI_OnViewCreated(this.OnViewReady);

        _view.Listener.ReadyForBindings += (frameId, path, isMainFrame) =>
        {
            _view.View.BindCall("GoToDestination", (System.Action<string>) GoToDestination);
            _view.View.BindCall("CheckLoginInformation", (System.Action<string, string, bool>) CheckLoginInformation);
            _view.View.BindCall("SignOut", (System.Action) SignOut);
            _view.View.BindCall("RequestToLogin", (System.Action) RequestToLogin);
        };

        _userManager = Object.FindObjectOfType(typeof(UserManager)) as UserManager;
        _viewReady = false;
    }
Esempio n. 29
0
    // Use this for initialization
    void Start()
    {
#if COHERENT_UNITY_STANDALONE
        Debug.LogWarning("The mobile input emulation in the Editor " +
                         "works only when you switch to Android/iOS!");
#endif

        m_CameraView = m_MainCamera.gameObject.GetComponent <CoherentUIView>();
        if (m_CameraView && !m_CameraView.ClickToFocus)
        {
            m_CameraView.ReceivesInput = true;
        }
        if (m_CameraView)
        {
            m_CameraView.Listener.ReadyForBindings += HandleReadyForBindings;
        }
        ToggleMouseLook();         // Disable mouse look initially
    }
Esempio n. 30
0
    // Use this for initialization
    void Start()
    {
        _view = this.GetComponent<CoherentUIView>();
        _view.OnViewCreated += new UnityViewListener.CoherentUI_OnViewCreated(this.OnViewReady);
        myTween = gameObject.GetComponent<TweenTransform>();
        _view.Listener.ReadyForBindings += (frameId, path, isMainFrame) =>
        {
            _view.View.BindCall("LoadAdPlayer", (System.Action<string>)LoadAdPlayer);
            _view.View.BindCall("OnBusinessWasSelected", (System.Action)OnBusinessWasSelected);
            _view.View.BindCall("AddBusinesses", (System.Action)AddBusinesses);
            _view.View.BindCall("CloseBusinessList", (System.Action)CloseBusinessList);
            _view.View.BindCall("LoadAdData", (System.Action)LoadAdData);
            _view.View.BindCall("MenuClosed", (System.Action)MenuClosed);
        };
		
		if (Application.platform == RuntimePlatform.IPhonePlayer)
			_view.InputState = CoherentUIView.CoherentViewInputState.TakeNone;
		gameObject.GetComponent<CoherentUIView>().FlipY = true;
    }
Esempio n. 31
0
        public UnityViewListener(CoherentUIView component, int width, int height)
        {
            m_ViewComponent = component;
            m_Width         = width;
            m_Height        = height;

            m_ObjectsToDestroy = new List <Object>();

            HasModalDialogOpen = false;

            this.ViewCreated += new CoherentUI_OnViewCreated(OnViewCreatedHandler);

            if (component.ShowJavaScriptDialogs)
            {
                this.JavaScriptMessage += new CoherentUI_OnJavaScriptMessage(OnJavaScriptMessageHandler);
                                #if UNITY_EDITOR || COHERENT_UNITY_STANDALONE
                this.GetAuthCredentials += new CoherentUI_OnGetAuthCredentials(OnGetAuthCredentialsHandler);
                                #endif
            }
        }
Esempio n. 32
0
	private SmartFox smartFox; // the smartfox server
		
	// Use this for initialization
	void Start () {
		smartFox = SmartFoxConnection.Connection;
		
		if(smartFox == null){
			smartFox = new SmartFox();
		}
		
		smartFox.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage);
		
		Debug.Log("The last room you joined was:");
		//Debug.Log(smartFox.LastJoinedRoom.Name);
		
		
		ViewComponent = GetComponent<CoherentUIView>();
		if (ViewComponent)
		{
			ViewComponent.OnReadyForBindings += this.RegisterBindings;
		}
	
		ViewComponent.ReceivesInput = true;
	
	}
    private void CalculateScaledMouseCoordinates(ref MouseEventData data,
                                                 CoherentUIView view,
                                                 bool invertY)
    {
        float camWidth;
        float camHeight;

        var isOnSurface = view.gameObject.camera == null;

        if (!isOnSurface)
        {
            camWidth  = view.gameObject.camera.pixelWidth;
            camHeight = view.gameObject.camera.pixelHeight;
        }
        else
        {
            var surfaceCameraObj =
                view.gameObject.transform.Find
                    ("CoherentRenderingCamera" + view.View.GetId());
            if (surfaceCameraObj != null && surfaceCameraObj.camera != null)
            {
                camWidth  = surfaceCameraObj.camera.pixelWidth;
                camHeight = surfaceCameraObj.camera.pixelHeight;
            }
            else
            {
                return;
            }
        }

        float factorX = view.WidthToCamWidthRatio(camWidth);
        float factorY = view.HeightToCamHeightRatio(camHeight);

        float y = (invertY)? (camHeight - data.Y) : data.Y;

        data.X = (int)(data.X * factorX);
        data.Y = (int)(y * factorY);
    }
Esempio n. 34
0
    // Use this for initialization
    void Start()
    {
        DontDestroyOnLoad(this.gameObject);
        networkView.group = 1;

        this.m_View             = GetComponent <CoherentUIView>();
        m_View.OnViewCreated   += (view) => { this.viewReady = true; };
        m_View.OnViewDestroyed += () => { this.viewReady = false; };

        // Make the Coherent View receive input
        if (this.m_View)
        {
            this.m_View.ReceivesInput = true;
        }

        if (this.netMan)
        {
            this.netMan.OnServerListUpdated     += UpdateGUIServerList;            // Bind to event
            this.netMan.OnServerRegisterAttempt += RespondToServerRegisterAttempt; // Bind to event
            this.netMan.OnAsyncConnectInfoEvent += RespondToAsyncConnectInfoEvent;
            this.netMan.OnDisconnected          += RespondToDisconnect;
        }
    }
    void LateUpdate()
    {
                #if UNITY_ANDROID || COHERENT_SIMULATE_MOBILE_IN_EDITOR || COHERENT_SIMULATE_MOBILE_IN_PLAYER
        CoherentUI.InputManager.PrepareForNextFrame();
                #elif COHERENT_UNITY_STANDALONE
        // Check if the mouse moved
        Vector2 mousePosition = Input.mousePosition;
        if (mousePosition != m_LastMousePosition)
        {
            if (m_MouseMoveEvent != null && m_Views != null)
            {
                Coherent.UI.InputManager.GenerateMouseMoveEvent(
                    ref m_MouseMoveEvent);

                //Cache the initial mouse X and Y
                int mouseX = m_MouseMoveEvent.X;
                int mouseY = m_MouseMoveEvent.Y;
                foreach (var item in m_Views)
                {
                    CoherentUIView view = item;

                    MouseMovedViewUpdate(view);

                    //Since we are using a single mouse event for all
                    //of the views and the MouseMovedViewUpdate
                    //mutates the event's X and Y per view, we have to
                    //reset the X and Y for the next view

                    m_MouseMoveEvent.X = mouseX;
                    m_MouseMoveEvent.Y = mouseY;
                }
            }

            m_LastMousePosition = mousePosition;
        }
                #endif
    }
Esempio n. 36
0
    void Start()
    {
        _view = this.GetComponent<CoherentUIView>();
        _view.OnViewCreated += new UnityViewListener.CoherentUI_OnViewCreated(this.OnViewReady);
        _userManager = Object.FindObjectOfType(typeof(UserManager)) as UserManager;
		_eventManager = GameObject.Find("EventManager").GetComponent<EventManager>();
		_eventManager.RepopulateEvents();
		_view.Listener.ReadyForBindings += (frameId, path, isMainFrame) =>
        {
            _view.View.BindCall("GetWeekEvents", (System.Action)GetWeekEvents);
            _view.View.BindCall("PopulateCalendar", (System.Action)PopulateCalendar);
            _view.View.BindCall("CreateEvent", (System.Action<string[], int[]>)CreateEvent);
            _view.View.BindCall("GetEvents", (System.Action<string>)GetEvents);
            _view.View.BindCall("GetCategories", (System.Action)GetCategories);
            _view.View.BindCall("GetMyEvents", (System.Action)GetMyEvents);
            _view.View.BindCall("GetOtherEvents", (System.Action)GetOtherEvents);
            _view.View.BindCall("CancelEvent", (System.Action<string>)CancelEvent);
            _view.View.BindCall("WithdrawEvent", (System.Action<string>)WithdrawEvent);
            _view.View.BindCall("JoinEvent", (System.Action<string>)JoinEvent);
            _view.View.BindCall("GetInvitationEvents", (System.Action)GetInvitationEvents);
        };

        _viewReady = false;
    }
Esempio n. 37
0
	private void Start()
	{
		if (View == null)
		{
			View = GetComponent<CoherentUIView>();
		}
		foreach (var button in Buttons)
		{
			button.Initialize(this);
		}
		if (View.IsReadyForBindings)
		{
			SetupBindings();
		}
		else
		{
			View.Listener.ReadyForBindings += OnReadyForBindings;
		}
		View.Listener.BindingsReleased += OnBindingsReleased;
	}
Esempio n. 38
0
    // Update is called once per frame
    void Update()
    {
        if (m_UISystem.HasFocusedView)
        {
            return;
        }
        // Reset input processing for all views
        foreach (var item in m_UISystem.UIViews)
        {
            if (!item.ClickToFocus)
            {
                item.ReceivesInput = false;
            }
        }

        var cameraView = m_MainCamera.gameObject.GetComponent <CoherentUIView>();

        if (cameraView && !cameraView.ClickToFocus)
        {
            var view = cameraView.View;
            if (view != null)
            {
                var factorY = cameraView.Height / m_MainCamera.pixelHeight;

                //Normalize the view coordinates. We need this when we use view dimensions
                //are different than the camera ones
                var normX = Input.mousePosition.x / cameraView.Width;
                var normY = 1 - Input.mousePosition.y / cameraView.Height;

                //After the normalizations, the Normalized Y coordinate will be displaced because Y coords
                //grow downwards and we have to put it back into the [0-1] range.

                //E.g. if the view height is two times smaller
                //than the camera height, the normalized Y coords will start from -1 and end to +1.
                //If the view's height is 4 times smaller, the normalized coords will start from -3 and end to +1

                //The formula puts the Y coord back in [0-1] range.
                normY = ((normY * factorY) + (1 - factorY)) / factorY;

                if (normX >= 0 && normX <= 1 && normY >= 0 && normY <= 1)
                {
                    view.IssueMouseOnUIQuery(normX, normY);
                    view.FetchMouseOnUIQuery();
                    if (view.IsMouseOnView())
                    {
                        cameraView.ReceivesInput = true;
                        return;
                    }
                }
            }
        }


        // Activate input processing for the view below the mouse cursor
        RaycastHit hitInfo;

        if (Physics.Raycast(m_MainCamera.ScreenPointToRay(Input.mousePosition), out hitInfo))
        {
            //Debug.Log (hitInfo.collider.name);

            CoherentUIView viewComponent = hitInfo.collider.gameObject.GetComponent(typeof(CoherentUIView)) as CoherentUIView;
            if (viewComponent == null)
            {
                viewComponent = hitInfo.collider.gameObject.GetComponentInChildren(typeof(CoherentUIView)) as CoherentUIView;
            }

            if (viewComponent != null && !viewComponent.ClickToFocus)
            {
                viewComponent.ReceivesInput = true;
                viewComponent.SetMousePosition(
                    (int)(hitInfo.textureCoord.x * viewComponent.Width),
                    (int)(hitInfo.textureCoord.y * viewComponent.Height));
            }
        }
    }
Esempio n. 39
0
    // Use this for initialization
    void Start()
    {
        DontDestroyOnLoad(this.gameObject);
        // Separate the UI into its own group
        // so it doesn't get disabled when we change levels
        networkView.group = 1;

        this.m_View = GetComponent<CoherentUIView>();
        this.m_View.OnViewCreated += (view) => {this.viewReady = true;};
        this.m_View.OnViewDestroyed += () => {this.viewReady = false;};

        // Make the Coherent View receive input
        if(this.m_View)
            this.m_View.ReceivesInput = true;

        // If someone enters a territory
        this.territoryManager.OnATerritoryEntered += (sender, e) => {
            // And it is us...
            // Show the progress
            if(e.player.guid == this.playerManager.GetPlayer("self").guid)
            {
                this.ShowTerritoryProgress(e.TerritoryData);
                this.currentTerritory = sender;
            }

        };

        // If someone exits a territory
        this.territoryManager.OnATerritoryExited += (sender, e) => {
            // And it is us...
            // Hide the progress
            if(Object.ReferenceEquals(this.currentTerritory, sender))
            {
                if(e.player.guid == this.playerManager.GetPlayer("self").guid)
                {
                    this.HideTerritoryProgress();
                    this.currentTerritory = null;
                }
            }

        };

        // If a territory is updated
        this.territoryManager.OnATerritoryUpdated += (sender, tData) => {
            // If the territory we are in is the same as the one updated
            if(Object.ReferenceEquals(this.currentTerritory, sender))
                if(this.viewReady)
                    this.m_View.View.TriggerEvent("territoryUpdated", tData);
        };

        // If the score is updated
        this.scoreManager.OnScoreUpdated += (sender, e) => {
            this.UpdateScoreBox(e.ScoreData);
        };

        this.playerManager.OnPlayerUpdated += this.PlayerUpdatedEvent;

        // Stop the time once the game ends
        this.gameManager.OnGameEnded += (sender) => {
            this.StopGameTimeBox();
        };
    }
Esempio n. 40
0
    // Use this for initialization
    void Start()
    {
        DontDestroyOnLoad(this.gameObject);
        // Separate the UI into its own group
        // so it doesn't get disabled when we change levels
        networkView.group = 1;

        this.m_View = GetComponent <CoherentUIView>();
        this.m_View.OnViewCreated   += (view) => { this.viewReady = true; };
        this.m_View.OnViewDestroyed += () => { this.viewReady = false; };

        // Make the Coherent View receive input
        if (this.m_View)
        {
            this.m_View.ReceivesInput = true;
        }

        // If someone enters a territory
        this.territoryManager.OnATerritoryEntered += (sender, e) => {
            // And it is us...
            // Show the progress
            if (e.player.guid == this.playerManager.GetPlayer("self").guid)
            {
                this.ShowTerritoryProgress(e.TerritoryData);
                this.currentTerritory = sender;
            }
        };

        // If someone exits a territory
        this.territoryManager.OnATerritoryExited += (sender, e) => {
            // And it is us...
            // Hide the progress
            if (Object.ReferenceEquals(this.currentTerritory, sender))
            {
                if (e.player.guid == this.playerManager.GetPlayer("self").guid)
                {
                    this.HideTerritoryProgress();
                    this.currentTerritory = null;
                }
            }
        };

        // If a territory is updated
        this.territoryManager.OnATerritoryUpdated += (sender, tData) => {
            // If the territory we are in is the same as the one updated
            if (Object.ReferenceEquals(this.currentTerritory, sender))
            {
                if (this.viewReady)
                {
                    this.m_View.View.TriggerEvent("territoryUpdated", tData);
                }
            }
        };

        // If the score is updated
        this.scoreManager.OnScoreUpdated += (sender, e) => {
            this.UpdateScoreBox(e.ScoreData);
        };

        this.playerManager.OnPlayerUpdated += this.PlayerUpdatedEvent;


        // Stop the time once the game ends
        this.gameManager.OnGameEnded += (sender) => {
            this.StopGameTimeBox();
        };
    }
Esempio n. 41
0
    // Use this for initialization
    void Start()
    {
        DontDestroyOnLoad(this.gameObject);
        networkView.group = 1;

        this.m_View = GetComponent<CoherentUIView>();
        m_View.OnViewCreated += (view) => {this.viewReady = true;};
        m_View.OnViewDestroyed += () => {this.viewReady = false;};

        // Make the Coherent View receive input
        if(this.m_View)
            this.m_View.ReceivesInput = true;

        if(this.netMan)
        {
            this.netMan.OnServerListUpdated += UpdateGUIServerList; // Bind to event
            this.netMan.OnServerRegisterAttempt += RespondToServerRegisterAttempt; // Bind to event
            this.netMan.OnAsyncConnectInfoEvent += RespondToAsyncConnectInfoEvent;
            this.netMan.OnDisconnected += RespondToDisconnect;
        }
    }
 internal bool RemoveView(CoherentUIView view)
 {
     return(m_Views.Remove(view));
 }
Esempio n. 43
0
	private void CalculateScaledMouseCoordinates(ref MouseEventData data,
		CoherentUIView view,
		bool invertY)
	{
		float camWidth;
		float camHeight;

		var isOnSurface = view.gameObject.camera == null;

		if (!isOnSurface)
		{
			camWidth = view.gameObject.camera.pixelWidth;
			camHeight = view.gameObject.camera.pixelHeight;
		}
		else
		{
			var surfaceCameraObj =
				view.gameObject.transform.Find
					("CoherentRenderingCamera" + view.View.GetId());
			if (surfaceCameraObj != null && surfaceCameraObj.camera != null)
			{
				camWidth = surfaceCameraObj.camera.pixelWidth;
				camHeight = surfaceCameraObj.camera.pixelHeight;
			}
			else
			{
				return;
			}
		}

		float factorX = view.WidthToCamWidthRatio(camWidth);
		float factorY = view.HeightToCamHeightRatio(camHeight);

		float y = (invertY)? (camHeight - data.Y) : data.Y;

		data.X = (int)(data.X * factorX);
		data.Y = (int)(y * factorY);
	}
Esempio n. 44
0
	void MouseMovedViewUpdate(CoherentUIView view)
	{

		if (view.ReceivesInput && view != null && view.View != null)
		{
			if (view.MouseX != -1 && view.MouseY != -1)
			{
				m_MouseMoveEvent.X = view.MouseX;
				m_MouseMoveEvent.Y = view.MouseY;
			}
			else
			{
				CalculateScaledMouseCoordinates(ref m_MouseMoveEvent, view,
					true);
			}

			view.View.MouseEvent(m_MouseMoveEvent);
		}
	}
Esempio n. 45
0
    // Update is called once per frame
    void Update()
    {
        if (m_UISystem.HasFocusedView)
        {
            return;
        }
        // Reset input processing for all views
        foreach (var item in m_UISystem.UIViews)
        {
            if (!item.ClickToFocus)
            {
                item.ReceivesInput = false;
            }
        }

        var cameraView = m_MainCamera.gameObject.GetComponent <CoherentUIView>();

        if (cameraView && !cameraView.ClickToFocus)
        {
            var view = cameraView.View;
            if (view != null)
            {
                var normX = Input.mousePosition.x / cameraView.Width;
                var normY = 1 - Input.mousePosition.y / cameraView.Height;
                if (normX >= 0 && normX <= 1 && normY >= 0 && normY <= 1)
                {
                    view.IssueMouseOnUIQuery(normX, normY);
                    view.FetchMouseOnUIQuery();
                    if (view.IsMouseOnView())
                    {
                        cameraView.ReceivesInput = true;
                        cameraView.SetMousePosition((int)Input.mousePosition.x, cameraView.Height - (int)Input.mousePosition.y);
                        return;
                    }
                }
            }
        }


        // Activate input processing for the view below the mouse cursor
        RaycastHit hitInfo;

        if (Physics.Raycast(m_MainCamera.ScreenPointToRay(Input.mousePosition), out hitInfo))
        {
            //Debug.Log (hitInfo.collider.name);

            CoherentUIView viewComponent = hitInfo.collider.gameObject.GetComponent(typeof(CoherentUIView)) as CoherentUIView;
            if (viewComponent == null)
            {
                viewComponent = hitInfo.collider.gameObject.GetComponentInChildren(typeof(CoherentUIView)) as CoherentUIView;
            }

            if (viewComponent != null && !viewComponent.ClickToFocus)
            {
                viewComponent.ReceivesInput = true;
                viewComponent.SetMousePosition(
                    (int)(hitInfo.textureCoord.x * viewComponent.Width),
                    (int)(hitInfo.textureCoord.y * viewComponent.Height));
            }
        }
    }
Esempio n. 46
0
    // Use this for initialization
    void Start()
    {
        DontDestroyOnLoad(this.gameObject);
        // Separate the UI into its own group
        // so it doesn't get disabled when we change levels
        networkView.group = 1;

        this.m_View = GetComponent<CoherentUIView>();
        this.m_View.OnViewCreated += (view) => {this.viewReady = true;};
        this.m_View.OnViewDestroyed += () => {this.viewReady = false;};

        this.playerManager.OnPlayerJoined += this.PlayerJoinedEvent;
        this.playerManager.OnPlayerLeft += this.PlayerLeftEvent;
        this.playerManager.OnPlayerUpdated += this.PlayerUpdatedEvent;

        this.gameManager.OnGameStarted += (sender) => {
            if(this.viewReady)
                this.m_View.View.TriggerEvent("respondToStartGame");
        };

        this.gameManager.OnGameEnded += (sender) => {
            if(this.viewReady)
                this.m_View.View.TriggerEvent("respondToEndGame");
        };

        // Make the Coherent View receive input
        if(this.m_View)
            this.m_View.ReceivesInput = true;
    }
Esempio n. 47
0
 public void OnEnable()
 {
     m_Target = target as CoherentUIView;
     m_Fields = CoherentExposeProperties.GetProperties(m_Target);
 }
Esempio n. 48
0
	public void OnEnable() {
		m_Target = target as CoherentUIView;
		m_Fields = CoherentExposeProperties.GetProperties(m_Target);
	}
    private void TrackInputFocus()
    {
                #if COHERENT_UNITY_STANDALONE
        if (m_MainCamera == null)
        {
            m_MainCamera = Camera.main;
            if (m_MainCamera == null)
            {
                return;
            }
        }

        bool isClick = Input.GetMouseButtonDown(0);
        if (!m_SystemHasFocusedView && !isClick)
        {
            // Do nothing if the left mouse button isn't clicked
            // (and there is no focused view; if there is, we need to track the mouse)
            return;
        }

        CoherentUIView cameraView = m_MainCamera.gameObject.GetComponent <CoherentUIView>();
        if (cameraView && cameraView.ClickToFocus)
        {
            var view = cameraView.View;
            if (view != null)
            {
                var normX = (Input.mousePosition.x / cameraView.Width);
                var normY = (1 - Input.mousePosition.y / cameraView.Height);

                normX = normX *
                        cameraView.WidthToCamWidthRatio(m_MainCamera.pixelWidth);

                normY = 1 - ((1 - normY) *
                             cameraView.HeightToCamHeightRatio(m_MainCamera.pixelHeight));

                if (normX >= 0 && normX <= 1 && normY >= 0 && normY <= 1)
                {
                    view.IssueMouseOnUIQuery(normX, normY);
                    view.FetchMouseOnUIQuery();
                    if (view.IsMouseOnView())
                    {
                        if (isClick)
                        {
                            // Reset input processing for all views
                            foreach (var item in m_Views)
                            {
                                item.ReceivesInput = false;
                            }
                            // Set input to the clicked view
                            cameraView.ReceivesInput = true;
                            SetViewFocused(true);
                        }

                        return;
                    }
                }
            }
        }

        // Activate input processing for the view below the mouse cursor
        RaycastHit hitInfo;
        if (Physics.Raycast(m_MainCamera.ScreenPointToRay(Input.mousePosition), out hitInfo))
        {
            CoherentUIView viewComponent = hitInfo.collider.gameObject.GetComponent(typeof(CoherentUIView)) as CoherentUIView;
            if (viewComponent == null)
            {
                viewComponent = hitInfo.collider.gameObject.GetComponentInChildren(typeof(CoherentUIView)) as CoherentUIView;
            }

            if (viewComponent != null && viewComponent.ClickToFocus)
            {
                if (isClick)
                {
                    // Reset input processing for all views
                    foreach (var item in m_Views)
                    {
                        item.ReceivesInput = false;
                    }
                    // Set input to the clicked view
                    viewComponent.ReceivesInput = true;
                    SetViewFocused(true);
                }

                viewComponent.SetMousePosition(
                    (int)(hitInfo.textureCoord.x * viewComponent.Width),
                    (int)(hitInfo.textureCoord.y * viewComponent.Height));

                return;
            }
        }

        // If neither the HUD nor an object was clicked, clear the focus
        if (m_SystemHasFocusedView && isClick)
        {
            // Reset input processing for all views
            foreach (var item in m_Views)
            {
                item.ReceivesInput = false;
            }
            SetViewFocused(false);
        }
                #endif
    }
Esempio n. 50
0
	internal void AddView(CoherentUIView view)
	{
		m_Views.Add(view);
	}
Esempio n. 51
0
		public UnityViewListener(CoherentUIView component, int width, int height)
		{
	        m_ViewComponent = component;

			#if UNITY_EDITOR || COHERENT_UNITY_STANDALONE
			m_Width = width;
			m_Height = height;
			#endif

			m_ObjectsToDestroy = new List<Object>();
			
			HasModalDialogOpen = false;

			this.ViewCreated += new CoherentUI_OnViewCreated(OnViewCreatedHandler);
			
			if (component.ShowJavaScriptDialogs)
			{
				this.JavaScriptMessage += new CoherentUI_OnJavaScriptMessage(OnJavaScriptMessageHandler);
				#if UNITY_EDITOR || COHERENT_UNITY_STANDALONE
				this.GetAuthCredentials += new CoherentUI_OnGetAuthCredentials(OnGetAuthCredentialsHandler);
				#endif
			}

			#if COHERENT_SIMULATE_MOBILE_IN_EDITOR || COHERENT_SIMULATE_MOBILE_IN_PLAYER
			this.ReadyForBindings += (frameId, path, isMainFrame) =>
			{
				m_View.BindCall("__couiTouchEvent",
				(System.Action<int, int, int, int>)this.NewTouchEventHandler);
			};
			#endif

			#if UNITY_ANDROID && !UNITY_EDITOR
			this.FailLoad += (frame, path, isMain, errorMsg) =>
			{
				if (FailLoadSubscribersCount() > 1)
				{
					// The user is handling FailLoads
					return;
				}

				if (!path.StartsWith("coui"))
				{
					Debug.LogError("URL \"" + path + "\" failed loading!");
					return;
				}

				if (m_View == null)
				{
					Debug.LogError("Coherent UI View is null inside " +
						"FailLoad handler for url \" + path +\"!");
					return;
				}

				string escapedData = System.Uri.EscapeUriString(
					"<!DOCTYPE html>" +
					"<html lang=\"en\">" +
					"<head><title>Resource not available</title></head>" +
					"<body style=\"background-color: rgba(0, 0, 0, 0);" +
						"color: #e35;\">" +
					"<h1>Unable to find coui resource to be loaded!</h1>" +
					"<br/><br/>" +
					"<div style=\"font-size: 140%;\">" +
					"Please ensure that you didn't use 'Build & run' since " +
					"this function is not supported. Use 'Build' or an " +
					"Eclipse project instead." +
					"<br/><br/>" +
					"If you're building on a Mac, please also make sure that " +
					"the aapt executable in the <b>Assets/CoherentUI/Editor/" +
					"apktool-1.5.2</b> folder has executable permissions so " +
					"the repack step is successful." +
					"</div>" +
					"</body></html>");

				m_View.Load("data:text/html;charset=utf-8," + escapedData);
			};
			#endif
		}
Esempio n. 52
0
	internal bool RemoveView(CoherentUIView view)
	{
		return m_Views.Remove(view);
	}
 internal void AddView(CoherentUIView view)
 {
     m_Views.Add(view);
 }
        public UnityViewListener(CoherentUIView component, int width, int height)
        {
            m_ViewComponent = component;

                        #if COHERENT_UNITY_STANDALONE
            m_Width  = width;
            m_Height = height;
                        #endif

            m_ObjectsToDestroy = new List <Object>();

            HasModalDialogOpen = false;

            this.ViewCreated += new CoherentUI_OnViewCreated(OnViewCreatedHandler);

            if (component.ShowJavaScriptDialogs)
            {
                this.JavaScriptMessage += new CoherentUI_OnJavaScriptMessage(OnJavaScriptMessageHandler);
                                #if COHERENT_UNITY_STANDALONE
                this.GetAuthCredentials += new CoherentUI_OnGetAuthCredentials(OnGetAuthCredentialsHandler);
                                #endif
            }

                        #if COHERENT_SIMULATE_MOBILE_IN_EDITOR || COHERENT_SIMULATE_MOBILE_IN_PLAYER
            this.ReadyForBindings += (frameId, path, isMainFrame) =>
            {
                m_View.BindCall("__couiTouchEvent",
                                (System.Action <int, int, int, int>) this.NewTouchEventHandler);
            };
                        #endif

                        #if UNITY_ANDROID && !UNITY_EDITOR
            this.FailLoad += (frame, path, isMain, errorMsg) =>
            {
                if (FailLoadSubscribersCount() > 1)
                {
                    // The user is handling FailLoads
                    return;
                }

                if (!path.StartsWith("coui"))
                {
                    Debug.LogError("URL \"" + path + "\" failed loading!");
                    return;
                }

                if (m_View == null)
                {
                    Debug.LogError("Coherent UI View is null inside " +
                                   "FailLoad handler for url \" + path +\"!");
                    return;
                }

                string escapedData = System.Uri.EscapeUriString(
                    "<!DOCTYPE html>" +
                    "<html lang=\"en\">" +
                    "<head><title>Resource not available</title></head>" +
                    "<body style=\"background-color: rgba(0, 0, 0, 0);" +
                    "color: #e35;\">" +
                    "<h1>Unable to find coui resource to be loaded!</h1>" +
                    "<br/><br/>" +
                    "<div style=\"font-size: 140%;\">" +
                    "Please ensure that you didn't use 'Build & run' since " +
                    "this function is not supported. Use 'Build' or an " +
                    "Eclipse project instead." +
                    "<br/><br/>" +
                    "If you're building on a Mac, please also make sure that " +
                    "the aapt executable in the <b>Assets/CoherentUI/Editor/" +
                    "apktool-1.5.2</b> folder has executable permissions so " +
                    "the repack step is successful." +
                    "</div>" +
                    "</body></html>");

                m_View.Load("data:text/html;charset=utf-8," + escapedData);
            };
                        #endif
        }
	private void CalculateScaledMouseCoordinates(ref MouseEventData data,
		CoherentUIView view,
		bool invertY)
	{
		var camWidth = view.gameObject.camera.pixelWidth;
		var camHeight = view.gameObject.camera.pixelHeight;

		float factorX = view.WidthToCamWidthRatio(camWidth);
		float factorY = view.HeightToCamHeightRatio(camHeight);

		float y = (invertY)? (camHeight - data.Y) : data.Y;

		data.X = (int)(data.X * factorX);
		data.Y = (int)(y * factorY);
	}