コード例 #1
0
        public void StateChanged(IMachineStateComponent <RoundState> component, RoundState previous)
        {
            //if (!(sender is IRound round)) return;
            var round = component;

            Enabled = round.State.Equals(RoundState.WaitingForBallServe);
        }
コード例 #2
0
        public void StateChanged(IMachineStateComponent <MatchState> sender, MatchState previousState)
        {
            if (!(sender is IMatch match))
            {
                return;
            }

            if (match.State == MatchState.InstanciatedRound)
            {
                Enabled = true;
                match.CurrentRound.StateChanges += StateChanged;
            }
            else if (match.State == MatchState.FindingFirstServer)
            {
                Visible         = true;
                TheBall.Visible = true;
                currentTeam     = (new Random().Next(2) == 1) ? Team.Blue : Team.Red;
                timerSwitcharooDo.Reset(true);
                timerEndSwitcharoo.IntervalMs = TimeSpan.FromMilliseconds(new Random().Next(2000, 3001)).TotalMilliseconds;
                timerEndSwitcharoo.Reset(true);
                timerEndScaling.Reset(false);
            }
            else if (previousState == MatchState.FindingFirstServer)
            {
                match.CurrentRound.StateChanges -= StateChanged;
            }
        }
コード例 #3
0
 public void StateChanged(IMachineStateComponent <RoundState> round, RoundState previousState)
 {
     if (round.State != RoundState.NotStarted)
     {
         Enabled = false;
         Visible = false;
     }
 }
コード例 #4
0
ファイル: ColoredBlock.cs プロジェクト: fdrobidoux/MonoTycoon
        private void Match_MatchStateChanges(IMachineStateComponent <MatchState> component, MatchState previous)
        {
            if (!(component is IMatch match))
            {
                return;
            }

            Enabled = Visible = match.State.Equals(MatchState.NotStarted);
        }
コード例 #5
0
ファイル: Ball.cs プロジェクト: fdrobidoux/MonoTycoon
        public void StateChanged(IMachineStateComponent <MatchState> component, MatchState previousState)
        {
            if (!(component is Match match))
            {
                return;
            }

            Visible = match.State.Any(MatchState.FindingFirstServer, MatchState.InProgress);
        }
コード例 #6
0
        public void StateChanged(IMachineStateComponent <MatchState> component, MatchState previousState)
        {
            if (!(component is IMatch match))
            {
                return;
            }

            if (match.State == MatchState.InstanciatedRound)
            {
                match.CurrentRound.StateChanges += StateChanged;
            }
        }
コード例 #7
0
 /// <summary>
 /// ROUND EVENTS
 /// </summary>
 public void StateChanged(IMachineStateComponent <RoundState> component, RoundState previous)
 {
     if (_round.State.Equals(RoundState.WaitingForBallServe))
     {
         Paddle servingPaddle = Components.OfType <Paddle>().Where((x) => x.Team == _round.ServingTeam).Single();
         ServeBallHandler.AssignRequiredEntities(Ball, servingPaddle);
     }
     else if (previous.Equals(RoundState.WaitingForBallServe))
     {
         ServeBallHandler.FreeRequiredEntities();
     }
 }
コード例 #8
0
        private void OnMatchStateChanges(IMachineStateComponent<MatchState> component, MatchState previous)
        {
            if (!(component is IMatch match))
                return;

            //_moving = (e.Modified.Any(MatchState.InProgress, MatchState.DemoMode));

            if (match.State == MatchState.FindingFirstServer)
            {
                match.CurrentRound.StateChanges += OnRoundStateChanges;
            }
        }
コード例 #9
0
 /// <summary>
 /// MATCH EVENTS
 /// </summary>
 public void StateChanged(IMachineStateComponent <MatchState> component, MatchState previous)
 {
     if (_match.State == MatchState.InstanciatedRound)
     {
         _match.CurrentRound.StateChanges += StateChanged;
         foreach (IRoundStateSensitive roundSensitive in Components.OfType <IRoundStateSensitive>())
         {
             _round.StateChanges += roundSensitive.StateChanged;
         }
     }
     else if (_match.State == MatchState.FindingFirstServer)
     {
         MediaPlayer.Volume = 0.5f;
         MediaPlayer.Play(music);
     }
 }
コード例 #10
0
        private void OnRoundStateChanges(IMachineStateComponent<RoundState> component, RoundState e)
        {
			if (!(component is IRound round))
				return;

            if (round.State == RoundState.NotStarted)
            {
                Enabled = false;
                Visible = false;
            }
            else if (round.State == RoundState.WaitingForBallServe)
            {
                Visible = true;
                Enabled = true;
            }
        }
コード例 #11
0
ファイル: Ball.cs プロジェクト: fdrobidoux/MonoTycoon
        public void StateChanged(IMachineStateComponent <RoundState> component, RoundState previousState)
        {
            if (!(component is IRound round))
            {
                return;
            }

            Visible = !round.State.Equals(RoundState.NotStarted);
            Enabled = round.State.Equals(RoundState.InProgress);

            if (round.State.Equals(RoundState.WaitingForBallServe))
            {
                Transform.Scale = 1f;
                Visible         = true;
            }
        }
コード例 #12
0
ファイル: ScoreDisplay.cs プロジェクト: fdrobidoux/MonoTycoon
 public void StateChanged(IMachineStateComponent <MatchState> match, MatchState previousState)
 {
     Enabled = (!match.State.Any(STATES_WHEN_DISABLED));
 }