Example #1
0
    private void Awake()
    {
        Debug.Assert(_globalItemQueue != null);

        _difficulty = DifficultyController.Instance;
        Debug.Assert(_difficulty != null);
    }
Example #2
0
        public void Run()
        {
            this.soundEffects.PlayStart();

            CollisionResolver    collisionResolver    = new CollisionResolver(this.soundEffects, this.scoreContainer);
            DifficultyController difficultyController =
                new DifficultyController(
                    this.graphicalObjects,
                    this.objectGenerator,
                    this.scoreContainer);

            while (true)
            {
                Thread.Sleep(this.threadSleepTime);

                this.ReadAndProcessCommands(this.graphicalObjects);

                this.UpdateObjects();

                collisionResolver.Resolve(this.graphicalObjects);

                this.DrawObjects();

                this.scoreContainer.DrawScore();

                difficultyController.UpdateDifficulty();

                // Go to game over screen condition
                if (this.graphicalObjects.SpaceShipPlayerOne.HealthPoints == 0)
                {
                    this.soundEffects.PlayExplosion();
                    break;
                }
            }
        }
Example #3
0
 void Start()
 {
     playerPrefsController = FindObjectOfType <PlayerPrefsController>();
     randomCubeGenerator   = FindObjectOfType <RandomCubeGenerator>();
     difficultyController  = FindObjectOfType <DifficultyController>();
     volumeSlider.value    = PlayerPrefsController.GetMasterVolume();
 }
        public async Task Create_NoAdminPrivileges_NotAddedToDatabase()
        {
            // Arrange
            var identity    = new GenericIdentity("Jack");
            var principal   = new Mock <ClaimsPrincipal>();
            var mockService = new Mock <IDifficultyService>();
            DifficultyController controller = new DifficultyController(mockService.Object);
            var controllerContext           = new Mock <ControllerContext>();

            principal.Setup(p => p.IsInRole("Administrator"))
            .Returns(false);
            principal.SetupGet(p => p.Identity.Name).Returns("Jack");
            controllerContext.SetupGet(c => c.HttpContext.User)
            .Returns(principal.Object);
            controller.ControllerContext = controllerContext.Object;

            var difficultyListViewModel = new DifficultyCreateViewModel {
                Name = "Red", Color = "#4286f4"
            };

            // Act
            var result = await controller.Create(difficultyListViewModel);

            // Assert
            var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result);

            Assert.Equal("Difficulty", redirectToActionResult.ControllerName);
            Assert.Equal("Create", redirectToActionResult.ActionName);
            mockService.Verify(service => service.AddDifficulty(It.IsAny <string>(), It.IsAny <string>()), Times.Never); // checks that the sectionService.AddSection was called once.
        }
 private void Awake()
 {
     _memoryGameController = GetComponentInParent <MemoryGameController>();
     _difficultyController = _memoryGameController.DifficultyController;
     _gameModelSO          = Data.Instance.MemoryGameModel;
     _cardData             = _gameModelSO.GetCardData();
 }
Example #6
0
        /// <summary>
        /// Updates the dc
        /// </summary>
        public void DrawDifficultyController()
        {
            DifficultyController dc = mc.GetDifficultyController();

            playerStatusLabel.Content  = dc.GetPlayerStatus();
            eventModifierLabel.Content = dc.GetEventModifier();
            endLocChanceLabel.Content  = dc.GetEndLocationChance();
            eventChanceLabel.Content   = dc.GetEventChance();

            List <double> tracker = dc.GetPlayerStatusTracker();

            trackerLB.ItemsSource = tracker;

            List <double> yValues = new List <double>();

            if (tracker.Count > 0)
            {
                var bestFit = dc.GenerateBestFitLine();

                foreach (var fit in bestFit)
                {
                    yValues.Add(fit.Item2);
                }
            }
            bestFitLineLB.ItemsSource = yValues;
        }
