Example #1
0
        /// <summary>
        /// Sends a message with the current rotation of the selected mirror.
        /// <para>
        /// The selected mirror should not be null.
        /// </para>
        /// </summary>
        public void SendRotationUpdate()
        {
            Assert.IsNotNull(this.SelectedMirror, "SendRotationUpdate: No Mirror Selected");
            RemoteMarker marker   = this.SelectedMirror.GetComponent <RemoteMarker>();
            float        rotation = marker.ObjectRotation;

            RotationUpdate update = new RotationUpdate(UpdateType.UpdateRotation, rotation, marker.Id);

            this.SendMessage("OnRotationChanged", update);
            this.SendMessage("OnRotationUpdate", update);
        }
Example #2
0
        /// <summary>
        /// Constructs a correct type of marker for the level.
        /// </summary>
        /// <param name="level">The level GameObject to assign the Marker to.</param>
        /// <param name="properties">The <see cref="LevelProperties"/> object describing the level.</param>
        /// <returns>The constructed marker.</returns>
        private Marker ConstructMarker(GameObject level, LevelProperties properties)
        {
            Vector3 position = new Vector3(
                (this.BoardSize.x - properties.Width) / 2,
                0,
                -(this.BoardSize.y - properties.Height) / 2);

            Debug.Log("Level position: " + position);

            GameObject levelMarker = new GameObject("LevelMarker");

            this.AddBoard(levelMarker);

            if (GameObject.Find("MetaWorld") == null)
            {
                RemoteMarker remoteMarker = levelMarker.AddComponent <RemoteMarker>();
                remoteMarker.Id          = LevelMarkerID;
                remoteMarker.ScaleFactor = 1f;
                GameObject.Find("RemoteController")
                .GetComponent <RemoteMarkerHolder>()
                .AddMarker(remoteMarker as RemoteMarker);
            }
            else
            {
                LocalMarker localMarker = levelMarker.AddComponent <LocalMarker>();
                localMarker.Id = LevelMarkerID;
                GameObject.Find("MetaWorld")
                .GetComponent <LocalMarkerHolder>()
                .AddMarker(localMarker as LocalMarker);
            }

            level.transform.parent        = levelMarker.transform;
            level.transform.localPosition = position;

            Marker marker = levelMarker.GetComponent <Marker>();

            // Simulate a PositionUpdate from the server.
            PositionUpdate update = new PositionUpdate(UpdateType.UpdatePosition, Vector3.zero, 0, LevelMarkerID);

            marker.RemotePosition       = new MarkerPosition(update);
            marker.RemotePosition.Scale = Vector3.one;

            return(marker);
        }