Esempio n. 1
0
        static string GetStateColor(JudgeState state)
        {
            switch (state)
            {
            case JudgeState.Accepted:
                return("forestgreen");

            case JudgeState.WrongAnswer:
                return("red");

            case JudgeState.CompileError:
                return("#004488");

            case JudgeState.TimeLimitExceeded:
            case JudgeState.MemoryLimitExceeded:
                return("sandybrown");

            case JudgeState.RuntimeError:
                return("darkorchid");

            case JudgeState.SystemError:
                return("grey");

            case JudgeState.Pending:
                return("#6cf");

            case JudgeState.Judging:
                return("blue");

            case JudgeState.Compiling:
                return("#f1e05a");
            }
            return("black");
        }
Esempio n. 2
0
    private void SetJudgeString(JudgeState state, NotesScript note)
    {
        switch (state)
        {
        case JudgeState.Great:
            combo++;
            judgeStr.text = "GREAT " + combo.ToString();
            break;

        case JudgeState.Good:
            combo++;
            judgeStr.text = "GOOD " + combo.ToString();
            break;

        case JudgeState.Bad:
            combo         = 0;
            judgeStr.text = "BAD";
            break;

        case JudgeState.AUTO:
            combo++;
            judgeStr.text = "AUTO " + combo.ToString();
            break;
        }
    }
Esempio n. 3
0
 public StateTick(AnalogEntity root, AnalogEntity segment, time_t pos, JudgeState state)
 {
     RootEntity    = root;
     SegmentEntity = segment;
     Position      = pos;
     State         = state;
 }
Esempio n. 4
0
    public void ReplaceJudgeSameState(JudgeState newState)
    {
        var index     = GameComponentsLookup.JudgeSameState;
        var component = (JudgeSameState)CreateComponent(index, typeof(JudgeSameState));

        component.state = newState;
        ReplaceComponent(index, component);
    }
    //セットするよ
    public void SetActiveNotes(int laneNum, JudgeState judge = JudgeState.none)
    {
        bool LongEnd = false;

        if (activeNotes[laneNum] != null)
        {
            NotesScript noteInfo = activeNotes[laneNum].GetComponent <NotesScript>();

            ScoreIndex noteType = noteInfo.type;

            switch (noteType)
            {
            case ScoreIndex.SIMPLE:
                Destroy(activeNotes[laneNum]);
                break;

            case ScoreIndex.LONG:
                if (judge == JudgeState.Bad)
                {
                    Destroy(activeNotes[laneNum]);
                }
                else
                {
                    LongEnd = true;
                }
                break;

            case ScoreIndex.LONG_END:
                Destroy(activeNotes[laneNum].transform.parent.gameObject);
                break;
            }
        }

        if (LongEnd)
        {
            activeNotes[laneNum] = activeNotes[laneNum].GetComponent <NotesScript>().LNendObj;
            return;
        }

        if (noteObjects[laneNum].Count != 0)
        {
            activeNotes[laneNum] = noteObjects[laneNum].Dequeue();
        }
        else
        {
            activeNotes[laneNum] = null;
        }
    }
Esempio n. 6
0
        public void UserReleased(time_t position)
        {
            DespawnKeyBeam?.Invoke(Label);

            switch (m_state)
            {
            case JudgeState.Idle:
            case JudgeState.HoldOff: break;     // do nothing when released

            case JudgeState.HoldOn:
            {
                OnHoldReleased?.Invoke(position, m_currentStateTick.Entity);

                m_state = JudgeState.HoldOff;

                IsBeingPlayed = false;
            } break;
            }
        }
Esempio n. 7
0
    private void AddScore(JudgeState state, NotesScript note)
    {
        switch (state)
        {
        case JudgeState.Great:
            score += 2;
            break;

        case JudgeState.Good:
            score += 1;
            break;

        case JudgeState.AUTO:
            score += 2;
            break;

        default:
            break;
        }
    }
