private void StageSelect_Stage(AllInput input)
        {
            _SelectedActor = new int[] { -1, -1, -1 };
            bool isExit = false;

            while (_CurrentTime * 3 < _Replay.InputData.Length)
            {
                input.P1.Step(_Replay.InputData[_CurrentTime * 3]);
                input.P2.Step(_Replay.InputData[_CurrentTime * 3 + 1]);
                input.P3.Step(_Replay.InputData[_CurrentTime * 3 + 2]);

                if (isExit)
                {
                    if (input.Y < 0)
                    {
                        isExit = false;
                    }
                    else if (GetB0(_CurrentTime))
                    {
                        Skip(60);

                        Title();
                        return;
                    }
                }
                else
                {
                    if (input.Y > 0)
                    {
                        isExit = true;
                    }
                    else
                    {
                        if (GetInputData(_CurrentTime, 0, 0x10))
                        {
                            _SelectedActor[0] = _DefaultActor[0];
                            SwitchActorVisible(input);
                            StageSelect_Actor(input);
                            return;
                        }
                        if (GetInputData(_CurrentTime, 1, 0x10))
                        {
                            _SelectedActor[1] = _DefaultActor[1];
                            SwitchActorVisible(input);
                            StageSelect_Actor(input);
                            return;
                        }
                        if (GetInputData(_CurrentTime, 2, 0x10))
                        {
                            _SelectedActor[2] = _DefaultActor[2];
                            SwitchActorVisible(input);
                            StageSelect_Actor(input);
                            return;
                        }
                    }
                }
                _CurrentTime += 1;
            }
            throw new Exception();
        }
