예제 #1
0
        private void Ring(Alarm alarm, int currentMinute)
        {
            if (alarm.SoundId > Sounds.Unknown)
            {
                _sounds.Invoke(alarm.SoundId);
            }

            if (alarm.PrintMessage)
            {
                var tmp = "is currently up";
                if (alarm.MinuteOffset > 0)
                {
                    var offTime = (currentMinute / 60 + alarm.Node !.Times !.NextUptime(currentMinute / 60 % 24)) * 60 - currentMinute;
                    var(m, s) = EorzeaTime.MinutesToReal(offTime);
                    if (offTime > 0)
                    {
                        tmp = $"will be up in {m}:{s:D2} minutes (real-time)";
                    }
                }

                var items = alarm.Node !.Items !.PrintItems(", ", _pi.ClientState.ClientLanguage);
                _pi.Framework.Gui.Chat.PrintError($"[GatherBuddy][Alarm {alarm.Name}]: The gathering node for {items} {tmp}.");
            }

            LastAlarm = alarm;
        }
예제 #2
0
        private async Task RunAsync()
        {
            await foreach (var item in _channel.Reader.ReadAllAsync())
            {
                switch (item)
                {
                case ToggleImage image:
                    if (ToggleImage is not null)
                    {
                        await ToggleImage.Invoke(image);
                    }
                    break;

                case PlaySound sound:
                    if (PlaySound is not null)
                    {
                        await PlaySound.Invoke(sound);
                    }
                    break;

                case Services.ClearAll:
                    if (ClearAll is not null)
                    {
                        await ClearAll.Invoke();
                    }
                    break;
                }
            }
        }
예제 #3
0
        public void Run()
        {
            ProcessorCycle.Cycle(500, () =>
            {
                //Benchmark.Log(() =>
                //{
                ProcessorStep();
                //});

                if (Timer_Delay > 0)
                {
                    --Timer_Delay;
                }

                if (Timer_Sound > 0)
                {
                    if (Timer_Sound == 1)
                    {
                        PlaySound?.Invoke(this);
                    }

                    --Timer_Sound;
                }

                if (DrawFlag)
                {
                    Draw?.Invoke(this, GFX, Resolution);
                    DrawFlag = false;
                }
            });
        }
        public static void OnPlaySound(AudioSourceMgr mgr)
        {
            var args = new SoundEventArgs {
                AudioSourceMgr = mgr
            };

            PlaySound?.Invoke(null, args);
        }
예제 #5
0
        public override void DrawMeWithLines(int lineThicknes, Color lineColor)
        {
            base.DrawMeWithLines(lineThicknes, lineColor);

            if (!soundPlayed)
            {
                sound.Invoke();
                soundPlayed = true;
            }

            gameWonButton.DrawMeWithLines(3, Color.BLACK);
            text.DrawMe();
        }
예제 #6
0
        public void ExecuteAttack()
        {
            string x = attackType ? "Attack" : "Skill";

            Console.WriteLine($"Pawn at {movedPawn} with bonus {attackBonus}. {x} on pawn at {attackPlace}");


            if (attackType)
            {
                PAt(movedPawn).NormalAttack(this, attackPlace, attackBonus);
                PlaySound?.Invoke(PAt(movedPawn).AttackSound);
            }
            else
            {
                PAt(movedPawn).SkillAttack(this, attackPlace, attackBonus);
                PlaySound?.Invoke(PAt(movedPawn).AttackSound);
            }
            A[attackPlace].FloorStatus = FloorStatus.Normal;
            move = 5;
            OnlyCanEnd?.Invoke(true);
        }
예제 #7
0
    private void Draw()
    {
        Ray  r   = cam.ScreenPointToRay(Input.mousePosition);
        bool hit = Physics2D.Raycast(r.origin, r.direction, Mathf.Infinity, targetLayer);

        if (hit)
        {
            if (Input.GetMouseButtonDown(0))
            {
                CreateBrush();
                PlaySound?.Invoke("TattooGun");
            }
            if (Input.GetMouseButton(0))
            {
                if (curRenderer == null)
                {
                    CreateBrush();
                }
                Vector2 curPos = cam.ScreenToWorldPoint(Input.mousePosition);
                if (curPos != previousPos)
                {
                    AddPoint(curPos);
                    previousPos = curPos;
                }
            }
            else
            {
                curRenderer = null;
                StopSound?.Invoke("TattooGun");
            }
        }
        else
        {
            curRenderer = null;
            StopSound?.Invoke("TattooGun");
        }
    }
