示例#1
0
 private void Awake()
 {
     _isAIControlled = GetComponent <Movement>().IsAIControlled;
     _upgrades       = ProgressionSystem.Instance;
     MaxHealth       = _isAIControlled ? _upgrades.GetEnemySettings().Health : _upgrades.MaxHealth;
     CurrentHealth   = MaxHealth;
 }
示例#2
0
 private void Awake()
 {
     _movement       = GetComponent <Movement>();
     _weapon         = GetComponent <Weapon>();
     _player         = GameObject.FindWithTag("Player");
     _playerMovement = _player.GetComponent <Movement>();
     _upgrades       = ProgressionSystem.Instance;
     _timeSinceFired = 0f;
 }
示例#3
0
        // Cleanup from previous tests (needed because persistance to disc is used):
        private static async Task CleanupFilesFromTest(LocalAnalytics analytics, ProgressionSystem <FeatureFlag> xpSystem)
        {
            // First trigger 1 event for each relevant catory to load the category stores:
            foreach (var category in xpSystem.xpFactors.Keys)
            {
                AppFlow.TrackEvent(category, "Dummy Event");
            }
            await analytics.RemoveAll();                // Then clear all stores

            Assert.Empty(await analytics.GetAllKeys()); // Now the main store should be emtpy
        }
示例#4
0
 private void Awake()
 {
     #region Singleton
     if (Instance == null)
     {
         Instance = this;
     }
     if (Instance != this)
     {
         Destroy(gameObject);
         return;
     }
     #endregion
 }
示例#5
0
        private void Awake()
        {
            _upgrades = ProgressionSystem.Instance;

            _sprite   = GetComponent <SpriteRenderer>();
            _rb       = GetComponent <Rigidbody2D>();
            _weapon   = GetComponent <Weapon>();
            _animator = GetComponent <Animator>();

            if (!IsAIControlled)
            {
                PlayerInput = new DefaultInput();
                PlayerInput.Enable();
                PlayerInput.Player.Movement.performed += MovementPerformed;
                PlayerInput.Player.Movement.cancelled += MovementPerformed;
                PlayerInput.Player.Shoot.performed    += ShootPerformed;
            }
        }
示例#6
0
        public async Task TestDefaultProgressionSystem()
        {
            // Get your key from https://console.developers.google.com/apis/credentials
            var apiKey = "AIzaSyCtcFQMgRIUHhSuXggm4BtXT4eZvUrBWN0";
            // https://docs.google.com/spreadsheets/d/1KBamVmgEUX-fyogMJ48TT6h2kAMKyWU1uBL5skCGRBM contains the sheetId:
            var sheetId           = "1KBamVmgEUX-fyogMJ48TT6h2kAMKyWU1uBL5skCGRBM";
            var sheetName         = "MySheet1"; // Has to match the sheet name
            var googleSheetsStore = new GoogleSheetsKeyValueStore(new InMemoryKeyValueStore(), apiKey, sheetId, sheetName);
            var ffm = new FeatureFlagManager <FeatureFlag>(new FeatureFlagStore(new InMemoryKeyValueStore(), googleSheetsStore));

            IoC.inject.SetSingleton <FeatureFlagManager <FeatureFlag> >(ffm);

            LocalAnalytics analytics = new LocalAnalytics();

            AppFlow.AddAppFlowTracker(new AppFlowToStore(analytics));
            var xpSystem = new ProgressionSystem <FeatureFlag>(analytics, ffm);

            IoC.inject.SetSingleton <IProgressionSystem <FeatureFlag> >(xpSystem);

            await CleanupFilesFromTest(analytics, xpSystem);

            // Simulate User progression by causing analytics events:
            var eventCount = 1000;

            for (int i = 0; i < eventCount; i++)
            {
                AppFlow.TrackEvent(EventConsts.catMutation, "User did mutation nr " + i);
            }

            var flagId4 = "MyFlag4";
            var flag4   = await FeatureFlagManager <FeatureFlag> .instance.GetFeatureFlag(flagId4);

            Assert.Equal(1000, flag4.requiredXp); // The user needs >= 1000 XP for the feature

            // Now that the user has 1000 XP the condition of the TestXpSystem is met:
            Assert.True(await FeatureFlag.IsEnabled(flagId4));

            // The number of mutation events:
            Assert.Equal(eventCount, xpSystem.cachedCategoryCounts[EventConsts.catMutation]);
            // Since there are only mutation events the XP is equal to the factor*event count:
            Assert.Equal(await xpSystem.GetLatestXp(), eventCount * xpSystem.xpFactors[EventConsts.catMutation]);

            await CleanupFilesFromTest(analytics, xpSystem);
        }
示例#7
0
        private void Awake()
        {
            _rb       = GetComponent <Rigidbody2D>();
            _movement = GetComponent <Movement>();
            _upgrades = ProgressionSystem.Instance;
            if (FirePoint == null)
            {
                FirePoint = transform;
                Debug.LogWarning("Fire Point is unset, is this intended?");
            }

            Cooldown = _movement.IsAIControlled
                ? _upgrades.GetEnemySettings().WeaponCooldown
                : _upgrades.WeaponCooldown;
            _timeSinceFired = Cooldown;

            if (WeaponAnimator != null && WeaponAnimator.HasParamter("CanFire"))
            {
                WeaponAnimator.SetBool("CanFire", true);
            }
        }
示例#8
0
        public async Task ExtensiveDefaultProgressionSystemTests()
        {
            // Get your key from https://console.developers.google.com/apis/credentials
            var apiKey = "AIzaSyCtcFQMgRIUHhSuXggm4BtXT4eZvUrBWN0";
            // https://docs.google.com/spreadsheets/d/1KBamVmgEUX-fyogMJ48TT6h2kAMKyWU1uBL5skCGRBM contains the sheetId:
            var sheetId   = "1KBamVmgEUX-fyogMJ48TT6h2kAMKyWU1uBL5skCGRBM";
            var sheetName = "MySheet1"; // Has to match the sheet name
            ProgressionSystem <FeatureFlag> xpSys = await NewInMemoryTestXpSystem(apiKey, sheetId, sheetName);

            Assert.Empty(await xpSys.analytics.GetStoreForCategory(EventConsts.catMutation).GetAllKeys());
            Assert.Equal(0, await xpSys.GetLatestXp());

            Assert.False(await FeatureFlag.IsEnabled("MyFlag5")); // Needs 1 xp

            // The DefaultProgressionSystem will give 1 xp for each mutation:
            AppFlow.TrackEvent(EventConsts.catMutation, "Some mutation"); // Would also be triggered by DataStore
            Assert.Single(await xpSys.analytics.GetStoreForCategory(EventConsts.catMutation).GetAllKeys());
            Assert.NotEqual(0, await xpSys.GetLatestXp());

            Assert.False(await FeatureFlag.IsEnabled("MyFlag4")); // Needs 1000 xp
            Assert.True(await FeatureFlag.IsEnabled("MyFlag5"));  // Needs 1 xp

            await GetLockedAndUnlockedFeatures(xpSys, xpSys.GetLastCachedXp());
        }
示例#9
0
 void Awake()
 {
     progressionSystemInstance = progressionHolder.GetComponent <ProgressionSystem>();
 }
示例#10
0
 private void Awake()
 {
     _collider = GetComponent <Collider2D>();
     _upgrades = ProgressionSystem.Instance;
     _rb       = GetComponent <Rigidbody2D>();
 }