コード例 #1
0
        protected override void ProcessEntity(Entity entity, float deltaTime)
        {
            var view = _viewMapper.get(entity);
            var shot = _shotMapper.get(entity);

            view.Elapsed += deltaTime;

            if (view.Elapsed >= view.LifeTime)
            {
                _signalBus.Fire(new SignalShotDestroy(view));
            }
            else
            {
                var velocity     = view.transform.forward * view.Speed * deltaTime;
                var nextPosition = view.transform.position + velocity;
                var distance     = Vector3.Distance(view.transform.position, nextPosition);

                if (Physics.Raycast(view.transform.position, view.transform.forward, out _hit, distance))
                {
                    _signalBus.Fire(new SignalShotFXSpawn(_hit.point, _hit.normal));
                    _signalBus.Fire(new SignalShotDestroy(view));
                }
                else
                {
                    view.transform.position = nextPosition;
                }
            }
        }
コード例 #2
0
        protected override void ProcessEntity(Entity entity, float deltaTime)
        {
            var view = _viewMapper.get(entity);
            var shot = _shotFXMapper.get(entity);

            view.Elapsed += deltaTime;

            if (view.Elapsed >= view.LifeTime)
            {
                _signalBus.Fire(new SignalShotFXDestroy(view));
            }
        }