Пример #1
0
        public void Play()
        {
            BodyPart randomBodyPart = (BodyPart)rnd.Next(Enum.GetNames(typeof(BodyPart)).Length);

            HitEnemyBodyPart = BlockBodyPart = randomBodyPart;
            Played?.Invoke(this, BlockBodyPart);
        }
Пример #2
0
 public void UserProtect(BodyPart bodyPart)
 {
     if (humanTurn)
     {
         BlockBodyPart = bodyPart;
         Played?.Invoke(this, bodyPart);
     }
 }
Пример #3
0
 public void UserAttack(BodyPart bodyPart)
 {
     if (humanTurn)
     {
         HitEnemyBodyPart = bodyPart;
         Played?.Invoke(this, bodyPart);
     }
 }
Пример #4
0
        public Task NotifyPlay()
        {
            if (Played != null)
            {
                return(Played.Invoke());
            }

            return(Task.CompletedTask);
        }
Пример #5
0
    public void Play(int multiplier = 1)
    {
        Modifier = multiplier;

        _isPlaying   = true;
        _isRewinding = false;

        Played?.Invoke(this, EventArgs.Empty);
    }
        void OnResumed(PlayableDirector director)
        {
            if (m_ControlsMarsLifecycle)
            {
                MarsTime.Play();
            }

            PlaybackPauseTime = m_Duration;
            m_Paused          = false;
            Played?.Invoke();
        }
Пример #7
0
 public void Play()
 {
     _videoPlayer.Play();
     Played?.Invoke();
 }
Пример #8
0
        public void Play(int index)
        {
            // Check if he can play
            if (IsGameOver)
            {
                throw new GameException(GameErrorType.GameOver);
            }
            if (index <= 0 && index >= 8)
            {
                throw new GameException(GameErrorType.IndexOutOfRange);
            }
            if (plays[index] != GamePlay.None)
            {
                throw new GameException(GameErrorType.IndexPlayedOn);
            }

            // Play
            plays[index] = CurrentPlayer;


            // Chack if current player wins
            foreach (var winLine in Winners)
            {
                if (plays[winLine[0]] == GamePlay.None || plays[winLine[1]] == GamePlay.None || plays[winLine[2]] == GamePlay.None)
                {
                    continue;
                }

                if (plays[winLine[0]] == plays[winLine[1]] && plays[winLine[1]] == plays[winLine[2]])
                {
                    Winning = new GameWin(CurrentPlayer, winLine);

                    IsGameOver = true;
                    Played?.Invoke(this, EventArgs.Empty);
                    GameOver?.Invoke(this, new GameOverEventArgs(Winning));
                    return;
                }
            }

            // Chack if game is over with no winner
            if (!plays.Contains(GamePlay.None) ||
                (!plays.Select((value, i) => new { value, index = i })
                 .Where((play) => Array.IndexOf(new int[] { 0, 1, 2, 6, 7, 8 }, play.index) > -1)
                 .Select(p => p.value).Contains(GamePlay.None) &&
                 plays[0] == plays[2] && plays[2] == plays[7] &&
                 plays[1] == plays[6] && plays[6] == plays[8]) ||
                (!plays.Select((value, i) => new { value, index = i })
                 .Where((play) => Array.IndexOf(new int[] { 0, 2, 3, 5, 6, 8 }, play.index) > -1)
                 .Select(p => p.value).Contains(GamePlay.None) &&
                 plays[0] == plays[5] && plays[5] == plays[6] &&
                 plays[2] == plays[3] && plays[3] == plays[8]))
            {
                Winning = new GameWin(GamePlay.None, null);

                IsGameOver = true;
                Played?.Invoke(this, EventArgs.Empty);
                GameOver?.Invoke(this, new GameOverEventArgs(Winning));
                return;
            }

            Played?.Invoke(this, EventArgs.Empty);
            // If not over get ready for next round
            CurrentPlayer = (GamePlay)((int)CurrentPlayer % 2 + 1);

            // Auto play if only one left
            if (plays.Where((p) => p == GamePlay.None).Count() == 1)
            {
                Play(plays.IndexOf(GamePlay.None));
            }
        }
        void OnEnable()
        {
            if (Director == null || Director.playableAsset == null)
            {
                Debug.LogError(
                    $"You must call {nameof(SetupFromRecordingInfo)} on {nameof(RecordedSessionDirector)} before enabling it");

                enabled = false;
                return;
            }

            IsStarting = true;
            m_Paused   = false;
            Director.RebuildGraph(); // Ensure new playables are created
            SetTime(0d);
            Director.Play();
            Director.played  += OnResumed;
            Director.paused  += OnPaused;
            Director.stopped += OnStopped;
            IsPlaying         = true;
            IsStarting        = false;
            Played?.Invoke();

            // Notifications do not fire from manual timeline updates.
            // https://answers.unity.com/questions/1665172/markers-and-signal-emitters-not-working-when-timel.html
            // We must sort notifications by time and then directly send them to receivers for manual evaluation.
            var playableGraph = Director.playableGraph;
            var outputCount   = playableGraph.GetOutputCount();

            m_TimelineNotifications.Clear();
            m_NotificationReceivers.Clear();
            m_NotificationsSent = 0;
            for (var i = 0; i < outputCount; i++)
            {
                var output   = playableGraph.GetOutput(i);
                var playable = output.GetSourcePlayable().GetInput(i);
                var track    = output.GetReferenceObject() as TrackAsset;
                if (track == null || !(track is MarkerTrack))
                {
                    continue;
                }

                var targetObject = Director.GetGenericBinding(track);
                if (targetObject == null)
                {
                    continue;
                }

                var targetGameObject = targetObject as GameObject;
                var targetComponent  = targetObject as Component;
                if (targetGameObject == null && targetComponent == null)
                {
                    continue;
                }

                var notificationReceivers = new List <INotificationReceiver>();
                if (targetGameObject != null)
                {
                    targetGameObject.GetComponents(notificationReceivers);
                }
                else
                {
                    targetComponent.GetComponents(notificationReceivers);
                }

                m_NotificationReceivers[playable] = notificationReceivers;

                foreach (var marker in track.GetMarkers())
                {
                    if (!(marker is INotification notification))
                    {
                        continue;
                    }

                    m_TimelineNotifications.Add(new NotificationData
                    {
                        Notification = notification,
                        Time         = marker.time,
                        Origin       = playable
                    });
                }
            }

            m_TimelineNotifications.Sort((first, second) => first.Time.CompareTo(second.Time));
        }