Exemple #1
0
        public IEnumerable <IChange> Handle(Level level, ICommand command)
        {
            if (command is HitCommand)
            {
                foreach (var entityInTargetPos in level.GetActiveEntitiesAt(_entity.Position))
                {
                    if (entityInTargetPos.ObjectType.ToString() == "Player")
                    {
                        _haloFx.Stop();
                        _revertCollectFx.Stop();
                        _collectFx.Trigger(transform);

                        _entity.Deactivate();

                        if (_disableRenderersWhenInactive != null)
                        {
                            foreach (var rnd in _disableRenderersWhenInactive)
                            {
                                rnd.enabled = false;
                            }
                        }

                        SoundManager.Instance.Play(PickupSound);
                        level.CollectStar();

                        yield return(new Collection(_entity.Id));
                    }
                }
            }
        }
Exemple #2
0
        public void Revert(Level level, IChange change)
        {
            if (change is DestroyedChange)
            {
                DestroyedFx?.Stop();
                RevertDestroyedFx?.Trigger(transform);
                if (Animator != null)
                {
                    Animator.SetBool(AnimDiedBool, false);
                }


                if (DisableAllRenderersWhenInactive)
                {
                    foreach (var rnd in gameObject.GetComponentsInChildren <Renderer>())
                    {
                        rnd.enabled = true;
                    }
                }

                if (DisableRenderersWhenInactive != null)
                {
                    foreach (var rnd in DisableRenderersWhenInactive)
                    {
                        rnd.enabled = true;
                    }
                }

                SoundManager.Instance.Play(RevertDestroySound);

                _entity.Activate();
            }
        }
Exemple #3
0
 private void UpdateSparksState()
 {
     if (_turnsUntilDetonate >= 0)
     {
         Sparks?.Trigger(transform);
     }
     else
     {
         Sparks?.Stop();
     }
 }
Exemple #4
0
        public IEnumerable <IChange> Handle(Level level, ICommand command)
        {
            if (_entity == null)
            {
                yield break;
            }

            if (command is DestroyCommand)
            {
                RevertDestroyedFx?.Stop();
                DestroyedFx?.Trigger(transform);
                _entity.Deactivate();

                //if(_uiTimerManager != null)
                //_uiTimerManager.DeleteTimer(gameObject);

                if (Animator != null)
                {
                    Animator.SetBool(AnimDiedBool, true);
                }

                if (DisableAllRenderersWhenInactive)
                {
                    foreach (var rnd in gameObject.GetComponentsInChildren <Renderer>())
                    {
                        rnd.enabled = false;
                    }
                }

                if (DisableRenderersWhenInactive != null)
                {
                    foreach (var rnd in DisableRenderersWhenInactive)
                    {
                        rnd.enabled = false;
                    }
                }

                SoundManager.Instance.Play(DestroySound);

                yield return(new DestroyedChange(_entity.Id));
            }
        }
Exemple #5
0
        public void Revert(Level level, IChange change)
        {
            if (change is Collection)
            {
                SoundManager.Instance.Play(RevertPickupSound);
                _collectFx.Stop();
                _revertCollectFx.Trigger(transform);
                _haloFx.Trigger(transform);
                if (_disableRenderersWhenInactive != null)
                {
                    foreach (var rnd in _disableRenderersWhenInactive)
                    {
                        rnd.enabled = true;
                    }
                }

                _entity.Activate();

                level.LoseStar();
            }
        }