예제 #8
0
 private void OnPlaySound(string sound)
 {
     PlaySound?.Invoke(sound);
 }
예제 #9
0
 public void Play(UnmanagedMemoryStream sound)
 {
     PlaySound?.Invoke(sound);
 }
예제 #10
0
        public void Update(float time, bool[] b, bool[] released)
        {
            if (!initialized)
            {
                return;
            }
            ReadPpdData(time, SpeedScale * EventManager.BPM);
            ReadExternalPpdData(time);
            Logger.Instance.AddLog("Time:{0}, pressed:{1}, released:{2}", time, String.Join(",", b.Select(v => v ? "1" : "0").ToArray()),
                                   String.Join(",", released.Select(v => v ? "1" : "0").ToArray()));
            foreach (Mark mk in MarkLayer.Children.Reverse())
            {
                if (removeMarks.Contains(mk))
                {
                    continue;
                }
                var  exmk      = mk as ExMarkBase;
                var  results   = new MarkResults();
                int  soundType = -1;
                bool remove    = false;
                var  isAuto    = false;
                switch (AutoMode)
                {
                case AutoMode.All:
                    isAuto = true;
                    break;

                case AutoMode.ExceptSlide:
                    isAuto = !mk.IsScratch;
                    break;
                }
                if (exmk != null)
                {
                    remove = exmk.ExUpdate(EventManager.GetCorrectTime(time, mk.Time),
                                           SpeedScale * EventManager.BPM,
                                           ref b, ref released, results,
                                           isAuto, ref soundType,
                                           CreateEffect
                                           );
                    if (isAuto)
                    {
                        if (soundType >= 0 && soundType < 10)
                        {
                            var index = randomChangeManager.Invert(soundType);
                            if (PlaySound != null)
                            {
                                PlaySound.Invoke(index, true);
                            }
                        }
                        else if (soundType >= 10)
                        {
                            var index = randomChangeManager.Invert(soundType - 10);
                            if (StopSound != null)
                            {
                                StopSound.Invoke(index, false);
                            }
                            if (EventManager.GetReleaseSound(index) && PlaySound != null)
                            {
                                PlaySound.Invoke(index, false);
                            }
                        }
                    }
                    else
                    {
                        //manual
                        if (exmk.IsScratch && exmk.IsLong && soundType >= 0 && soundType < 10)
                        {
                            var index = randomChangeManager.Invert(soundType);
                            if (PlaySound != null)
                            {
                                PlaySound.Invoke(index, false);
                            }
                        }
                        else
                        {
                            var index = randomChangeManager.Invert(soundType);
                            if (EventManager.GetReleaseSound(index) && PlaySound != null)
                            {
                                PlaySound.Invoke(index, false);
                            }
                        }
                    }
                }
                else
                {
                    remove = mk.Update(EventManager.GetCorrectTime(time, mk.Time),
                                       SpeedScale * EventManager.BPM,
                                       ref b, results, isAuto,
                                       ref soundType,
                                       CreateEffect
                                       );
                    if (isAuto)
                    {
                        if (soundType != -1)
                        {
                            var index = randomChangeManager.Invert(soundType);
                            if (PlaySound != null)
                            {
                                PlaySound.Invoke(index, false);
                            }
                        }
                    }
                }
                if (results[EffectType.Cool] || results[EffectType.Fine])
                {
                    if (ACPressing[(int)mk.ButtonType] != null)
                    {
                        OnPressingButton(mk.ButtonType, false);
                        for (int i = 0; i < ACPressing.Length; i++)
                        {
                            if (ACPressing[i] != null)
                            {
                                AddToRemove(ACPressing[i]);
                            }
                        }
                        Array.Clear(ACPressing, 0, ACPressing.Length);
                    }
                    if (ChangeCombo != null)
                    {
                        ChangeCombo.Invoke(true, mk.Position);
                    }
                }
                if (results[EffectType.Pressing])
                {
                    // 同時にHoldが始まったときに2個目ので1個目のを消す
                    if (ACPressing[(int)mk.ButtonType] != null && ACPressing[(int)mk.ButtonType] != mk)
                    {
                        OnPressingButton(mk.ButtonType, false);
                        for (int i = 0; i < ACPressing.Length; i++)
                        {
                            if (ACPressing[i] != null)
                            {
                                AddToRemove(ACPressing[i]);
                            }
                        }
                        Array.Clear(ACPressing, 0, ACPressing.Length);
                    }
                    if (OnPressingButton(mk.ButtonType, true))
                    {
                        for (int i = 0; i < ACPressing.Length; i++)
                        {
                            if (ACPressing[i] != null)
                            {
                                AddToRemove(ACPressing[i]);
                            }
                        }
                        Array.Clear(ACPressing, 0, ACPressing.Length);
                    }
                    ACPressing[(int)mk.ButtonType] = exmk;
                    RemoveFromConnection(exmk);
                }
                if (results[EffectType.PressReleased])
                {
                    OnPressingButton(mk.ButtonType, false);
                    for (int i = 0; i < ACPressing.Length; i++)
                    {
                        if (ACPressing[i] != null)
                        {
                            AddToRemove(ACPressing[i]);
                        }
                    }
                    Array.Clear(ACPressing, 0, ACPressing.Length);
                }
                if (results[EffectType.Slide])
                {
                    var slideExMark = exmk as SlideExMark;
                    for (var i = slideExMark.ProcessedPressingFrames; i < slideExMark.PressingFrames; i++)
                    {
                        var position = slideExMark.GetPressedSlidePosition(i + 1);
                        if (slideExMark.IsMaxSlide && (i + 1) == slideExMark.ExCount)
                        {
                            // do nothing for max slide
                        }
                        else
                        {
                            var score = 10 * (i + 1);
                            Slide?.Invoke(slideExMark, position, score, exmk.IsRight);
                        }
                    }
                    slideExMark.ProcessedPressingFrames = slideExMark.PressingFrames;
                }
                if (results[EffectType.Safe] || results[EffectType.Sad] || results[EffectType.Worst])
                {
                    if (ChangeCombo != null)
                    {
                        ChangeCombo.Invoke(false, mk.Position);
                    }
                }
                if (results[EffectType.Cool] || results[EffectType.Fine] || results[EffectType.Safe] || results[EffectType.Sad] ||
                    results[EffectType.Worst])
                {
                    if (EvaluateCount != null)
                    {
                        EvaluateCount.Invoke(results.First, false);
                    }
                }
                if (remove)
                {
                    if (exmk is SlideExMark && ((SlideExMark)exmk).IsMaxSlide)
                    {
                        var slideExMark = ((SlideExMark)exmk);
                        var score       = 1000 + 10 * slideExMark.ExCount;
                        var position    = slideExMark.GetPressedSlidePosition(slideExMark.ExCount);
                        MaxSlide?.Invoke(slideExMark, position, score, exmk.IsRight);
                    }
                    AddToRemove(mk);
                }
            }
            foreach (Mark mk in removeMarks)
            {
                MarkLayer.RemoveChild(mk);
                mk.Dispose();
            }
            if (MarkLayer.ChildrenCount > 0 && AutoMode == AutoMode.None)
            {
                for (int i = 0; i < 10; i++)
                {
                    int iter = MarkLayer.ChildrenCount - 1;
                    while (b[i] && iter >= 0)
                    {
                        var mk = MarkLayer[iter] as Mark;
                        if (mk is ExMarkBase exmk && exmk.ExMarkState != ExMarkBase.ExState.Waiting)
                        {
                            iter--;
                            continue;
                        }
                        var eval = mk.Evaluate(time);
                        if (eval == EffectType.None)
                        {
                            iter--;
                            continue;
                        }
                        Action proc = () =>
                        {
                            b[i] = false;
                            ChangeCombo?.Invoke(false, mk.Position);
                            EvaluateCount.Invoke(eval, true);
                            mk_ChangeMarkEvaluate(mk, eval, true, false, mk.Position);
                            MarkLayer.RemoveChild(mk);
                            RemoveFromConnection(mk);
                            mk.Dispose();
                        };
                        if (scriptManager.ProcessMissPressManager.Process(mk, (MarkType)i, out bool isMissPress))
                        {
                            if (isMissPress)
                            {
                                proc();
                                break;
                            }
                        }
                        else if (mk.NoteType == NoteType.AC || (mk.NoteType == NoteType.ACFT && !mk.IsScratch))
                        {
                            proc();
                            break;
                        }
                        iter--;
                    }
                }
            }
            removeMarks.Clear();
            Update();
        }