Esempio n. 8
0
    public void AddJudge(JudgeState state, NotesScript note, float diff = 0.0f)
    {
        AddScore(state, note);
        SetJudgeString(state, note);
        string FS;

        if (diff >= 0.0f)
        {
            FS = "FAST";
        }
        else
        {
            FS = "SLOW";
        }
        switch (state)
        {
        case JudgeState.Great:
            AddJudge_Great();
            FSStr.text = "";
            break;

        case JudgeState.Good:
            AddJudge_Good();
            FSStr.text = FS;
            break;

        case JudgeState.Bad:
            AddJudge_Bad();
            FSStr.text = FS;
            if (note.type == ScoreIndex.LONG)
            {
                AddJudge_Bad();
            }
            break;

        case JudgeState.AUTO:
            AddJudge_Great();
            break;
        }
    }
Esempio n. 9
0
        void ScoreSubmit(JudgeState state)
        {
            var score = ScoreBoardController.Instance;

            switch (state)
            {
            case JudgeState.Great:
                score.Great++;
                break;

            case JudgeState.Good:
                score.Good++;
                break;

            case JudgeState.Ok:
                score.Ok++;
                break;

            case JudgeState.Bad:
                score.Bad++;
                break;
            }
        }
Esempio n. 10
0
 // Use this for initialization
 public void Start()
 {
     instance = this;
     img      = this.GetComponent <SpriteRenderer> ();
     for (int i = 0; i < 4; i++)
     {
         for (int j = 0; j < 4; j++)
         {
             table [i, j] = 0;
         }
     }
     while (true)
     {
         int x  = Random.Range(0, 4);
         int y  = Random.Range(0, 4);
         int ti = Random.Range(1, 3);
         if (table [x, y] == 0)
         {
             table [x, y] = ti * 2;
             break;
         }
     }
 }
Esempio n. 11
0
 public StateTick(ButtonEntity entity, time_t pos, JudgeState state)
 {
     Entity   = entity;
     Position = pos;
     State    = state;
 }
Esempio n. 12
0
        public JudgeResult?UserPressed(time_t position)
        {
            // This check just makes sure that we can process ticks.
            // If there are no state ticks, there should never be score ticks left.
            if (HasStateTicks)
            {
                Debug.Assert(HasScoreTicks);
            }
            else
            {
                SpawnKeyBeam?.Invoke(Label, JudgeKind.Passive, false);
                return(null);
            }

            switch (m_state)
            {
            case JudgeState.Idle:
            {
                var nextStateTick = NextStateTick;

                time_t difference    = position - (nextStateTick.Position + JudgementOffset);
                time_t absDifference = Math.Abs((double)difference);

                if (nextStateTick.State == JudgeState.ChipAwaitPress && absDifference <= m_chipMissRadius)
                {
                    var scoreTick = NextScoreTick;

                    Debug.Assert(scoreTick.Kind == TickKind.Chip);
                    Debug.Assert(scoreTick.Position == nextStateTick.Position);

                    // `difference` applies to both ticks, don't recalculate

                    JudgeResult result;
                    if (absDifference <= m_chipPerfectRadius)
                    {
                        result = new JudgeResult(difference, JudgeKind.Perfect);
                    }
                    else if (absDifference <= m_chipCriticalRadius)
                    {
                        result = new JudgeResult(difference, JudgeKind.Critical);
                    }
                    else if (absDifference <= m_chipNearRadius)
                    {
                        result = new JudgeResult(difference, JudgeKind.Near);
                    }
                    // TODO(local): Is this how we want to handle misses?
                    else
                    {
                        result = new JudgeResult(difference, JudgeKind.Bad);
                    }

                    OnTickProcessed?.Invoke(scoreTick.Entity, position, result, difference < 0);
                    OnChipPressed?.Invoke(position, scoreTick.Entity);
                    SpawnKeyBeam?.Invoke(scoreTick.Entity.Lane, result.Kind, difference < 0);

                    AdvanceStateTick();
                    AdvanceScoreTick();

                    // state stays idle after a chip press, chips are instantaneous

                    IsBeingPlayed = true;

                    return(result);
                }
                else if (nextStateTick.State == JudgeState.HoldAwaitPress && absDifference <= m_holdActivateRadius)
                {
                    OnHoldPressed?.Invoke(position, nextStateTick.Entity);

                    AdvanceStateTick();
                    // No need to advance a score tick, we haven't judged anything

                    // state is `hold on` because ofc we pressed the hold!
                    m_state            = JudgeState.HoldOn;
                    m_currentStateTick = nextStateTick;

                    IsBeingPlayed = true;
                }

                // do nothing when pressed otherwise
                else
                {
                    SpawnKeyBeam?.Invoke(Label, JudgeKind.Passive, false);
                }
            } break;

            case JudgeState.HoldOff:
            {
                OnHoldPressed?.Invoke(position, m_currentStateTick.Entity);

                m_state = JudgeState.HoldOn;

                IsBeingPlayed = true;
            } break;

            case JudgeState.HoldOn: throw new InvalidOperationException();
            }

            return(null);
        }
