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

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

        VelocityY  = _jumpSpeed;
        VelocityX /= 4;

        SoundService.PlaySound(Sound.Jump);

        Shield();
    }
Esempio 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);
            }
        }
Esempio 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;
         }
     });
 }
Esempio 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;
        }
    }
Esempio 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);
        }
Esempio n. 7
0
 private void Block(Danger danger)
 {
     SoundService.PlaySound(Sound.Block);
 }
Esempio n. 8
0
 private void Danger(Danger danger)
 {
     SoundService.PlaySound(Sound.Hit);
     State = State.Dead;
     Invoke(nameof(ResetGame), 3f);
 }
Esempio n. 9
0
 private void OnLanding()
 {
     State = State.Walk;
     WalkSoundDisposable = SoundService.PlaySound(Sound.Walk, true);
     VelocityX           = _defaultSpeed;
 }
Esempio n. 10
0
 protected override void OnDanger()
 {
     SoundService.PlaySound(Sound.Kick);
     _rigidBody2D.velocity = new Vector2(0f, -_speed);
     Destroy(gameObject, 10f);
 }