예제 #11
0
 internal void OnSound(DbAnimationEventArgs e)
 {
     PlaySound?.Invoke(this, e);
 }
예제 #12
0
        internal void Tick(int frame)
        {
            for (int i = 0; i < frame; i++)
            {
                Ship.SpeedX = 0;
                Ship.SpeedY = 0;
                if (IsKeyDown(VirtualKey.Left))
                {
                    Ship.SpeedX = -Ship.Speed;
                }
                if (IsKeyDown(VirtualKey.Right))
                {
                    Ship.SpeedX = Ship.Speed;
                }
                if (IsKeyDown(VirtualKey.Up))
                {
                    Ship.SpeedY = -Ship.Speed;
                }
                if (IsKeyDown(VirtualKey.Down))
                {
                    Ship.SpeedY = Ship.Speed;
                }
                if (IsKeyDown(VirtualKey.Space))
                {
                    Bullet b = new Bullet(Ship.X + Ship.Width / 2,
                                          Ship.Y + Ship.Height / 2);
                    AddBullet(b);
                    keyMap[VirtualKey.Space] = false;
                    PlaySound?.Invoke(SoundEffect.Shoot);
                }

                Message.Tick();
                foreach (Drawable e in Drawables.ToArray())
                {
                    e.Tick();
                    Rect r = e.Rect;
                    r.Intersect(Field);
                    if (!e.IsValid || r.IsEmpty)
                    {
                        Drawables.Remove(e);
                    }
                    if (e is AbstractEnemy)
                    {
                        AbstractEnemy enemy = (AbstractEnemy)e;
                        if (enemy.IsFire)
                        {
                            CreateEnemyBullet(enemy);
                        }
                        if (Crash(e, Ship))
                        {
                            Ship.IsValid = false;
                            Message.Text = "GAME OVER";
                            PlaySound?.Invoke(SoundEffect.Blast);
                        }
                    }
                }

                foreach (Bullet b in Bullets)
                {
                    if (b.IsEnemy)
                    {
                        if (Crash(b, Ship))
                        {
                            Ship.IsValid = false;
                            Message.Text = "GAME OVER";
                            PlaySound?.Invoke(SoundEffect.Blast);
                        }
                        continue;
                    }

                    foreach (AbstractEnemy e in Enemies)
                    {
                        if (Crash(b, e) && b.IsValid && e.IsValid)
                        {
                            e.IsValid = false;
                            b.IsValid = false;
                            Blast blast = new Blast(b.X + b.Width / 2, b.Y + b.Height / 2);
                            Drawables.Add(blast);
                            PlaySound?.Invoke(SoundEffect.Blast);
                        }
                    }
                }
            }
            Ship.Y = Math.Max(0, Math.Min(Field.Height - Ship.Height, Ship.Y));
            Ship.X = Math.Max(0, Math.Min(Field.Width - Ship.Width, Ship.X));
        }