Esempio n. 13
0
        protected override void AdvancePosition(time_t position)
        {
            // This check just makes sure that we can process ticks.
            // If there are no state ticks, there should never be score ticks left.
            if (HasStateTicks)
            {
                Debug.Assert(HasScoreTicks);
            }
            else
            {
                return;
            }

            // Now, if we have ticks we can continue

            switch (m_state)
            {
            case JudgeState.Idle:
            {
                var nextStateTick = NextStateTick;

                time_t difference = position - (nextStateTick.Position + JudgementOffset);

                // check missed chips
                if (nextStateTick.State == JudgeState.ChipAwaitPress && difference > m_chipMissRadius)
                {
                    var scoreTick = NextScoreTick;

                    Debug.Assert(scoreTick.Kind == TickKind.Chip);
                    Debug.Assert(scoreTick.Position == nextStateTick.Position);

                    OnTickProcessed?.Invoke(scoreTick.Entity, position, new JudgeResult(m_chipMissRadius, JudgeKind.Miss), false);

                    AdvanceStateTick();
                    AdvanceScoreTick();

                    IsBeingPlayed = false;
                }
                else if (nextStateTick.State == JudgeState.HoldAwaitPress && difference > 0)
                {
                    m_state = JudgeState.HoldOff;

                    AdvanceStateTick();
                    m_currentStateTick = nextStateTick;

                    IsBeingPlayed = false;
                }
            } break;

            case JudgeState.HoldOn:
            case JudgeState.HoldOff:
            {
                var nextScoreTick = NextScoreTick;
                Debug.Assert(nextScoreTick.Entity == m_currentStateTick.Entity);

                if (position - (nextScoreTick.Position + JudgementOffset) >= 0)
                {
                    var resultKind = IsBeingPlayed ? JudgeKind.Passive : JudgeKind.Miss;
                    OnTickProcessed?.Invoke(nextScoreTick.Entity, nextScoreTick.Position, new JudgeResult(0, resultKind), false);

                    AdvanceScoreTick();
                }

                var nextStateTick = NextStateTick;
                if (nextStateTick.State == JudgeState.HoldAwaitRelease && position - (nextStateTick.Position + JudgementOffset) >= 0)
                {
                    AdvanceStateTick();

                    m_state            = JudgeState.Idle;
                    m_currentStateTick = null;
                }
            } break;
            }
        }