Example #7
0
        public void DifficultyController_UpdatePlayerStatus()
        {
            DifficultyController dc = new DifficultyController(validStrings[0].Item1);

            Assert.AreEqual(1.1, dc.GetPlayerStatus(), "Player status should be 1.1");
            Assert.AreEqual(0, dc.GetEndLocationChance(), "Should be no chance of end location");
            Assert.AreEqual(0.9d, dc.GetEventModifier(), 0.0001, "Event modifier should be 0.9");
            Assert.AreEqual(0, dc.GetPlayerStatusTracker().Count, "Status tracker should be empty");
            //Assert.IsTrue(40 / 100 <= dc.GetEventChance() && dc.GetEventChance() <= 80 / 100, "Event chance should be between 40% and 80%");

            int    statsSum  = 300;
            double invValue  = 0.125;
            double newStatus = (double)statsSum / 400 + invValue;
            double current   = dc.GetPlayerStatus();
            double expected  = 0.75d * current + (1 - 0.75d) * newStatus;

            dc.UpdatePlayerStatus(statsSum, invValue);
            Assert.AreEqual(expected, dc.GetPlayerStatus(), "Player status should be the same as expected");

            statsSum  = 320;
            invValue  = 0.1;
            newStatus = (double)statsSum / 400 + invValue;
            current   = dc.GetPlayerStatus();
            expected  = 0.75d * current + (1 - 0.75d) * newStatus;

            dc.UpdatePlayerStatus(statsSum, invValue);
            Assert.AreEqual(expected, dc.GetPlayerStatus(), "Player status should be the same as expected");
        }
Example #8
0
    private IEnumerator IncrementSpawnAmount()
    {
        yield return(new WaitForSeconds(DifficultyController.GetIncrementTime()));

        amountToSpawn++;
        print("incrementing amount, amount is now: " + amountToSpawn);
        StartCoroutine(IncrementSpawnAmount());
    }
Example #9
0
 public void DifficultyController_ParseToString()
 {
     foreach (Tuple <String, String> test in validStrings)
     {
         DifficultyController dc = new DifficultyController(test.Item1);
         Assert.AreEqual(test.Item1, dc.ParseToString(), "String should be equal");
     }
 }
Example #10
0
    private void Start()
    {
        DifficultyController difficultyController = FindObjectOfType <DifficultyController>();
        Difficulty           difficulty           = difficultyController.getDifficulty();

        health = Mathf.RoundToInt(health * difficulty.getHealthScaling());
        onPlayerBaseDamaged.Invoke(health);
    }
Example #11
0
        public void DifficultyController_StandardConstructor()
        {
            DifficultyController dc = new DifficultyController();

            Assert.AreEqual(1, dc.GetPlayerStatus(), "Player status should be 1");
            Assert.AreEqual(0, dc.GetEndLocationChance(), "Should be no chance of end location");
            Assert.AreEqual(1d, dc.GetEventModifier(), "Event modifier should be 1");
            Assert.AreEqual(0, dc.GetPlayerStatusTracker().Count, "Status tracker should be empty");
            //Assert.IsTrue(40 / 100 <= dc.GetEventChance() && dc.GetEventChance() <= 80 / 100, "Event chance should be between 40% and 80%");
        }
Example #12
0
 // Start is called before the first frame update
 void Start()
 {
     if (difficulty == null)
     {
         difficulty = this;
     }
     else
     {
         Destroy(this);
     }
 }
Example #13
0
    // Start is called before the first frame update
    void Start()
    {
        if (DifficultyController.DifficultyProgress() < min || DifficultyController.DifficultyProgress() > max)
        {
            gameObject.SetActive(false);

            /*if (DifficultyController.DifficultyProgress() < min)
             *  Debug.Log("Current difficulty too low, despawning!");
             * else
             *  Debug.Log("Current difficulty too high, despawning!");*/
        }
    }
