예제 #1
0
        /// <summary>
        /// Initializes the LocalPlayerSimulator and simulates a board.
        /// </summary>
        public void Start()
        {
            HeadHolder holder = this.transform.parent.GetComponent <HeadHolder>();

            this.marker = holder.GetPlayer(FakeOverviewPlayerId);
            holder.Follow(this.marker);
        }
예제 #2
0
        /// <summary>
        /// Changes the tracked player to the next player in the sequence.
        /// </summary>
        public void NextTracking()
        {
            RemotePlayerMarker marker = null;
            bool takeNextEntry        = false;

            foreach (var entry in this.players)
            {
                if (takeNextEntry)
                {
                    marker = entry.Value;
                }

                if (entry.Key == this.trackingIndex)
                {
                    takeNextEntry = true;
                }
            }

            if (marker == null && this.players.Count > 0)
            {
                // We reached the end, so take the first one.
                marker = this.players.First().Value;
            }

            if (marker != null)
            {
                this.holder.PlayerToFollow = marker;
                trackingIndex = marker.Id;
            }
        }
예제 #3
0
        /// <summary>
        /// Gets a local player by its id.
        /// </summary>
        /// <param name="id">The player id.</param>
        /// <returns>The <see cref="RemotePlayerMarker"/> that represents the player.</returns>
        public RemotePlayerMarker GetPlayer(int id)
        {
            if (!this.players.ContainsKey(id))
            {
                if (this.referenceHead == null)
                {
                    this.referenceHead = Resources.Load("Prefabs/HEAD") as GameObject;
                }

                GameObject         head   = GameObject.Instantiate(this.referenceHead);
                RemotePlayerMarker marker = head.GetComponent <RemotePlayerMarker>();
                Assert.IsNotNull(marker, "Reference Player Marker has no `RemotePlayerMarker` script attached");

                this.players.Add(id, marker);
                marker.transform.SetParent(this.transform);

                marker.Id = PlayerIdOffset + id;
                if (this.holder == null)
                {
                    this.holder = gameObject.GetComponent <RemoteMarkerHolder>();
                }

                this.holder.AddMarker(marker);
                this.Follow(marker);
            }

            return(this.players[id]);
        }
예제 #4
0
        /// <summary>
        /// Starts following the given RemotePlayerMarker as camera origin.
        /// </summary>
        /// <param name="player">The player to follow.</param>
        public void Follow(RemotePlayerMarker player)
        {
            if (this.OverviewMarker == null)
            {
                this.OverviewMarker = this.holder.PlayerToFollow;
            }

            this.holder.PlayerToFollow = player;
        }
예제 #5
0
        /// <summary>
        /// Initializes the LocalPlayerSimulator and simulates a board.
        /// </summary>
        public void Start()
        {
            HeadHolder holder = this.transform.parent.GetComponent <HeadHolder>();

            this.marker = holder.GetPlayer(this.PlayerId);
            holder.Follow(this.marker);

            this.StartCoroutine(this.transform.parent.GetComponent <BoardResizer>().UpdateBoardSize(this.SimulatedBoardSize));
            LevelManager manager = this.transform.parent.GetComponent <LevelManager>();

            manager.BoardSize = this.SimulatedBoardSize;
            manager.RestartLevel();
        }
예제 #6
0
        /// <summary>
        /// Places the given <see cref="RemotePlayerMarker"/> at the position and
        /// rotation indicated by the <see cref="ARViewUpdate"/>.
        /// </summary>
        /// <param name="head">The <see cref="RemotePlayerMarker"/>.</param>
        /// <param name="playerInfo">The <see cref="ARViewUpdate"/>.</param>
        public void PlacePlayerHead(RemotePlayerMarker head, ARViewUpdate playerInfo)
        {
            Assert.IsNotNull(head);
            Assert.IsNotNull(playerInfo);
            int markerId = playerInfo.Id + PlayerIdOffset;

            Vector3 position = playerInfo.Position;

            //Quaternion direction = Quaternion.Euler(playerInfo.Rotation);
            Quaternion direction = Quaternion.LookRotation(playerInfo.Rotation - position);

            if (this.trackingIndex == -1)
            {
                this.NextTracking();
            }

            this.GetPlayer(playerInfo.Id).RemotePosition =
                new MarkerPosition(position, direction, DateTime.Now, Vector3.one, markerId);

            //Debug.LogWarning("LOCAL " + position);
        }