예제 #1
0
    public static void FadeInBGM(string _title, bool _cross = true)
    {
        if (!Controller)
        {
            return;
        }

        if (CurrentTitle == _title)
        {
            return;
        }
        if (BGM.isPlaying && _cross)
        {
            CrossFadeBGM(_title);
            return;
        }
        CurrentTitle = _title;
        Fade         = FadeType.FADEIN;
        AudioClip c = (AudioClip)Resources.Load("BGM/" + _title);

        LoopStats       = Loops[_title];
        BGM.volume      = 0;
        BGM.clip        = c;
        BGM.timeSamples = 0;
        BGM.Play();
    }
예제 #2
0
        private static void MakeLoopEnd(TokenizerOutput program, TLine line, Stack <LoopData> loopStack)
        {
            if (loopStack.Count < 1)
            {
                throw new TokenizerException(line, "Misplaced NEXT");
            }

            LoopData data = loopStack.Pop();
            var      next = (KwNext)line.Statement;

            if (data.LoopVariable.Name != next.Variable.Name)
            {
                throw new TokenizerException(line, "NEXT Error : Unknown variable " + next.Variable.Name);
            }

            // step 1: change the variable
            var add    = new NumBinaryOperator(data.LoopVariable, data.StepVariable, "+");
            var assign = new NumBinaryOperator(data.LoopVariable, add, "=");

            program.Program.Add(line.Clone(assign));

            // step 2: goto to the begining
            var gt = new KwrGoto(data.StartLine, true);

            program.Program.Add(line.Clone(gt));

            // change the top jump condition
            ((KwrJumpIfTrue)program.Program[data.StartLine].Statement).JumpPos = program.Program.Count;
        }
예제 #3
0
        private void VisitLoopAfterRightBorderNodes(Compiler.Nodes.Loop loop)
        {
            LoopData loopData = _loopData[loop];

            _builder.EmitBranch(loopData.Start);
            _builder.SetLabel(loopData.End);
        }
예제 #4
0
 public void LoopDelegate(StateMachineClient smc, LoopData ld)
 {
     if (ld.mLifeTime > kMaxPlayTime)
     {
         Actor.AddExitReason(ExitReason.Finished);
     }
 }
예제 #5
0
        public bool VisitIterateTunnel(IterateTunnel iterateTunnel)
        {
            // TODO: this should eventually call a RangeIterator::next function
            LoopData loopData = _loopData[(Compiler.Nodes.Loop)iterateTunnel.ParentStructure];

            LoadLocalAllocationReference(loopData.LoopCondition); // &cond
            _builder.EmitDuplicate();                             // &cond, &cond
            _builder.EmitDerefInteger();                          // &cond, cond

            VariableReference rangeInput = iterateTunnel.InputTerminals.ElementAt(0).GetTrueVariable();
            VariableReference output     = iterateTunnel.OutputTerminals.ElementAt(0).GetTrueVariable();

            LoadValueAsReference(rangeInput); // &range
            LoadValueAsReference(rangeInput); // &range, &range
            _builder.EmitLoadIntegerImmediate(4);
            _builder.EmitAdd();               // &range, &range.max
            _builder.EmitDerefInteger();      // &range, range.max
            _builder.EmitSwap();              // range.max, &range
            _builder.EmitDuplicate();         // range.max, &range, &range
            _builder.EmitDuplicate();         // range.max, &range, &range, &range
            _builder.EmitDerefInteger();      // range.max, &range, &range, range.current
            _builder.EmitLoadIntegerImmediate(1);
            _builder.EmitAdd();               // range.max, &range, &range, range.current+1
            _builder.EmitDuplicate();
            LoadLocalAllocationReference(output);
            _builder.EmitSwap();         // range.max, &range, &range, range.current+1, &output, range.current+1
            _builder.EmitStoreInteger(); // range.max, &range, &range, range.current+1
            _builder.EmitStoreInteger(); // range.max, &range

            _builder.EmitDerefInteger(); // range.max, range.current
            _builder.EmitGreaterThan();  // &cond, cond, (range.max > range.current)
            _builder.EmitAnd();          // &cond, (cond && range.max > range.current)
            _builder.EmitStoreInteger();
            return(true);
        }