Esempio n. 14
0
        protected override void AdvancePosition(time_t position)
        {
            time_t timeDelta = position - m_lastUpdatePosition;

            m_lastUpdatePosition = position;

            if (!HasStateTicks && !HasScoreTicks)
            {
                return;
            }

            switch (m_state)
            {
            case JudgeState.Idle:
            {
                var nextStateTick = NextStateTick;
                while (position - (nextStateTick.Position + JudgementOffset) >= 0)
                {
                    if (nextStateTick.State == JudgeState.CursorReset)
                    {
                        AdvanceStateTick();

                        OnShowCursor?.Invoke();

                        CursorPosition = m_desiredCursorPosition = nextStateTick.RootEntity.InitialValue;
                        LaserRange     = nextStateTick.RootEntity.RangeExtended ? 2 : 1;

                        m_direction = 0;
                    }
                    else if (nextStateTick.State == JudgeState.LaserBegin)
                    {
                        AdvanceStateTick();

                        //LastLockTime = position;
                        m_direction = 0;
                        m_state     = nextStateTick.RootEntity.IsInstant ?
                                      (IsBeingPlayed ? JudgeState.ActiveOn : JudgeState.ActiveOff) :
                                      JudgeState.ActiveOn;
                        m_currentStateTick = nextStateTick;

                        // The first score tick happens at the same time as the laser start event,
                        //  hop straight over to the other case explicitly and let it process the score tick.
                        goto case JudgeState.ActiveOn;
                    }
                    else
                    {
                        break;
                    }

                    if (HasStateTicks)
                    {
                        nextStateTick = NextStateTick;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            break;

            case JudgeState.ActiveOn:
            case JudgeState.ActiveOff:
            {
                var segmentCheck = m_currentStateTick.SegmentEntity;
                while (segmentCheck != null && segmentCheck.AbsoluteEndPosition < position && segmentCheck.NextConnected is AnalogEntity next)
                {
                    segmentCheck = next;
                }

                m_desiredCursorPosition = segmentCheck.SampleValue(position);

                if (m_direction != 0)
                {
                    m_lockTimer -= timeDelta * m_lockTimerSpeed;
                }
                if (m_lockTimer < 0)
                {
                    m_lockTimer = 0;
                }

                if (AutoPlay)
                {
                    CursorPosition = m_desiredCursorPosition;
                }

                var nextStateTick = NextStateTick;
                while (position - (nextStateTick.Position + JudgementOffset) >= 0)
                {
                    if (nextStateTick.State == JudgeState.LaserEnd)
                    {
                        AdvanceStateTick();

                        OnHideCursor?.Invoke();

                        if (AutoPlay)
                        {
                            CursorPosition = m_desiredCursorPosition = nextStateTick.SegmentEntity.FinalValue;
                        }

                        m_state            = JudgeState.Idle;
                        m_currentStateTick = null;
                    }
                    else if (nextStateTick.State == JudgeState.SwitchDirection)
                    {
                        if (position > (nextStateTick.Position + JudgementOffset))
                        {
                            if (position - (nextStateTick.Position + JudgementOffset) >= m_directionChangeRadius)
                            {
                                AdvanceStateTick();

                                m_direction        = nextStateTick.SegmentEntity.DirectionSign;
                                m_currentStateTick = nextStateTick;

                                //Logger.Log($"Direction Switch ({ (m_direction == 1 ? "->" : (m_direction == -1 ? "<-" : "|")) }) Missed (by { position - (nextStateTick.Position + JudgementOffset) }): { nextStateTick.SegmentEntity.Position } ({ nextStateTick.SegmentEntity.AbsolutePosition })");

                                m_lockTimer = 0.0;
                            }
                            else
                            {
                                m_canControlCursorMovement = false;
                                //Logger.Log($"Prevented automatic cursor moving while locked: direction switch origin passed without being played ({ nextStateTick.SegmentEntity.Position })");

                                break;
                            }
                        }
                    }
                    else if (nextStateTick.State == JudgeState.SameDirectionSlam && position - (nextStateTick.Position + JudgementOffset) >= m_directionChangeRadius)
                    {
                        AdvanceStateTick();
                    }
                    else
                    {
                        break;
                    }

                    if (HasStateTicks)
                    {
                        nextStateTick = NextStateTick;
                    }
                    else
                    {
                        break;
                    }
                }

                if (IsLocked && m_canControlCursorMovement)
                {
                    CursorPosition = m_desiredCursorPosition;
                }

                IsBeingPlayed = IsLocked || MathL.Abs(m_desiredCursorPosition - CursorPosition) <= m_cursorActiveRange;
                if (IsBeingPlayed && m_direction == 0)
                {
                    m_lockTimer = m_lockDuration;     // NOTE(local): don't SetLocked, keep the timer decay speed
                    if (m_canControlCursorMovement)
                    {
                        CursorPosition = m_desiredCursorPosition;
                    }
                }

                if (HasScoreTicks)
                {
                    var nextScoreTick = NextScoreTick;
                    if (position - (nextScoreTick.Position + JudgementOffset) >= 0)
                    {
                        var resultKind = IsBeingPlayed ? JudgeKind.Passive : JudgeKind.Miss;
                        OnTickProcessed?.Invoke(nextScoreTick.Entity, nextScoreTick.Position, new JudgeResult(0, resultKind));

                        AdvanceScoreTick();
                    }
                }
            }
            break;
            }

            if (HasStateTicks && position - (NextStateTick.Position + JudgementOffset) >= 0)
            {
                //Logger.Log($"{ NextStateTick.State } :: { NextStateTick.SegmentEntity.Position } or { NextStateTick.Position }");
            }
        }
Esempio n. 15
0
        public StatePresenter(IGameStateUseCase gameStateUseCase, InputState inputState, JudgeState judgeState,
                              ClearState clearState)
        {
            _disposable  = new CompositeDisposable();
            _tokenSource = new CancellationTokenSource();
            _states      = new List <BaseState>
            {
                inputState,
                judgeState,
                clearState,
            };
            _gameStateUseCase = gameStateUseCase;

            Init();

            _gameStateUseCase.gameState
            .Where(x => x != GameState.None)
            .Subscribe(state =>
            {
                //
                TickAsync(state, _tokenSource.Token).Forget();
            })
            .AddTo(_disposable);
        }
Esempio n. 16
0
    public void InputKey(int laneNum, bool keyState)
    {
        if (activeNotes[laneNum] == null)
        {
            return;
        }

        NotesScript noteInfo = activeNotes[laneNum].GetComponent <NotesScript>();

        ScoreIndex type = noteInfo.type;

        if (keyState == false && type != ScoreIndex.LONG_END)
        {
            return;
        }

        float diff = noteInfo.notesTiming - move.time;

        float fixDiff = Mathf.Abs(diff);

        JudgeState state = JudgeState.none;

        //判定部分
        if (judgeWidth.JudgeTimings[judgeWidth.JudgeTimings.Length - 1] >= fixDiff)
        {
            for (int i = 0; i < judgeWidth.JudgeTimings.Length; i++)
            {
                if (judgeWidth.JudgeTimings[i] >= fixDiff)
                {
                    switch (i)
                    {
                    case 0:
                        state = JudgeState.Great;
                        break;

                    case 1:
                        state = JudgeState.Good;
                        break;

                    case 2:
                        state = JudgeState.Bad;
                        break;
                    }
                    break;
                }
            }
        }

        switch (type)
        {
        case ScoreIndex.SIMPLE:
            if (state == JudgeState.none)
            {
                break;
            }
            ScoreManager.instance.AddJudge(state, noteInfo, diff);
            SetActiveNotes(laneNum, state);
            break;

        case ScoreIndex.LONG:
            if (state == JudgeState.none)
            {
                break;
            }
            ScoreManager.instance.AddJudge(state, noteInfo, diff);
            SetActiveNotes(laneNum, state);
            break;

        case ScoreIndex.LONG_END:
            if (state == JudgeState.none)
            {
                state = JudgeState.Bad;
            }
            ScoreManager.instance.AddJudge(state, noteInfo, diff);
            SetActiveNotes(laneNum, state);
            break;
        }
    }