Example #14
0
        public void DifficultyController_CheckStringIsValid()
        {
            foreach (Tuple <String, String> test in validStrings)
            {
                Assert.IsTrue(DifficultyController.IsValidDifficultyController(test.Item1), test.Item2);
            }

            foreach (Tuple <String, String> test in invalidStrings)
            {
                Assert.IsFalse(DifficultyController.IsValidDifficultyController(test.Item1), test.Item2);
            }
        }
        void Start()
        {
            //Positioning at Top of Screen
            gameObject.transform.position = Positioner.GetScreenTopMiddle();

            _gameManager          = FindObjectOfType <GameManager>();
            _currentSpawnInterval = FindObjectOfType <GameManager>().startSpawnInterval;
            _difficultyController = FindObjectOfType <DifficultyController>();
            StartCoroutine(nameof(SpawnRandom));

            _difficultyController.IncreaseDifficulty += IncreaseDifficulty;
        }
Example #16
0
 private void Awake()
 {
     _controllers = new Controllers();
     Initialization();
     ScreenInterface.GetInstance().Execute(ScreenType.GameMenu);
     _mainCanvas               = GameObject.FindGameObjectWithTag("MainCanvas").GetComponent <Canvas>();
     _gameMenu                 = _mainCanvas.GetComponentInChildren <GameMenuBehaviour>();
     _helpButton               = _gameMenu.GameMenuHelpButton;
     _tutorialHand             = _mainCanvas.GetComponentInChildren <TutorialHandBehaviour>();
     CardDealerController      = (CardDealerController)_controllers._initializations[0];
     DifficultyController      = (DifficultyController)_controllers._initializations[1];
     CameraAnimationController = GetComponentInChildren <CameraAnimationController>();
 }
    // Use this for initialization
    void Start()
    {
        //Reset the difficulty on load
        DifficultyController.ResetVariables();

        highScoreText.text = HighScoreController.GetHighScores();

        flashPanel.SetActive(false);
        AdjustScore(0);             //Initialize the score text to current;
        TakeDamage(0, Color.black); //Initialize the text to the current health

        //Begin the incrememnting of the difficulty
        //Every 20 seconds, increment difficulty
        InvokeRepeating("IncrementDifficulty", .2f, difficultyIncrementInterval);
    }
Example #18
0
    private void Start()
    {
        defendersParent = GameObject.Find(DEFENDER_PARENT_NAME) ?? new GameObject(DEFENDER_PARENT_NAME);

        DifficultyController difficultyController = FindObjectOfType <DifficultyController>();
        Difficulty           difficulty           = difficultyController.getDifficulty();

        stars = Mathf.RoundToInt(stars * difficulty.getStartingStarAmountScaling());
        onStarAmountUpdated.Invoke(stars);

        foreach (DefenderIcon defenderIcon in FindObjectsOfType <DefenderIcon>())
        {
            defenderIcon.registerOnDefenderSelected((selectedDefender) => setDefender(selectedDefender));
        }
        onStarGeneration.AddListener((amount) => addStars(amount));
    }
Example #19
0
    // Token: 0x06001BF1 RID: 7153 RVA: 0x00087438 File Offset: 0x00085638
    public void Awake()
    {
        InventoryManager.Instance = this;
        CleverMenuItemSelectionManager expr_0C = this.NavigationManager;

        expr_0C.OptionChangeCallback = (Action)Delegate.Combine(expr_0C.OptionChangeCallback, new Action(this.OnMenuItemChange));
        CleverMenuItemSelectionManager expr_33 = this.NavigationManager;

        expr_33.OptionPressedCallback = (Action)Delegate.Combine(expr_33.OptionPressedCallback, new Action(this.OnMenuItemPressed));
        CleverMenuItemSelectionManager expr_5A = this.NavigationManager;

        expr_5A.OnBackPressedCallback = (Action)Delegate.Combine(expr_5A.OnBackPressedCallback, new Action(this.OnBackPressed));
        DifficultyController expr_80 = DifficultyController.Instance;

        expr_80.OnDifficultyChanged = (Action)Delegate.Combine(expr_80.OnDifficultyChanged, new Action(this.OnDifficultyChanged));
    }
Example #20
0
    private void Awake()
    {
        LevelController levelController = FindObjectOfType <LevelController>();

        levelController.addEnemy();

        Damagable damagable = GetComponent <Damagable>();

        damagable?.registerOnKilled(() => levelController.removeEnemy());

        DifficultyController difficultyController = FindObjectOfType <DifficultyController>();
        Difficulty           difficulty           = difficultyController.getDifficulty();
        Walker walker = GetComponent <Walker>();

        walker?.setWalkSpeed(walker.getWalkSpeed() * difficulty.getEnemySpeedScaling());
    }