예제 #6
0
        private static LoopData MakeLoopBegin(TokenizerOutput program, TLine line)
        {
            var kwFor = (KwFor)line.Statement;
            var ret   = new LoopData {
                StartLine = (program.Program.Count + 2)
            };

            // step 1: var = initial
            NumVariable forVar = kwFor.Variable;

            program.Program.Add(line.Clone(new NumBinaryOperator(forVar, kwFor.Initial, "=")));
            ret.LoopVariable = forVar;

            // step 2: make step variable
            var          stepVar   = new NumVariable("$" + ret.StartLine + forVar.Name + "_StepVariable");
            NumStatement stepValue = kwFor.Step ?? new NumConstant("1");

            program.Program.Add(line.Clone(new NumBinaryOperator(stepVar, stepValue, "=")));
            ret.StepVariable = stepVar;

            // step 3: loop
            var condition = new NumBoolBinaryOperator(forVar, kwFor.End, ">");
            var jmp       = new KwrJumpIfTrue(condition, -1);

            program.Program.Add(line.Clone(jmp));

            return(ret);
        }
예제 #7
0
 public void __LoopDel(StateMachineClient smc, LoopData loopData)
 {
     if (Target.DeathReactionBroadcast == null)
     {
         Actor.AddExitReason(ExitReason.Finished);
     }
 }
예제 #8
0
        private void VisitLoopAfterRightBorderNodes(Compiler.Nodes.Loop loop)
        {
            LoopData loopData = _loopData[loop];

            _builder.CreateBr(loopData.StartBlock);
            _builder.PositionBuilderAtEnd(loopData.EndBlock);
        }
예제 #9
0
        private void VisitLoopBeforeLeftBorderNodes(Compiler.Nodes.Loop loop)
        {
            LLVMBasicBlockRef startBlock           = _topLevelFunction.AppendBasicBlock($"loop{loop.UniqueId}_start"),
                              interiorBlock        = _topLevelFunction.AppendBasicBlock($"loop{loop.UniqueId}_interior"),
                              endBlock             = _topLevelFunction.AppendBasicBlock($"loop{loop.UniqueId}_end");
            LoopConditionTunnel loopCondition      = loop.BorderNodes.OfType <LoopConditionTunnel>().First();
            Terminal            loopConditionInput = loopCondition.InputTerminals[0];
            var conditionAllocationSource          = (LocalAllocationValueSource)GetTerminalValueSource(loopConditionInput);

            _loopData[loop] = new LoopData(conditionAllocationSource, startBlock, interiorBlock, endBlock);

            if (!loopConditionInput.IsConnected)
            {
                // if loop condition was unwired, initialize it to true
                conditionAllocationSource.UpdateValue(_builder, true.AsLLVMValue());
            }

            // initialize all output tunnels with None values, in case the loop interior does not execute
            foreach (Tunnel outputTunnel in loop.BorderNodes.OfType <Tunnel>().Where(tunnel => tunnel.Direction == Direction.Output))
            {
                VariableReference tunnelOutputVariable = outputTunnel.OutputTerminals[0].GetTrueVariable();
                ValueSource       tunnelOutputSource   = _variableValues[tunnelOutputVariable];
                LLVMTypeRef       tunnelOutputType     = tunnelOutputVariable.Type.AsLLVMType();
                tunnelOutputSource.UpdateValue(_builder, LLVMSharp.LLVM.ConstNull(tunnelOutputType));
            }

            _builder.CreateBr(startBlock);
            _builder.PositionBuilderAtEnd(startBlock);
        }
예제 #10
0
    public static void CrossFadeBGM(string _title)
    {
        if (!Controller)
        {
            return;
        }
        if (CurrentTitle == _title)
        {
            return;
        }
        AudioClip c = (AudioClip)Resources.Load("BGM/" + _title);

        if (c != null)
        {
            CurrentTitle = _title;
            if (Loops.ContainsKey(_title))
            {
                LoopStats = Loops[_title];
            }
            Fade = FadeType.FADEINOUT;
            Crossfade.Stop();
            Crossfade.clip   = c;
            Crossfade.volume = 0;
            Crossfade.Play();
        }
    }