예제 #13
0
 public void Update(float time, bool[] b, bool[] released, bool fadeout)
 {
     if (!initialized)
     {
         return;
     }
     cd.Update();
     readppddata(time);
     foreach (Mark mk in marks)
     {
         if (removemarks.Contains(mk))
         {
             continue;
         }
         ExMark     exmk      = mk as ExMark;
         EffectType result    = 0;
         int        soundtype = -1;
         bool       remove    = false;
         if (exmk != null)
         {
             remove = exmk.ExUpdate(em.GetCorrectTime(time, mk.Time),
                                    gameutility.SpeedScale * em.BPM,
                                    ref b, ref released, ref result,
                                    gameutility.Auto, ref soundtype,
                                    CreateEffect
                                    );
             if (gameutility.Auto)
             {
                 if (soundtype >= 0 && soundtype < 10)
                 {
                     int index = Array.IndexOf(keychange, soundtype);
                     if (PlaySound != null)
                     {
                         PlaySound.Invoke(index, true);
                     }
                 }
                 else if (soundtype >= 10)
                 {
                     int index = Array.IndexOf(keychange, soundtype - 10);
                     if (StopSound != null)
                     {
                         StopSound.Invoke(index, false);
                     }
                     if (em.GetReleaseSound(index) && PlaySound != null)
                     {
                         PlaySound.Invoke(index, false);
                     }
                 }
             }
             else
             {
                 //manual
                 int index = Array.IndexOf(keychange, soundtype);
                 if (em.GetReleaseSound(index) && PlaySound != null)
                 {
                     PlaySound.Invoke(index, false);
                 }
             }
         }
         else
         {
             remove = mk.Update(em.GetCorrectTime(time, mk.Time),
                                gameutility.SpeedScale * em.BPM,
                                ref b, ref result, gameutility.Auto,
                                ref soundtype,
                                CreateEffect
                                );
             if (gameutility.Auto)
             {
                 if (soundtype != -1)
                 {
                     int index = Array.IndexOf(keychange, soundtype);
                     if (PlaySound != null)
                     {
                         PlaySound.Invoke(index, false);
                     }
                 }
             }
         }
         if (result != EffectType.None)
         {
             if (result == EffectType.Cool || result == EffectType.Fine)
             {
                 if (gameutility.Auto && ACPressing[(int)mk.ButtonType] != null)
                 {
                     if (PressingButton != null)
                     {
                         PressingButton.Invoke(mk.ButtonType, false);
                     }
                     for (int i = 0; i < ACPressing.Length; i++)
                     {
                         if (ACPressing[i] != null)
                         {
                             AddRemove(ACPressing[i]);
                         }
                     }
                     Array.Clear(ACPressing, 0, ACPressing.Length);
                 }
                 if (ChangeCombo != null)
                 {
                     ChangeCombo.Invoke(true, new Vector2(mk.Position.X + 10, mk.Position.Y - 60));
                 }
             }
             else if (result == EffectType.Pressing)
             {
                 if (PressingButton != null)
                 {
                     if (PressingButton.Invoke(mk.ButtonType, true))
                     {
                         for (int i = 0; i < ACPressing.Length; i++)
                         {
                             if (ACPressing[i] != null)
                             {
                                 AddRemove(ACPressing[i]);
                             }
                         }
                         Array.Clear(ACPressing, 0, ACPressing.Length);
                     }
                 }
                 ACPressing[(int)mk.ButtonType] = exmk;
                 CheckConnection(exmk);
             }
             else if (result == EffectType.PressReleased)
             {
                 PressingButton.Invoke(mk.ButtonType, false);
                 for (int i = 0; i < ACPressing.Length; i++)
                 {
                     if (ACPressing[i] != null)
                     {
                         AddRemove(ACPressing[i]);
                     }
                 }
                 Array.Clear(ACPressing, 0, ACPressing.Length);
             }
             else
             {
                 if (ChangeCombo != null)
                 {
                     ChangeCombo.Invoke(false, new Vector2(mk.Position.X + 10, mk.Position.Y - 60));
                 }
             }
             if (!fadeout && result != EffectType.Pressing && result != EffectType.PressReleased)
             {
                 if (EvaluateCount != null)
                 {
                     EvaluateCount.Invoke((int)result - 1, false);
                 }
             }
         }
         if (remove)
         {
             AddRemove(mk);
         }
     }
     foreach (Mark mk in removemarks)
     {
         marks.Remove(mk);
     }
     if (marks.Count > 0 && !gameutility.Auto)
     {
         int iter = 0;
         for (int i = 0; i < 10; i++)
         {
             if (b[i])
             {
                 Mark mk = null;
                 while (iter < marks.Count)
                 {
                     mk = marks[iter] as Mark;
                     ExMark exmk = mk as ExMark;
                     if (exmk != null && exmk.ExMarkState != ExMark.ExState.waitingpress)
                     {
                         iter++;
                     }
                     else
                     {
                         break;
                     }
                 }
                 if (iter >= marks.Count || mk == null)
                 {
                     break;
                 }
                 if (mk.AC)
                 {
                     int eval = mk.Evaluate(time);
                     if (eval > 0)
                     {
                         if (ChangeCombo != null)
                         {
                             ChangeCombo(false, new Vector2(mk.Position.X + 10, mk.Position.Y - 60));
                         }
                         EvaluateCount.Invoke(eval - 1, true);
                         marks.Remove(mk);
                         CheckConnection(mk);
                     }
                 }
             }
         }
     }
     removemarks.Clear();
 }
예제 #14
0
 public static void AudioSourceMgr_Play(AudioSourceMgr manager)
 {
     PlaySound?.Invoke(manager, null);
 }