Example #21
0
        public void DifficultyController_ParseFromString()
        {
            DifficultyController dc = new DifficultyController(validStrings[0].Item1);

            Assert.AreEqual(1.1, dc.GetPlayerStatus(), "Player status should be 1.1");
            Assert.AreEqual(0, dc.GetEndLocationChance(), "Should be no chance of end location");
            Assert.AreEqual(0.9d, dc.GetEventModifier(), 0.0001, "Event modifier should be 0.9");
            Assert.AreEqual(0, dc.GetPlayerStatusTracker().Count, "Status tracker should be empty");
            Assert.IsTrue(0.4d <= dc.GetEventChance() && dc.GetEventChance() <= 0.8d, "Event chance should be between 40% and 80%");

            dc = new DifficultyController(validStrings[2].Item1);
            Assert.AreEqual(1.1, dc.GetPlayerStatus(), "Player status should be 1.1");
            Assert.AreEqual(0, dc.GetEndLocationChance(), "Should be no chance of end location");
            Assert.AreEqual(0.9d, dc.GetEventModifier(), 0.0001, "Event modifier should be 0.9");
            Assert.AreEqual(5, dc.GetPlayerStatusTracker().Count, "Status tracker should be empty");
            //Assert.IsTrue(40 / 100 <= dc.GetEventChance() && dc.GetEventChance() <= 80 / 100, "Event chance should be between 40% and 80%");
        }
        [InlineData("Red", "#4286f45")] // Invalid Color
        public async Task Create_InputsAreInvalid_NotAddedToDatabaseAndRedirectsToListAction(string name, string color)
        {
            // Arrange
            var mockService = new Mock <IDifficultyService>();
            DifficultyController controller = new DifficultyController(mockService.Object);
            var difficultyListViewModel     = new DifficultyCreateViewModel {
                Name = name, Color = color
            };

            // Act
            var result = await controller.Create(difficultyListViewModel);

            // Assert
            var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result);

            Assert.Equal("Difficulty", redirectToActionResult.ControllerName);
            Assert.Equal("Create", redirectToActionResult.ActionName);
            mockService.Verify(service => service.AddDifficulty(It.IsAny <string>(), It.IsAny <string>()), Times.Never); // checks that the sectionService.AddSection is never called.
        }
        public async Task Delete_IdValid_RemovedFromDatabaseAndRedirectsToListAction()
        {
            // Arrange
            var mockService = new Mock <IDifficultyService>();
            DifficultyController controller = new DifficultyController(mockService.Object);
            var difficultyListViewModel     = new DifficultyCreateViewModel {
                ID = 1
            };

            // Act
            var result = await controller.Delete(difficultyListViewModel);

            // Assert
            var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result);

            Assert.Equal("Difficulty", redirectToActionResult.ControllerName);
            Assert.Equal("Create", redirectToActionResult.ActionName);
            mockService.Verify(service => service.RemoveDifficulty(It.Is <int?>(i => i == 1)), Times.Once);
        }
Example #24
0
    // Token: 0x06001BF6 RID: 7158 RVA: 0x0008766C File Offset: 0x0008586C
    public void OnDestroy()
    {
        if (InventoryManager.Instance == this)
        {
            InventoryManager.Instance = null;
        }
        CleverMenuItemSelectionManager expr_1C = this.NavigationManager;

        expr_1C.OptionChangeCallback = (Action)Delegate.Remove(expr_1C.OptionChangeCallback, new Action(this.OnMenuItemChange));
        CleverMenuItemSelectionManager expr_43 = this.NavigationManager;

        expr_43.OptionPressedCallback = (Action)Delegate.Remove(expr_43.OptionPressedCallback, new Action(this.OnMenuItemPressed));
        CleverMenuItemSelectionManager expr_6A = this.NavigationManager;

        expr_6A.OnBackPressedCallback = (Action)Delegate.Remove(expr_6A.OnBackPressedCallback, new Action(this.OnBackPressed));
        DifficultyController expr_90 = DifficultyController.Instance;

        expr_90.OnDifficultyChanged = (Action)Delegate.Remove(expr_90.OnDifficultyChanged, new Action(this.OnDifficultyChanged));
    }