예제 #11
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="logger"></param>
        private ServerMainGameLoop(ILogger logger, LoopData loopData, ServerPlayingState.LogicInfo info)
        {
            this.logger = logger ?? throw new ArgumentNullException(nameof(logger));

            LooperId = Interlocked.Increment(ref gameLoopSeq);
            this.logger.LogInformation($"{nameof(ServerMainGameLoop)}[{LooperId}]: Register");

            // 固有のループ情報
            this.loopData = loopData;

            // Response用の変数を事前確保
            for (int i = 0; i < SharedConstant.BOARD_ARRAY_SIZE; ++i)
            {   // 予め足しとく
                enemyBoard.Add(0);
            }

            // プレイ中Stateはこちらでも把握したいので保持 / Startに渡しつつ、開始はStartStateから実行されるように
            PlayingState = new ServerPlayingState(info, loopData.HubImpl);
            ServerPlayStartState start = new ServerPlayStartState(PlayingState, loopData.HubImpl);

            stateCtrl.ReserveAddState(start);

            // みんなから参照できるように
            All.TryAdd(loopData.MineId, this);
        }
예제 #12
0
        /// <summary>
        /// Gets loop data fro CSV file
        /// </summary>
        /// <returns>returns List of LoopData objects read from CSV file</returns>
        private List <LoopData> getLoopData()
        {
            List <LoopData> loop = new List <LoopData>();

            using (StreamReader reader = new StreamReader(LoopPath))
            {
                string line = null;
                while ((line = reader.ReadLine()) != null)
                {
                    String[] thisRow = line.Split(',');
                    //If speed is not null and this isn't the column header row.
                    if (thisRow[3] != "speed" && thisRow[3] != "")
                    {
                        LoopData thisReading = new LoopData();
                        thisReading.DetectorID = int.Parse(thisRow[0]);
                        thisReading.Speed      = int.Parse(thisRow[3]);
                        thisReading.Volume     = int.Parse(thisRow[2]);

                        DateTime thisDate = DateTime.Parse(thisRow[1]);
                        thisReading.StartHour   = (byte)thisDate.Hour;
                        thisReading.StartTime   = thisDate.TimeOfDay.ToString();
                        thisReading.StartMinute = (byte)thisDate.Minute;
                        thisReading.StartSecond = (byte)thisDate.Second;
                        thisReading.StartDate   = thisDate.Year.ToString() + "-" + thisDate.Month.ToString() + "-" + thisDate.Day.ToString();
                        thisReading.DayOfWeek   = getDayAbbrev(thisDate.DayOfWeek);
                        loop.Add(thisReading);
                    }
                }
            }

            return(loop);
        }
예제 #13
0
 public void LoopDel(StateMachineClient smc, LoopData loopData)
 {
     if (base.Actor.HasTrait(TraitNames.AntiTV) && loopData.mLifeTime > Computer.kTechnophobeTraitMaximumChatTime)
     {
         base.Actor.ShowTNSIfSelectable(Localization.LocalizeString("Lyralei/Localized/BrowseWebForPatternsHateComputers:InteractionName", new object[0]), StyledNotification.NotificationStyle.kSimTalking);
         base.Actor.AddExitReason(ExitReason.Finished);
     }
 }
예제 #14
0
 public void OnReset(InputAction.CallbackContext context)
 {
     if (context.performed)
     {
         controller.AllNotesOff();
         LoopData.Init();
     }
 }
예제 #15
0
        private void VisitLoopAfterLeftBorderNodes(Compiler.Nodes.Loop loop)
        {
            LoopData     loopData  = _loopData[loop];
            LLVMValueRef condition = loopData.ConditionAllocationSource.GetValue(_builder);

            _builder.CreateCondBr(condition, loopData.InteriorBlock, loopData.EndBlock);
            _builder.PositionBuilderAtEnd(loopData.InteriorBlock);
        }
예제 #16
0
        private void VisitLoopAfterLeftBorderNodes(Compiler.Nodes.Loop loop)
        {
            LoopData loopData = _loopData[loop];

            LoadLocalAllocationReference(loopData.LoopCondition);
            _builder.EmitDerefInteger();
            _builder.EmitBranchIfFalse(loopData.End);
        }
