Ejemplo n.º 1
0
        public void PlaySoundTest()
        {
            //Act
            _soundService.PlaySound();

            //Assert
            _soundWrapper.Verify(x => x.Play(It.IsAny <string>(), Guid.Empty), Times.Once);
        }
Ejemplo n.º 2
0
    private void Jump()
    {
        _isOnGround = false;

        VelocityY  = _jumpSpeed;
        VelocityX /= 4;

        SoundService.PlaySound(Sound.Jump);

        Shield();
    }
Ejemplo n.º 3
0
        public void GivenSoundServiceWithoutAudioSource_WhenPlaySound_ThenExceptionThrown()
        {
            try
            {
                // Given
                var soundService = new SoundService();

                // When
                soundService.PlaySound();
            }

            // Then
            catch (Exception e)
            {
                Assert.AreEqual("Audio source not set.", e.Message);
            }
        }
Ejemplo n.º 4
0
 public override void Setup()
 {
     button = GetComponentInChildren <Button>();
     button.onClick.RemoveAllListeners();
     button.onClick.AddListener(() => {
         try {
             LOG.Log($"[CLICK] - {this.GetType()}");
             switch (buttonSound)
             {
             case ButtonSound.Default:
                 SoundService.PlaySound(SfxId.BUTTON_CLICK_1);
                 break;
             }
             _ = OnClick();
         }
         catch (System.Exception e) {
             LOG.Log(e);
             throw;
         }
     });
 }
Ejemplo n.º 5
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        if (IsGliding)
        {
            OnLanding();
        }

        _isOnGround = !IsJumping;

        var danger = other.gameObject.GetComponent <Danger>();

        if (danger != null)
        {
            SoundService.PlaySound(Sound.Danger);

            switch (State)
            {
            case State.Shell:
                Block(danger);
                break;

            case State.Walk:
            case State.Glide:
                Danger(danger);
                break;

            case State.Jump:
                PerfectBlock(danger);
                break;
            }
        }
        else
        {
            _rigidBody.gravityScale = _defaultGravity;
        }
    }
Ejemplo n.º 6
0
        /// <summary>
        /// 开始分拣产品
        /// </summary>
        /// <param name="productCode"></param>
        private void SortProductBegin(string barCode)
        {
            //0.验证
            if (SlaveInfoService.SlaveInfo.LatticeStatus == LatticeStatus.PutError)
            {
                if (SlaveInfoService.LatticeInfoList.Exists(o => o.Status == LatticeStatus.WaitPut && o.Product.Exists(p => p.BarCode == barCode)))
                {
                    var latticePutError = SlaveInfoService.LatticeInfoList.Where(o => o.Status == LatticeStatus.PutError).ToList();
                    UpDownService.RemovePutError(new UpDownMessage()
                    {
                        LatticeByUpDown =
                            latticePutError.Select(l => new LatticeByUpDown {
                            LatticeNo = l.LatticeNo
                        }).ToList()
                    });

                    lblMsg.Text = string.Format(Resources.RemovePutError, barCode);
                }
                else
                {
                    lblMsg.Text = string.Format(Resources.PleaseSolvePutError, barCode);
                    SoundService.PlaySound(SoundType.PutError);
                }
                return;
            }
            if (SlaveInfoService.SlaveInfo.LatticeStatus == LatticeStatus.BlockError)
            {
                lblMsg.Text = string.Format(Resources.PleaseSolveBlockError, barCode);
                SoundService.PlaySound(SoundType.BlockError);
                return;
            }
            if (SlaveInfoService.SlaveInfo.LatticeStatus == LatticeStatus.WaitPut)
            {
                lblMsg.Text = string.Format(Resources.PleaseWait, barCode);
                UpDownService.SetText("存在待投递的产品!");
                SoundService.PlaySoundAsny(SoundType.WaitPut);
                return;
            }

            //1.装载格口
            var waveApiList = WaveApiService.GetOrderApiList(SlaveInfoService.SlaveInfo.WaveNo, barCode);

            if (waveApiList.Count == 0)
            {
                UpDownService.ProductNotFound();
                lblMsg.Text = string.Format(Resources.ProductError, SlaveInfoService.SlaveInfo.WaveNo, barCode);
                return;
            }
            waveApiList.ForEach(o =>
            {
                if (!SlaveInfoService.LatticeInfoList.Exists(s => s.OrderNo == o.OrderNo))
                {
                    SlaveInfoService.LoadLattice(o);
                }
            });
            if (!SlaveInfoService.SlaveInfo.LatticeInfo.SelectMany(o => o.Product).Where(o => o.BarCode == barCode).Any(o => !o.IsComplete))
            {
                lblMsg.Text = $"货物已配足:{barCode}";
                UpDownService.SetText($"货物已配足:{barCode}");
                SoundService.PlaySoundAsny(SoundType.ProductOver);
                return;
            }
            //2.更新格口为待投递
            string orderNo        = waveApiList.First().OrderNo;
            var    waitPutLattice = SlaveInfoService.LatticeInfoList.Where(o => !o.IsComplete && waveApiList.Select(s => s.OrderNo).Contains(o.OrderNo)).ToList();

            UpDownService.WaitPut(waitPutLattice, barCode);
        }
Ejemplo n.º 7
0
 private void Block(Danger danger)
 {
     SoundService.PlaySound(Sound.Block);
 }
Ejemplo n.º 8
0
 private void Danger(Danger danger)
 {
     SoundService.PlaySound(Sound.Hit);
     State = State.Dead;
     Invoke(nameof(ResetGame), 3f);
 }
Ejemplo n.º 9
0
 private void OnLanding()
 {
     State = State.Walk;
     WalkSoundDisposable = SoundService.PlaySound(Sound.Walk, true);
     VelocityX           = _defaultSpeed;
 }
Ejemplo n.º 10
0
 protected override void OnDanger()
 {
     SoundService.PlaySound(Sound.Kick);
     _rigidBody2D.velocity = new Vector2(0f, -_speed);
     Destroy(gameObject, 10f);
 }