Example #25
0
    void Start()
    {
        plopSource = GetComponent <AudioSource>();

        levelNumber = PlayerPrefs.GetInt(levelNumberKey);

        difficultyController = GetComponent <DifficultyController>();

        if (levelNumber == 0)
        {
            levelNumber++;
            PlayerPrefs.SetInt(levelNumberKey, levelNumber);
            PlayerPrefs.Save();
        }

        levelText.text = "";

        CheckIfGameStarted();
    }
Example #26
0
    public static void SaveScore()
    {
        int timeScore = (int)totalTime;

        totalTimeText.text = "Time: " + HighScoreController.convertSecondstoString(timeScore);

        string regionName     = MainMenuController.getRegionName();
        string difficultyName = DifficultyController.getDifficultyName();
        string scoreKey       = regionName + "_" + difficultyName + "_Score_Key";
        string timeKey        = regionName + "_" + difficultyName + "_Time_Key";
        float  highScore      = PlayerPrefs.GetFloat(scoreKey);
        int    bestTime       = PlayerPrefs.GetInt(timeKey);

        if (score > highScore || (score >= highScore && timeScore < bestTime))
        {
            PlayerPrefs.SetFloat(scoreKey, score);
            PlayerPrefs.SetInt(timeKey, timeScore);
        }
    }
Example #27
0
    private void Awake()
    {
        _rigidBody = GetComponent <Rigidbody2D>();
        Debug.Assert(_rigidBody != null);

        Debug.Assert(_cogs != null && _cogs.All(cog => cog != null));
        Debug.Assert(_leftCogs != null && _leftCogs.All(cog => cog != null));
        Debug.Assert(_rightCogs != null && _rightCogs.All(cog => cog != null));

        Debug.Assert(_leftTopBelt != null);
        Debug.Assert(_leftBottomBelt != null);
        Debug.Assert(_rightTopBelt != null);
        Debug.Assert(_rightBottomBelt != null);

        Debug.Assert(_beltCollider != null);
        Debug.Assert(_movementCollider != null);

        _difficulty = DifficultyController.Instance;
        Debug.Assert(_difficulty != null);
    }
        public void List_ValidDifficultyListViewModel_ReturnViewWithDifficultyListViewModel()
        {
            // Arrange
            var mockService = new Mock <IDifficultyService>();

            mockService.Setup(service => service.GetAllDifficulties())
            .Returns(new List <RouteDifficulty> {
                new RouteDifficulty {
                }, new RouteDifficulty {
                }
            });
            DifficultyController controller = new DifficultyController(mockService.Object);

            // Act
            var result = controller.Create();

            // Assert
            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsAssignableFrom <DifficultyCreateViewModel>(
                viewResult.ViewData.Model);

            Assert.Equal(2, model.Difficulties.Count);
        }
Example #29
0
    // Use this for initialization
    protected override void Start()
    {
        audioSource = GetComponent <AudioSource>();
        CurrentXP   = DifficultyController.GetCurrentXP();



        waypoints = new List <Transform>();
        GameObject[] wayPointObjects = GameObject.FindGameObjectsWithTag("Waypoint");
        foreach (GameObject obj in wayPointObjects)
        {
            Transform wp = obj.transform;
            waypoints.Add(wp);
        }
        //print(waypoints.Count);
        InvokeRepeating("IncrementXP", 0, 1);

        nearestWaypoint = closestWaypoint();
        //print(nearestWaypoint.ToString());
        moveDirection = ChooseMoveDirection();
        base.Start();
        levelText = canvas.transform.GetChild(0).GetComponent <Text>();
    }
 // Start is called before the first frame update
 void Start()
 {
     sharedInstance = this;
 }