예제 #17
0
        private static void TokenizeStatement(TokenizerOutput program, TLine line, Stack <LoopData> loopStack)
        {
            if (line.Statement is KwGoto)
            {
                program.Program.Add(line.Clone(new KwrGoto(((KwGoto)line.Statement).Value.Value, false)));
            }
            else if (line.Statement is KwGosub)
            {
                program.Program.Add(line.Clone(new KwrGosub(((KwGosub)line.Statement).Value.Value, false)));
            }
            else if (line.Statement is KwData)
            {
                KwData data = (KwData)line.Statement;

                if (program.Data == null)
                {
                    program.Data = new List <string>();
                }

                ((List <string>)program.Data).AddRange(data.Data);
                program.Program.Add(line.Clone(new KwRem(line.OriginalLine.OriginalLine)));
            }
            else if (line.Statement is KwIf)
            {
                MakeBranch(program, line, loopStack);
            }
            else if (line.Statement is KwFor)
            {
                LoopData d = MakeLoopBegin(program, line);
                loopStack.Push(d);
            }
            else if (line.Statement is KwNext)
            {
                MakeLoopEnd(program, line, loopStack);
            }
            else if (line.Statement is KwOn)
            {
                MakeOnStatement(program, line);
            }
            else if (line.Statement is KwPrint)
            {
                MakePrintStatement(program, line);
            }
            else if (line.Statement is KwDim)
            {
                KwDim dim = (KwDim)line.Statement;
                foreach (VariableArray arr in dim.ArrayList)
                {
                    program.Program.Add(line.Clone(new KwrDim(arr)));
                }
            }
            else
            {
                program.Program.Add(line);
            }
        }
예제 #18
0
        /// <summary>
        /// 新規ゲームを生成し、ゲームループをスレッドプールに登録
        /// </summary>
        /// <param name="looperPool"></param>
        /// <param name="logger"></param>
        public static void CreateNew(ILogicLooperPool looperPool, ILogger logger, LoopData loopData)
        {
            ServerPlayingState.LogicInfo info;
            info.input         = loopData.Input;
            info.threadLockObj = threadLockObj;

            // ゲームループを登録
            var gameLoop = new ServerMainGameLoop(logger, loopData, info);

            looperPool.RegisterActionAsync(gameLoop.UpdateFrame);
        }
예제 #19
0
        internal override void Compile(IBuildContext ctx, int expressionId)
        {
            var data = new LoopData(ctx.DefineLabel(), ctx.DefineLabel());

            ctx.SetLoopData(data);

            data.ContinueLabel.Mark();
            ctx.Compile(_loop);
            data.ContinueLabel.EmitGoto(OpCodes.Br);

            data.BreakLabel.Mark();
            ctx.ResetLoopData(data);
        }
예제 #20
0
 public static void ReplayBGM(SavedBGM s)
 {
     if (!Controller)
     {
         return;
     }
     BGM.Stop();
     BGM.clip        = s.clip;
     BGM.timeSamples = s.sample;
     BGM.volume      = s.volume;
     BGM.Play();
     CurrentTitle = s.title;
     LoopStats    = s.loop;
 }
    IEnumerator Start()
    {
        inst = this;

        var cursorOffset = new Vector2(MeshRef.inst.mouse.width / 2, MeshRef.inst.mouse.height / 2);

        Cursor.SetCursor(MeshRef.inst.mouse, cursorOffset, CursorMode.Auto);

        // Wait (cause raycasts wouldnt hit any collider)
        yield return(new WaitForFixedUpdate()); yield return(new WaitForEndOfFrame());

        // 1. Create all meshes
        MeshCreation.CreateAll();

        // 2. Fill fields with last content (chords & colors)
        LoopData.Init();
        #region hack: isNotSpawning = false
        for (int i = 0; i < TunnelData.fields.Length; i++)
        {
            Player.inst.curFieldSet[i].isNotSpawning = false;
        }
        #endregion

        // EVENTS
        MusicRef.inst.beatSequencer.beatEvent.AddListener(MusicManager.inst.OnBeat);
        MusicRef.inst.beatSequencer.beatEvent.AddListener(MusicManager.inst.OnVeryFirstBeats);
        GameEvents.inst.onVeryFirstBeat  += OnVeryFirstBeat;
        GameEvents.inst.onVerySecondBeat += OnVerySecondBeat;
        GameEvents.inst.onPlayPerformed  += VisualController.inst.OnPlayField_byInput;
        GameEvents.inst.onPlayCanceled   += VisualController.inst.OnStopfield_byInput;
        GameEvents.inst.onChangeField    += VisualController.inst.OnFieldChange;
        GameEvents.inst.onMouseInside    += VisualController.inst.OnMouseInside;
        GameEvents.inst.onMouseOutside   += VisualController.inst.OnMouseOutside;
        GameEvents.inst.onScreenResize   += CameraOps.PanCamera;

        // Music-related
        GameEvents.inst.onPlayPerformed += MusicManager.inst.OnFieldStart;
        GameEvents.inst.onChangeField   += MusicManager.inst.OnFieldChange;
        GameEvents.inst.onPlayCanceled  += MusicManager.inst.OnFieldLeave;

        GameEvents.inst.onScreenResize?.Invoke(); // Hack

        yield return(null);
    }