Esempio n. 2
0
    public void HandleInput(AllInput allInput)
    {
        var index = Random.Range(0, settings.ClickSoundEffects.Count);
        var fx    = settings.ClickSoundEffects[index];

        audio.PlayEffect(fx);
    }
    private void StartStory(AllInput e)
    {
        ChangeState(ApplicationState.Starting);

        Events.Instance.RemoveListener <AllInput>(StartStory);
        StopAllCoroutines();

        StartCoroutine(_playingLogic.InvokeFunctionsCoroutine(settings.OnStart, PlayRootNode, this));
    }
        private void SwitchActorVisible(AllInput input)
        {
            //skip current frame
            _CurrentTime += 1;

            int count = _ActorIsFirstSwitch ? 56 : 57;

            _ActorIsFirstSwitch = false;

            for (int i = 0; i < count; ++i)
            {
                input.P1.Step(_Replay.InputData[_CurrentTime * 3]);
                input.P2.Step(_Replay.InputData[_CurrentTime * 3 + 1]);
                input.P3.Step(_Replay.InputData[_CurrentTime * 3 + 2]);
                _CurrentTime += 1;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Start the Servitor, listening on its thread.
        /// </summary>
        public void Start()
        {
            TcpListener listener = new TcpListener(Address, Port);

            listener.Start();

            // Continuously accept clients
            for (; /*ever*/;)
            {
                TcpClient     client   = listener.AcceptTcpClient();
                NetworkStream nwStream = client.GetStream();

                var    buffer       = new byte[client.ReceiveBufferSize];
                int    bytesRead    = nwStream.Read(buffer, 0, client.ReceiveBufferSize);
                string dataReceived = Encoding.ASCII.GetString(buffer, 0, bytesRead);

                lock (AllInput)
                {
                    AllInput.Add(dataReceived);
                }

                Changed = true;
            }
        }
        private void StageSelect_Actor(AllInput input)
        {
            int[] status = new int[] { 0, 0, 0 };
            for (int i = 0; i < 3; ++i)
            {
                if (_SelectedActor[i] != -1)
                {
                    status[i] = 1; break;
                }
            }

            while (_CurrentTime * 3 < _Replay.InputData.Length)
            {
                input.P1.Step(_Replay.InputData[_CurrentTime * 3]);
                input.P2.Step(_Replay.InputData[_CurrentTime * 3 + 1]);
                input.P3.Step(_Replay.InputData[_CurrentTime * 3 + 2]);

                for (int i = 0; i < 3; ++i)
                {
                    if (status[i] == 0)
                    {
                        if (GetB0Pressed(_CurrentTime, i))
                        {
                            _SelectedActor[i] = _DefaultActor[i];

                            for (int j = 0; j < 3; ++j)
                            {
                                if (j != i && status[j] != 0 && _SelectedActor[j] == _SelectedActor[i])
                                {
                                    _SelectedActor[i] = (_SelectedActor[i] + 1) % 5;
                                    j = -1;
                                }
                            }

                            status[i] = 1;
                        }
                    }
                    else if (status[i] == 2)
                    {
                        if (GetB1Pressed(_CurrentTime, i))
                        {
                            status[i] = 1;
                        }
                    }
                    else
                    {
                        //TODO megane check

                        var dx  = input.Pn(i).X;
                        var dxa = Math.Abs(dx);
                        if (dxa != 1 && (dxa < 25 || dxa % 7 != 0))
                        {
                            dx = 0;
                        }
                        if (dx != 0)
                        {
                            var dxs = Math.Sign(dx);
                            var pos = _SelectedActor[i] + dxs;
                            while (true)
                            {
                                if (pos < 0 || pos >= 5)
                                {
                                    pos = _SelectedActor[i];
                                    break;
                                }
                                if (IsActorAvailable(status, i, pos))
                                {
                                    break;
                                }
                                pos += dxs;
                            }
                            _SelectedActor[i] = pos;
                        }

                        if (GetB0Pressed(_CurrentTime, i))
                        {
                            status[i] = 2;
                        }
                        else if (GetB1Pressed(_CurrentTime, i))
                        {
                            status[i] = 0;
                        }
                    }
                }

                if (status.Count(s => s == 1) == 0)
                {
                    if (status.Count(s => s == 2) == 0)
                    {
                        SwitchActorVisible(input);
                        StageSelect_Stage(input);
                        return;
                    }
                    else
                    {
                        //finally finished
                        return;
                    }
                }

                _CurrentTime += 1;
            }
            throw new Exception();
        }
        private void Title()
        {
            var index = Array.FindIndex(_Replay.InputData, x => (x & 0x02) != 0);

            Skip(1);

            int lap      = _SelectedLap;
            int selector = 0;
            int maxLap   = _Replay.BaseLap * _Replay.BaseLap + 1;

            AllInput input = new AllInput();

            while (_CurrentTime * 3 < _Replay.InputData.Length)
            {
                input.P1.Step(_Replay.InputData[_CurrentTime * 3]);
                input.P2.Step(_Replay.InputData[_CurrentTime * 3 + 1]);
                input.P3.Step(_Replay.InputData[_CurrentTime * 3 + 2]);
                var dy = input.Y;
                {
                    var dya = Math.Abs(dy);
                    if (dya != 1 && (dya < 25 || dya % 7 != 0))
                    {
                        dy = 0;
                    }
                }
                if (dy != 0)
                {
                    Log(dy);
                }
                selector += Math.Sign(dy);
                if (selector < 0)
                {
                    selector = 0;
                }
                if (selector > 2)
                {
                    selector = 2;
                }
                if (selector == 1)
                {
                    int x = input.X;
                    if (Math.Abs(x) == 1 || Math.Abs(x) > 13)
                    {
                        var sx   = Math.Sign(x);
                        var incr = sx;
                        if (GetB1(_CurrentTime))
                        {
                            incr += sx * 10;
                        }
                        if (GetB2(_CurrentTime))
                        {
                            incr += sx * 20;
                        }
                        lap += incr;
                        if (lap < 1)
                        {
                            lap = 1;
                        }
                        if (lap > maxLap)
                        {
                            lap = maxLap;
                        }
                    }
                }
                if (GetB0(_CurrentTime))
                {
                    if (selector == 2)
                    {
                        //not entering game
                        throw new Exception();
                    }
                    else if (selector == 0)
                    {
                        _SelectedLap = 1;

                        Skip(61);
                        //Skip(60);

                        _ActorIsFirstSwitch = true;
                        Skip(1);

                        //TODO it seems that enter StageSelect_Stage before 265 frame will not
                        //trigger further events
                        if (_CurrentTime < 265)
                        {
                            _CurrentTime = 265;
                        }

                        StageSelect_Stage(new AllInput());
                        return;
                    }
                    else if (selector == 1)
                    {
                        _SelectedLap = lap;

                        Skip(100);

                        _ActorIsFirstSwitch = true;
                        Skip(1);

                        StageSelect_Stage(new AllInput());
                        return;
                    }
                }
                _CurrentTime += 1;
            }
            throw new Exception();
        }
Esempio n. 8
0
 private void StopWaiting(AllInput e)
 {
     StopWaiting();
 }