Ejemplo n.º 1
0
        private async void DeckDeletingHandler(HordeDeckObject deck)
        {
            // HACK for offline mode in online mode, local data should only be saved after
            // backend operation has succeeded
            _dataManager.CachedDecksData.Decks.Remove(deck.SelfDeck);
            _dataManager.CachedUserLocalData.LastSelectedDeckId = -1;
            _dataManager.CachedDecksLastModificationTimestamp   = Utilites.GetCurrentUnixTimestampMillis();
            await _dataManager.SaveCache(Enumerators.CacheDataType.DECKS_DATA);

            await _dataManager.SaveCache(Enumerators.CacheDataType.USER_LOCAL_DATA);

            try
            {
                await _backendFacade.DeleteDeck(
                    _backendDataControlMediator.UserDataModel.UserId,
                    deck.SelfDeck.Id,
                    _dataManager.CachedDecksLastModificationTimestamp
                    );

                Debug.Log($" ====== Delete Deck {deck.SelfDeck.Id} Successfully ==== ");
            }
            catch (Exception e)
            {
                // HACK for offline mode
#pragma warning disable 162
                if (false)
                {
                    Debug.Log("Result === " + e);
                    OpenAlertDialog($"Not able to Delete Deck {deck.SelfDeck.Id}: " + e.Message);
                    return;
                }
#pragma warning restore 162
            }

            LoadDeckObjects();
        }
Ejemplo n.º 2
0
        public void PlayAttackVfx(Enumerators.CardType type, Vector3 target, int damage)
        {
            GameObject effect;
            GameObject vfxPrefab;

            target = Utilites.CastVfxPosition(target);
            Vector3 offset = Vector3.forward * 1;

            switch (type)
            {
            case Enumerators.CardType.FERAL:
            {
                vfxPrefab = _loadObjectsManager.GetObjectByPath <GameObject>("Prefabs/VFX/FeralAttackVFX");
                effect    = Object.Instantiate(vfxPrefab);
                effect.transform.position = target - offset;
                _soundManager.PlaySound(Enumerators.SoundType.FERAL_ATTACK, Constants.CreatureAttackSoundVolume,
                                        false, false, true);

                _particlesController.RegisterParticleSystem(effect, true, 5f);

                if (damage > 3 && damage < 7)
                {
                    _timerManager.AddTimer(
                        a =>
                        {
                            effect = Object.Instantiate(vfxPrefab);
                            effect.transform.position   = target - offset;
                            effect.transform.localScale = new Vector3(-1, 1, 1);
                            _particlesController.RegisterParticleSystem(effect, true, 5f);
                        },
                        null,
                        0.5f);
                }

                if (damage > 6)
                {
                    _timerManager.AddTimer(
                        a =>
                        {
                            effect = Object.Instantiate(vfxPrefab);
                            effect.transform.position    = target - Vector3.right - offset;
                            effect.transform.eulerAngles = Vector3.forward * 90;

                            _particlesController.RegisterParticleSystem(effect, true, 5f);
                        });
                }

                break;
            }

            case Enumerators.CardType.HEAVY:
            {
                Enumerators.SoundType soundType = Enumerators.SoundType.HEAVY_ATTACK_1;
                string prefabName = "Prefabs/VFX/HeavyAttackVFX";
                if (damage > 4)
                {
                    prefabName = "Prefabs/VFX/HeavyAttack2VFX";
                    soundType  = Enumerators.SoundType.HEAVY_ATTACK_2;
                }

                vfxPrefab = _loadObjectsManager.GetObjectByPath <GameObject>(prefabName);
                effect    = Object.Instantiate(vfxPrefab);
                effect.transform.position = target;

                _particlesController.RegisterParticleSystem(effect, true, 5f);

                _soundManager.PlaySound(soundType, Constants.CreatureAttackSoundVolume, false, false, true);
                break;
            }

            default:
            {
                vfxPrefab = _loadObjectsManager.GetObjectByPath <GameObject>("Prefabs/VFX/WalkerAttackVFX");
                effect    = Object.Instantiate(vfxPrefab);
                effect.transform.position = target - offset;

                _particlesController.RegisterParticleSystem(effect, true, 5f);

                if (damage > 4)
                {
                    _timerManager.AddTimer(
                        a =>
                        {
                            effect = Object.Instantiate(vfxPrefab);
                            effect.transform.position = target - offset;

                            effect.transform.localScale = new Vector3(-1, 1, 1);
                            _particlesController.RegisterParticleSystem(effect, true, 5f);
                        },
                        null,
                        0.5f);

                    _soundManager.PlaySound(Enumerators.SoundType.WALKER_ATTACK_2,
                                            Constants.CreatureAttackSoundVolume, false, false, true);
                }
                else
                {
                    _soundManager.PlaySound(Enumerators.SoundType.WALKER_ATTACK_1,
                                            Constants.CreatureAttackSoundVolume, false, false, true);
                }

                break;
            }
            }
        }