예제 #22
0
 public static void Play(string _title)
 {
     if (!Controller)
     {
         return;
     }
     if (CurrentTitle == _title)
     {
         return;
     }
     BGM.Stop();
     Fade            = FadeType.NONE;
     LoopStats       = Loops[_title];
     BGM.volume      = MaxBGMVolume;
     BGM.clip        = (AudioClip)Resources.Load("BGM/" + _title);
     BGM.timeSamples = 0;
     BGM.Play();
     CurrentTitle = _title;
 }
예제 #23
0
        public void LoopFunc(StateMachineClient smc, LoopData ld)
        {
            if (ld.mLifeTime > kWatchPlantMaxTime)
            {
                Actor.AddExitReason(ExitReason.Finished);
                return;
            }
            ThoughtBalloonManager.BalloonData balloonData = new ThoughtBalloonManager.BalloonData(Target.GetThumbnailKey());
            balloonData.BalloonType = ThoughtBalloonTypes.kThoughtBalloon;
            balloonData.mPriority   = ThoughtBalloonPriority.Low;
            balloonData.mFlags      = ThoughtBalloonFlags.ShowIfSleeping;
            Actor.ThoughtBalloonManager.ShowBalloon(balloonData);
            AcquireStateMachine("catdoginvestigate");
            EnterStateMachine("catdoginvestigate", "Enter", "x");
            AnimateSim("Investigate");
            AnimateSim("Exit");
            ReactionTypes reactionType = kReactionList[RandomUtil.GetInt(kReactionList.Length - 1)];

            Actor.PlayReaction(reactionType, ReactionSpeed.ImmediateWithoutOverlay);
        }
예제 #24
0
        private void VisitLoopBeforeLeftBorderNodes(Compiler.Nodes.Loop loop)
        {
            LabelBuilder start = _builder.CreateLabel(),
                         end   = _builder.CreateLabel();
            LoopConditionTunnel loopCondition         = loop.BorderNodes.OfType <LoopConditionTunnel>().First();
            Terminal            loopConditionInput    = loopCondition.InputTerminals.ElementAt(0);
            VariableReference   loopConditionVariable = loopConditionInput.GetTrueVariable();

            _loopData[loop] = new LoopData(start, end, loopConditionVariable);

            if (!loopConditionInput.IsConnected)
            {
                // if loop condition was unwired, initialize it to true
                LoadLocalAllocationReference(loopConditionVariable);
                _builder.EmitLoadIntegerImmediate(1);
                _builder.EmitStoreInteger();
            }

            _builder.SetLabel(start);
        }
예제 #25
0
파일: SoundSystem.cs 프로젝트: larnin/LD47
    public int PlayLoop(AudioClip clip, float volume = 0.5f, float fade = 0.5f)
    {
        if (clip == null)
        {
            return(-1);
        }

        if (fade < 0.001f)
        {
            fade = 0.001f;
        }

        for (int i = 0; i < m_sources.Length; i++)
        {
            var s = m_sources[i];
            if (!s.isPlaying)
            {
                s.clip   = clip;
                s.volume = 0;
                s.loop   = true;
                s.Play();

                var loop = new LoopData();
                loop.id       = m_nextLoopID++;
                loop.volume   = volume;
                loop.timer    = 0;
                loop.maxTimer = fade;
                if (m_nextLoopID >= int.MaxValue)
                {
                    m_nextLoopID = 0;
                }
                loop.sourceIndex = i;
                m_loops.Add(loop);

                return(loop.id);
            }
        }

        return(-1);
    }
예제 #26
0
		static void PrintLoopData (LoopData data)
		{
			Console.WriteLine ("Body {0}:{1}", data.Body.Start.Index, data.Body.End.Index);
		}
예제 #27
0
 /// <summary>
 /// 停止
 /// </summary>
 public void Stop()
 {
     this.audioSource.Stop();
     this.audioSource.clip = null;
     this.loopData         = null;
 }
예제 #28
0
 static void PrintLoopData(LoopData data)
 {
     Console.WriteLine("Body {0}:{1}", data.Body.Start.Index, data.Body.End.Index);
 }
예제 #29
0
 protected bool Equals(LoopData other)
 {
     return(ContinueLabel.Equals(other.ContinueLabel) && BreakLabel.Equals(other.BreakLabel));
 }